-
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.
554: finish implementation of wasi::fd_seek, fix bug in filestat r=syrusakbary a=MarkMcCaskey Co-authored-by: Mark McCaskey <[email protected]> Co-authored-by: Syrus <[email protected]>
- Loading branch information
Showing
18 changed files
with
129 additions
and
14 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
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,13 @@ | ||
#[test] | ||
fn test_fseek() { | ||
assert_wasi_output!( | ||
"../../wasitests/fseek.wasm", | ||
"fseek", | ||
vec![( | ||
".".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet") | ||
),], | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
"wasitests/test_fs/hamlet/README.md" | ||
"wasitests/test_fs/hamlet/act1" | ||
"wasitests/test_fs/hamlet/act2" | ||
"wasitests/test_fs/hamlet/act3" | ||
"wasitests/test_fs/hamlet/act4" | ||
"wasitests/test_fs/hamlet/act5" | ||
"./README.md" | ||
"./act1" | ||
"./act2" | ||
"./act3" | ||
"./act4" | ||
"./act5" |
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