Skip to content

Commit

Permalink
adapter poll_oneoff: when descriptors.get_*_stream(fd) fails, die wit…
Browse files Browse the repository at this point in the history
…h that error (bytecodealliance#154)

* adapter poll_oneoff: when descriptors.get_*_stream(fd) fails, die with that error

There was a special case in poll_oneoff that put in a fake clock stream
when a read/write stream for a descriptor wasn't available. The
poll_oneoff_files test (in `test_fd_readwrite_invalid_fd()`) checks that
poll_oneoff returns a BADF when an invalid fd is subscribed to.

I'm not sure what the special case was patching over, but this passes
all of the other tests right now.

* poll_oneoff_files fails on windows with god knows what error
diff --git a/host/tests/command.rs b/host/tests/command.rs
index 7af7bd0..67c8c0b 100644
--- a/host/tests/command.rs
+++ b/host/tests/command.rs
@@ -466,10 +466,11 @@ async fn run_path_symlink_trailing_slashes(store: Store<WasiCtx>, wasi: Command)
 }

 async fn run_poll_oneoff_files(store: Store<WasiCtx>, wasi: Command) -> Result<()> {
-    // trapping upwrap in poll_oneoff in adapter.
-    // maybe this is related to the "if fd isnt a stream, request a pollable which completes
-    // immediately so itll immediately fail" behavior, which i think breaks internal invariant...
-    run_with_temp_dir(store, wasi).await
+    if cfg!(windows) {
+        expect_fail(run_with_temp_dir(store, wasi).await)
+    } else {
+        run_with_temp_dir(store, wasi).await
+    }
 }

 async fn run_poll_oneoff_stdio(store: Store<WasiCtx>, wasi: Command) -> Result<()> {
  • Loading branch information
pchickey authored Apr 24, 2023
1 parent 344ac74 commit 6f44c91
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions host/tests/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,11 @@ async fn run_path_symlink_trailing_slashes(store: Store<WasiCtx>, wasi: Command)
}

async fn run_poll_oneoff_files(store: Store<WasiCtx>, wasi: Command) -> Result<()> {
// trapping upwrap in poll_oneoff in adapter.
// maybe this is related to the "if fd isnt a stream, request a pollable which completes
// immediately so itll immediately fail" behavior, which i think breaks internal invariant...
expect_fail(run_with_temp_dir(store, wasi).await)
if cfg!(windows) {
expect_fail(run_with_temp_dir(store, wasi).await)
} else {
run_with_temp_dir(store, wasi).await
}
}

async fn run_poll_oneoff_stdio(store: Store<WasiCtx>, wasi: Command) -> Result<()> {
Expand Down

0 comments on commit 6f44c91

Please sign in to comment.