Skip to content

Commit

Permalink
wasi: removes constraint around closing a pre-open, and temporarily s…
Browse files Browse the repository at this point in the history
…kips 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 <[email protected]>
  • Loading branch information
codefromthecrypt authored Mar 21, 2023
1 parent a43a0f1 commit 046af43
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .github/wasi_testsuite_skip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"WASI Rust tests": {
"interesting_paths": "config is broken, and after fixing it forbids leading slash with EPERM"
}
}
1 change: 1 addition & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions imports/wasi_snapshot_preview1/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
}
Expand Down
4 changes: 0 additions & 4 deletions internal/sys/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions internal/sys/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
}

Expand Down

0 comments on commit 046af43

Please sign in to comment.