Skip to content

Commit

Permalink
Fix running wasi-common tests on CI (#8353)
Browse files Browse the repository at this point in the history
* Fix running wasi-common tests on CI

Turns out we haven't been running wasi-common tests for some time in CI
and they've started failing. Force enable the test at all times and then
fix the test failures. The test failures here were introduced in #8277
and weren't caught due to the test not running and the fix was to relax
the implementation of `fd_pread` to avoid taking multiple mutable
borrows.

* Fix CI
  • Loading branch information
alexcrichton authored Apr 12, 2024
1 parent 4bc9b7a commit 1a7c006
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/wasi-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ features = [
]

[dev-dependencies]
wasi-common = { path = '.', features = ['tokio'] }
tempfile = { workspace = true }
test-log = { workspace = true }
tracing-subscriber = { workspace = true }
Expand Down Expand Up @@ -98,4 +99,3 @@ all-features = true

[[test]]
name = "all"
required-features = ["wasmtime", "sync", "tokio"]
10 changes: 6 additions & 4 deletions crates/wasi-common/src/snapshots/preview_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,15 @@ impl wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiCtx {
return Ok(0);
}
} else {
// Convert all of the unsafe guest slices to safe ones--this uses
// Wiggle's internal borrow checker to ensure no overlaps. We assume
// here that, because the memory is not shared, there are no other
// threads to access it while it is written to.
// Convert unsafe guest slices to safe ones -- this uses Wiggle's
// internal borrow checker to ensure no overlaps. Note that borrow
// checking is coarse at this time so at most one non-empty slice is
// chosen.
let mut guest_slices: Vec<wiggle::GuestSliceMut<u8>> = iovs
.into_iter()
.filter(|iov| iov.len() > 0)
.map(|iov| Ok(iov.as_slice_mut()?.unwrap()))
.take(1)
.collect::<Result<_, Error>>()?;

// Read directly into the Wasm memory.
Expand Down

0 comments on commit 1a7c006

Please sign in to comment.