-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
113 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
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,10 @@ | ||
#[test] | ||
fn test_fseek() { | ||
assert_wasi_output!( | ||
"../../wasitests/fseek.wasm", | ||
"fseek", | ||
vec![], | ||
vec![], | ||
"../../wasitests/fseek.out" | ||
); | ||
} |
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ mod create_dir; | |
mod envvar; | ||
mod file_metadata; | ||
mod fs_sandbox_test; | ||
mod fseek; | ||
mod hello; | ||
mod mapdir; | ||
mod quine; |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,11 @@ | ||
SCENE III. A room in Polonius' h | ||
ouse. | ||
|
||
Enter LAERTES and OPH | ||
And, sister, as the winds gi | ||
r talk with the Lord Hamlet. | ||
|
||
uits, | ||
Breathing like sanctif | ||
is is for all: | ||
I would not, |
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,47 @@ | ||
// Args: | ||
// mapdir: .:wasitests/test_fs/hamlet | ||
|
||
use std::fs; | ||
use std::io::{Read, Seek, SeekFrom}; | ||
use std::path::PathBuf; | ||
|
||
fn main() { | ||
#[cfg(not(target_os = "wasi"))] | ||
let mut base = PathBuf::from("wasitests/test_fs/hamlet"); | ||
#[cfg(target_os = "wasi")] | ||
let mut base = PathBuf::from("."); | ||
|
||
base.push("act1/scene3.txt"); | ||
|
||
let mut file = fs::File::open(&base).expect("Could not open file"); | ||
|
||
let mut buffer = [0u8; 32]; | ||
|
||
assert_eq!(file.read(&mut buffer).unwrap(), 32); | ||
let str_val = std::str::from_utf8(&buffer[..]).unwrap(); | ||
println!("{}", str_val); | ||
|
||
assert_eq!(file.read(&mut buffer).unwrap(), 32); | ||
let str_val = std::str::from_utf8(&buffer[..]).unwrap(); | ||
println!("{}", str_val); | ||
|
||
assert_eq!(file.seek(SeekFrom::Start(123)).unwrap(), 123); | ||
assert_eq!(file.read(&mut buffer).unwrap(), 32); | ||
let str_val = std::str::from_utf8(&buffer[..]).unwrap(); | ||
println!("{}", str_val); | ||
|
||
assert_eq!(file.seek(SeekFrom::End(-123)).unwrap(), 6617); | ||
assert_eq!(file.read(&mut buffer).unwrap(), 32); | ||
let str_val = std::str::from_utf8(&buffer[..]).unwrap(); | ||
println!("{}", str_val); | ||
|
||
assert_eq!(file.seek(SeekFrom::Current(-250)).unwrap(), 6399); | ||
assert_eq!(file.read(&mut buffer).unwrap(), 32); | ||
let str_val = std::str::from_utf8(&buffer[..]).unwrap(); | ||
println!("{}", str_val); | ||
|
||
assert_eq!(file.seek(SeekFrom::Current(50)).unwrap(), 6481); | ||
assert_eq!(file.read(&mut buffer).unwrap(), 32); | ||
let str_val = std::str::from_utf8(&buffer[..]).unwrap(); | ||
println!("{}", str_val); | ||
} |
Binary file not shown.
Binary file not shown.
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
Binary file not shown.
Binary file not shown.
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