-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for opening miscellaneous devices on UNIX-alikes.
Fixes #514, but CI is grumpy and I have questions. Both the sync and async variants run by `cargo test -p wasi-common preview1_device_read` work and are valid. However, `foreach_preview1!(assert_test_exists)` fails its assertions when I run `ci/run-tests.sh` unless I repeat my tests in `wasi` (commented out here) as well as `wasi-common`. Is that the intent? I'm not sure what value such repetition has for this test. Perhaps I'm adding tests in the wrong place altogether. I welcome any illumination! Note that I've hard-coded a "/dev" preopen into the test harnesses temporarily. Once I'm sure I'm adding to the right set of tests, I'll refactor to pass it only for this new one.
- Loading branch information
Showing
5 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use std::fs::OpenOptions; | ||
use std::io::Read; | ||
|
||
/// Assert that we can read from "miscellanous" devices such as /dev/zero on UNIX-alikes (assuming | ||
/// /dev is passed as a preopen). | ||
fn main() { | ||
let mut device = OpenOptions::new() | ||
.read(true) | ||
.open("zero") | ||
.expect("/dev/zero should be found and openable"); | ||
let mut buffer = [1, 1]; | ||
device | ||
.read_exact(&mut buffer) | ||
.expect("/dev/zero should be readable"); | ||
assert_eq!(buffer, [0, 0]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters