From 046af4356e42d44a6751fdb120d0009e3b814b4b Mon Sep 17 00:00:00 2001 From: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com> Date: Tue, 21 Mar 2023 23:43:59 +0800 Subject: [PATCH] wasi: removes constraint around closing a pre-open, and temporarily skips interesting_paths (#1265) wasi-testsuite changed its mind on pre-open WebAssembly/wasi-testsuite#66 they also now explicitly forbid paths being passed in with a leading slash. Even when the config bug on WebAssembly/wasi-testsuite#67 is finished, this requires discussion if we want to EPERM on that. Signed-off-by: Adrian Cole --- .github/wasi_testsuite_skip.json | 5 +++++ .github/workflows/integration.yaml | 1 + imports/wasi_snapshot_preview1/fs_test.go | 6 +++--- internal/sys/fs.go | 4 ---- internal/sys/fs_test.go | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 .github/wasi_testsuite_skip.json diff --git a/.github/wasi_testsuite_skip.json b/.github/wasi_testsuite_skip.json new file mode 100644 index 0000000000..2b4032822f --- /dev/null +++ b/.github/wasi_testsuite_skip.json @@ -0,0 +1,5 @@ +{ + "WASI Rust tests": { + "interesting_paths": "config is broken, and after fixing it forbids leading slash with EPERM" + } +} diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index d8375d58f9..6d4501294b 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -304,6 +304,7 @@ jobs: -t ./tests/assemblyscript/testsuite/ \ ./tests/c/testsuite/ \ ./tests/rust/testsuite/ \ + -f ../.github/wasi_testsuite_skip.json \ -r ../.github/wasi_testsuite_adapter.py build_gojs_test_binaries: diff --git a/imports/wasi_snapshot_preview1/fs_test.go b/imports/wasi_snapshot_preview1/fs_test.go index e956db5c8b..fb4003929b 100644 --- a/imports/wasi_snapshot_preview1/fs_test.go +++ b/imports/wasi_snapshot_preview1/fs_test.go @@ -164,11 +164,11 @@ func Test_fdClose(t *testing.T) { `, "\n"+log.String()) }) log.Reset() - t.Run("ErrnoNotsup for a preopen", func(t *testing.T) { - requireErrnoResult(t, ErrnoNotsup, mod, FdCloseName, uint64(sys.FdPreopen)) + t.Run("Can close a pre-open", func(t *testing.T) { + requireErrnoResult(t, ErrnoSuccess, mod, FdCloseName, uint64(sys.FdPreopen)) require.Equal(t, ` ==> wasi_snapshot_preview1.fd_close(fd=3) -<== errno=ENOTSUP +<== errno=ESUCCESS `, "\n"+log.String()) }) } diff --git a/internal/sys/fs.go b/internal/sys/fs.go index 5f87d783f2..f59ecd1ca9 100644 --- a/internal/sys/fs.go +++ b/internal/sys/fs.go @@ -447,10 +447,6 @@ func (c *FSContext) CloseFile(fd uint32) error { f, ok := c.openedFiles.Lookup(fd) if !ok { return syscall.EBADF - } else if f.IsPreopen { - // WASI is the only user of pre-opens and wasi-testsuite disallows this - // See https://github.com/WebAssembly/wasi-testsuite/issues/50 - return syscall.ENOTSUP } c.openedFiles.Delete(fd) return f.File.Close() diff --git a/internal/sys/fs_test.go b/internal/sys/fs_test.go index b35de3bfbc..8f22ea9ffd 100644 --- a/internal/sys/fs_test.go +++ b/internal/sys/fs_test.go @@ -125,8 +125,8 @@ func TestFSContext_CloseFile(t *testing.T) { t.Run("EBADF for an invalid FD", func(t *testing.T) { require.Equal(t, syscall.EBADF, fsc.CloseFile(42)) // 42 is an arbitrary invalid FD }) - t.Run("ENOTSUP for a preopen", func(t *testing.T) { - require.Equal(t, syscall.ENOTSUP, fsc.CloseFile(FdPreopen)) // 42 is an arbitrary invalid FD + t.Run("Can close a pre-open", func(t *testing.T) { + require.NoError(t, fsc.CloseFile(FdPreopen)) }) }