-
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
40 changed files
with
1,196 additions
and
593 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
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
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ fn test_fs_sandbox_test() { | |
"fs_sandbox_test", | ||
vec![], | ||
vec![], | ||
vec![], | ||
"../../wasitests/fs_sandbox_test.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 |
---|---|---|
|
@@ -5,6 +5,7 @@ fn test_hello() { | |
"hello", | ||
vec![], | ||
vec![], | ||
vec![], | ||
"../../wasitests/hello.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 |
---|---|---|
|
@@ -13,3 +13,6 @@ mod fseek; | |
mod hello; | ||
mod mapdir; | ||
mod quine; | ||
mod readlink; | ||
mod wasi_sees_virtual_root; | ||
mod writing; |
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,14 @@ | ||
#[test] | ||
fn test_readlink() { | ||
assert_wasi_output!( | ||
"../../wasitests/readlink.wasm", | ||
"readlink", | ||
vec![], | ||
vec![( | ||
".".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet") | ||
),], | ||
vec![], | ||
"../../wasitests/readlink.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,24 @@ | ||
#[test] | ||
fn test_wasi_sees_virtual_root() { | ||
assert_wasi_output!( | ||
"../../wasitests/wasi_sees_virtual_root.wasm", | ||
"wasi_sees_virtual_root", | ||
vec![], | ||
vec![ | ||
( | ||
"act1".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act1") | ||
), | ||
( | ||
"act2".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act2") | ||
), | ||
( | ||
"act1-again".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act1") | ||
), | ||
], | ||
vec![], | ||
"../../wasitests/wasi_sees_virtual_root.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,24 @@ | ||
#[test] | ||
fn test_writing() { | ||
assert_wasi_output!( | ||
"../../wasitests/writing.wasm", | ||
"writing", | ||
vec![], | ||
vec![ | ||
( | ||
"act1".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act1") | ||
), | ||
( | ||
"act2".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act2") | ||
), | ||
( | ||
"act1-again".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act1") | ||
), | ||
], | ||
vec![], | ||
"../../wasitests/writing.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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// Args: | ||
// dir: . | ||
|
||
use std::fs; | ||
use std::io::{Read, Seek, SeekFrom, Write}; | ||
use std::path::*; | ||
|
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,3 +1,3 @@ | ||
is dir: false | ||
filetype: false true false | ||
file info: 456 | ||
file info: 476 |
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,3 +1,6 @@ | ||
// Args: | ||
// dir: . | ||
|
||
use std::fs; | ||
use std::io::Read; | ||
|
||
|
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 +1 @@ | ||
create_dir | ||
|
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
"./act3" | ||
"./act4" | ||
"./act5" | ||
"./bookmarks" |
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,3 +1,6 @@ | ||
// Args: | ||
// dir: . | ||
|
||
use std::fs; | ||
use std::io::Read; | ||
|
||
|
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,3 +1,6 @@ | ||
// Args: | ||
// dir: . | ||
|
||
use std::fs; | ||
use std::io::Read; | ||
|
||
|
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 @@ | ||
../act1/scene2.txt | ||
SCENE II. A room of state in the castle. | ||
|
||
Enter KING CLAUDIUS, QUEEN GERTRUDE, HAMLET, POLONIUS, LAERTES, VOLTIMAND, CORNELI |
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,27 @@ | ||
// Args: | ||
// mapdir: .:wasitests/test_fs/hamlet | ||
use std::io::Read; | ||
|
||
fn main() { | ||
#[cfg(not(target_os = "wasi"))] | ||
let cur_dir = std::env::current_dir().unwrap(); | ||
#[cfg(not(target_os = "wasi"))] | ||
std::env::set_current_dir("wasitests/test_fs/hamlet").unwrap(); | ||
|
||
let sym_link_path = "bookmarks/2019-07-16"; | ||
|
||
let link_path = std::fs::read_link(sym_link_path).unwrap(); | ||
println!("{}", link_path.to_string_lossy()); | ||
|
||
let mut some_contents = std::fs::File::open(sym_link_path).unwrap(); | ||
|
||
let mut buffer = [0; 128]; | ||
|
||
assert_eq!(some_contents.read(&mut buffer).unwrap(), 128); | ||
let str_val = std::str::from_utf8(&buffer[..]).unwrap(); | ||
println!("{}", str_val); | ||
|
||
// return to the current directory | ||
#[cfg(not(target_os = "wasi"))] | ||
std::env::set_current_dir(cur_dir).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../act1/scene2.txt |
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 @@ | ||
"/act1" | ||
"/act1-again" | ||
"/act2" | ||
"/act1" | ||
"/act1-again" | ||
"/act2" | ||
"/act1" | ||
"/act1-again" | ||
"/act2" | ||
"/act1" | ||
"/act1-again" | ||
"/act2" | ||
ROOT IS SAFE |
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,59 @@ | ||
// Args: | ||
// mapdir: act1:wasitests/test_fs/hamlet/act1 | ||
// mapdir: act2:wasitests/test_fs/hamlet/act2 | ||
// mapdir: act1-again:wasitests/test_fs/hamlet/act1 | ||
|
||
use std::fs; | ||
|
||
fn main() { | ||
// just cheat in this test because there is no comparison for native | ||
#[cfg(not(target_os = "wasi"))] | ||
let results = { | ||
let start = vec!["\"/act1\"", "\"/act1-again\"", "\"/act2\""]; | ||
|
||
let mut out = vec![]; | ||
for _ in 0..4 { | ||
for path_str in &start { | ||
out.push(path_str.to_string()); | ||
} | ||
} | ||
|
||
out.push("ROOT IS SAFE".to_string()); | ||
out | ||
}; | ||
|
||
#[cfg(target_os = "wasi")] | ||
let results = { | ||
let mut out = vec![]; | ||
|
||
let read_dir = fs::read_dir("/").unwrap(); | ||
for entry in read_dir { | ||
out.push(format!("{:?}", entry.unwrap().path())) | ||
} | ||
let read_dir = fs::read_dir("act1/..").unwrap(); | ||
for entry in read_dir { | ||
out.push(format!("{:?}", entry.unwrap().path())) | ||
} | ||
let read_dir = fs::read_dir("act1/../../..").unwrap(); | ||
for entry in read_dir { | ||
out.push(format!("{:?}", entry.unwrap().path())) | ||
} | ||
let read_dir = fs::read_dir("act1/../../act2/../act1/../../../").unwrap(); | ||
for entry in read_dir { | ||
out.push(format!("{:?}", entry.unwrap().path())) | ||
} | ||
let f = fs::OpenOptions::new().write(true).open("/abc"); | ||
|
||
if f.is_ok() { | ||
out.push("ROOT IS NOT SAFE".to_string()); | ||
} else { | ||
out.push("ROOT IS SAFE".to_string()); | ||
} | ||
|
||
out | ||
}; | ||
|
||
for result in results { | ||
println!("{}", result); | ||
} | ||
} |
Binary file not shown.
Oops, something went wrong.