-
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.
643: Improve error reporting of IO errors, implement path_symlink r=MarkMcCaskey a=MarkMcCaskey Co-authored-by: Mark McCaskey <[email protected]>
- Loading branch information
Showing
9 changed files
with
361 additions
and
21 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,20 @@ | ||
#[test] | ||
fn test_path_symlink() { | ||
assert_wasi_output!( | ||
"../../wasitests/path_symlink.wasm", | ||
"path_symlink", | ||
vec![], | ||
vec![ | ||
( | ||
"temp".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/temp") | ||
), | ||
( | ||
"hamlet".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet") | ||
), | ||
], | ||
vec![], | ||
"../../wasitests/path_symlink.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ACT III | ||
SCENE I. A room in the castle. | ||
|
||
Enter KING CLAUDIUS, |
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,30 @@ | ||
// Args: | ||
// mapdir: temp:wasitests/test_fs/temp | ||
// mapdir: hamlet: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"); | ||
#[cfg(target_os = "wasi")] | ||
let mut base = PathBuf::from("/"); | ||
|
||
let symlink_loc = base.join("temp/act3"); | ||
let symlink_target = "../hamlet/act3"; | ||
let scene1 = symlink_loc.join("scene1.txt"); | ||
|
||
std::fs::soft_link(&symlink_target, &symlink_loc); | ||
|
||
let mut file = fs::File::open(&scene1).expect("Could not open file"); | ||
|
||
let mut buffer = [0u8; 64]; | ||
|
||
assert_eq!(file.read(&mut buffer).unwrap(), 64); | ||
let str_val = std::str::from_utf8(&buffer[..]).unwrap(); | ||
println!("{}", str_val); | ||
|
||
std::fs::remove_file(symlink_loc).unwrap(); | ||
} |
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
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
Oops, something went wrong.