diff --git a/build.rs b/build.rs index 7707daa1848..50e0074a31b 100644 --- a/build.rs +++ b/build.rs @@ -20,6 +20,8 @@ fn main() -> anyhow::Result<()> { .expect("Can't get directory"); build_deps::rerun_if_changed_paths("tests/wasi-wast/wasi/snapshot1/*") .expect("Can't get directory"); + build_deps::rerun_if_changed_paths("tests/wasi-wast/wasi/nightly-2022-10-18/*") + .expect("Can't get directory"); let out_dir = PathBuf::from( env::var_os("OUT_DIR").expect("The OUT_DIR environment variable must be set"), @@ -66,7 +68,7 @@ fn main() -> anyhow::Result<()> { }; with_test_module(&mut wasitests, "wasitests", |wasitests| { - for wasi_version in &["unstable", "snapshot1"] { + for wasi_version in &["unstable", "snapshot1", "nightly_2022_10_18"] { with_test_module(wasitests, wasi_version, |wasitests| { for (wasi_filesystem_test_name, wasi_filesystem_kind) in &[ ("host_fs", "WasiFileSystemKind::Host"), diff --git a/lib/vfs/src/lib.rs b/lib/vfs/src/lib.rs index e6c028724a1..d7be3ac4ae6 100644 --- a/lib/vfs/src/lib.rs +++ b/lib/vfs/src/lib.rs @@ -72,15 +72,27 @@ pub trait FileOpener { #[derive(Debug, Clone)] pub struct OpenOptionsConfig { - read: bool, - write: bool, - create_new: bool, - create: bool, - append: bool, - truncate: bool, + pub read: bool, + pub write: bool, + pub create_new: bool, + pub create: bool, + pub append: bool, + pub truncate: bool, } impl OpenOptionsConfig { + /// Returns the minimum allowed rights, given the rights of the parent directory + pub fn minimum_rights(&self, parent_rights: &Self) -> Self { + Self { + read: parent_rights.read && self.read, + write: parent_rights.write && self.write, + create_new: parent_rights.create_new && self.create_new, + create: parent_rights.create && self.create, + append: parent_rights.append && self.append, + truncate: parent_rights.truncate && self.truncate, + } + } + pub const fn read(&self) -> bool { self.read } @@ -106,7 +118,11 @@ impl OpenOptionsConfig { } } -// TODO: manually implement debug +impl fmt::Debug for OpenOptions { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.conf.fmt(f) + } +} pub struct OpenOptions { opener: Box, @@ -127,6 +143,11 @@ impl OpenOptions { }, } } + + pub fn get_config(&self) -> OpenOptionsConfig { + self.conf.clone() + } + pub fn options(&mut self, options: OpenOptionsConfig) -> &mut Self { self.conf = options; self diff --git a/lib/vfs/src/mem_fs/filesystem.rs b/lib/vfs/src/mem_fs/filesystem.rs index 57982fd38e2..6943c7f20a5 100644 --- a/lib/vfs/src/mem_fs/filesystem.rs +++ b/lib/vfs/src/mem_fs/filesystem.rs @@ -327,7 +327,7 @@ impl FileSystemInner { let mut components = path.components(); match components.next() { - Some(Component::RootDir) => {} + Some(Component::RootDir) | None => {} _ => return Err(FsError::BaseNotDirectory), } diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index 637412be11a..7f210de0914 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -2277,9 +2277,10 @@ pub fn path_open( if !working_dir.rights.contains(Rights::PATH_OPEN) { return Errno::Access; } + let path_string = unsafe { get_input_str!(&memory, path, path_len) }; - debug!("=> fd: {}, path: {}", dirfd, &path_string); + debug!("=> path_open(): fd: {}, path: {}", dirfd, &path_string); let path_arg = std::path::PathBuf::from(&path_string); let maybe_inode = state.fs.get_inode_at_path( @@ -2293,8 +2294,61 @@ pub fn path_open( // TODO: traverse rights of dirs properly // COMMENTED OUT: WASI isn't giving appropriate rights here when opening // TODO: look into this; file a bug report if this is a bug + // + // Maximum rights: should be the working dir rights + // Minimum rights: whatever rights are provided let adjusted_rights = /*fs_rights_base &*/ working_dir_rights_inheriting; let mut open_options = state.fs_new_open_options(); + + let target_rights = match maybe_inode { + Ok(_) => { + let write_permission = adjusted_rights.contains(Rights::FD_WRITE); + + // append, truncate, and create all require the permission to write + let (append_permission, truncate_permission, create_permission) = if write_permission { + ( + fs_flags.contains(Fdflags::APPEND), + o_flags.contains(Oflags::TRUNC), + o_flags.contains(Oflags::CREATE), + ) + } else { + (false, false, false) + }; + + wasmer_vfs::OpenOptionsConfig { + read: fs_rights_base.contains(Rights::FD_READ), + write: write_permission, + create_new: create_permission && o_flags.contains(Oflags::EXCL), + create: create_permission, + append: append_permission, + truncate: truncate_permission, + } + } + Err(_) => wasmer_vfs::OpenOptionsConfig { + append: fs_flags.contains(Fdflags::APPEND), + write: fs_rights_base.contains(Rights::FD_WRITE), + read: fs_rights_base.contains(Rights::FD_READ), + create_new: o_flags.contains(Oflags::CREATE) && o_flags.contains(Oflags::EXCL), + create: o_flags.contains(Oflags::CREATE), + truncate: o_flags.contains(Oflags::TRUNC), + }, + }; + + let parent_rights = wasmer_vfs::OpenOptionsConfig { + read: working_dir.rights.contains(Rights::FD_READ), + write: working_dir.rights.contains(Rights::FD_WRITE), + // The parent is a directory, which is why these options + // aren't inherited from the parent (append / truncate doesn't work on directories) + create_new: true, + create: true, + append: true, + truncate: true, + }; + + let minimum_rights = target_rights.minimum_rights(&parent_rights); + + open_options.options(minimum_rights.clone()); + let inode = if let Ok(inode) = maybe_inode { // Happy path, we found the file we're trying to open let mut guard = inodes.arena[inode].write(); @@ -2318,35 +2372,25 @@ pub fn path_open( return Errno::Exist; } - let write_permission = adjusted_rights.contains(Rights::FD_WRITE); - // append, truncate, and create all require the permission to write - let (append_permission, truncate_permission, create_permission) = - if write_permission { - ( - fs_flags.contains(Fdflags::APPEND), - o_flags.contains(Oflags::TRUNC), - o_flags.contains(Oflags::CREATE), - ) - } else { - (false, false, false) - }; let open_options = open_options - .read(true) - // TODO: ensure these rights are actually valid given parent, etc. - .write(write_permission) - .create(create_permission) - .append(append_permission) - .truncate(truncate_permission); - open_flags |= Fd::READ; - if adjusted_rights.contains(Rights::FD_WRITE) { + .write(minimum_rights.write) + .create(minimum_rights.create) + .append(minimum_rights.append) + .truncate(minimum_rights.truncate); + + if minimum_rights.read { + open_flags |= Fd::READ; + } + if minimum_rights.write { open_flags |= Fd::WRITE; } - if o_flags.contains(Oflags::CREATE) { + if minimum_rights.create { open_flags |= Fd::CREATE; } - if o_flags.contains(Oflags::TRUNC) { + if minimum_rights.truncate { open_flags |= Fd::TRUNCATE; } + *handle = Some(wasi_try!(open_options .open(&path) .map_err(fs_error_into_wasi_err))); @@ -2393,7 +2437,11 @@ pub fn path_open( new_path.push(&new_entity_name); new_path } - Kind::Root { .. } => return Errno::Access, + Kind::Root { .. } => { + let mut new_path = std::path::PathBuf::new(); + new_path.push(&new_entity_name); + new_path + } _ => return Errno::Inval, } }; @@ -2401,13 +2449,23 @@ pub fn path_open( // todo: extra check that opening with write access is okay let handle = { let open_options = open_options - .read(true) - .append(fs_flags.contains(Fdflags::APPEND)) - // TODO: ensure these rights are actually valid given parent, etc. - // write access is required for creating a file - .write(true) - .create_new(true); - open_flags |= Fd::READ | Fd::WRITE | Fd::CREATE | Fd::TRUNCATE; + .read(minimum_rights.read) + .append(minimum_rights.append) + .write(minimum_rights.write) + .create_new(minimum_rights.create_new); + + if minimum_rights.read { + open_flags |= Fd::READ; + } + if minimum_rights.write { + open_flags |= Fd::WRITE; + } + if minimum_rights.create_new { + open_flags |= Fd::CREATE; + } + if minimum_rights.truncate { + open_flags |= Fd::TRUNCATE; + } Some(wasi_try!(open_options.open(&new_file_host_path).map_err( |e| { diff --git a/tests/ignores.txt b/tests/ignores.txt index 19d28fbf16f..39978d01cd9 100644 --- a/tests/ignores.txt +++ b/tests/ignores.txt @@ -96,3 +96,36 @@ wasitests::unstable::host_fs::unix_open_special_files wasitests::snapshot1::host_fs::unix_open_special_files wasitests::unstable::mem_fs::unix_open_special_files wasitests::snapshot1::mem_fs::unix_open_special_files + +# These tests are all tests that are disabled for unstable + snapshot1, +# so they are also disabled for nightly +wasitests::nightly_2022_10_18::host_fs::close_preopen_fd +wasitests::nightly_2022_10_18::host_fs::create_dir +wasitests::nightly_2022_10_18::host_fs::envvar +wasitests::nightly_2022_10_18::host_fs::fd_allocate +wasitests::nightly_2022_10_18::host_fs::fd_close +wasitests::nightly_2022_10_18::host_fs::fd_pread +wasitests::nightly_2022_10_18::host_fs::fd_read +wasitests::nightly_2022_10_18::host_fs::fd_rename_path +wasitests::nightly_2022_10_18::host_fs::poll_oneoff +wasitests::nightly_2022_10_18::host_fs::readlink +wasitests::nightly_2022_10_18::host_fs::unix_open_special_files +wasitests::nightly_2022_10_18::host_fs::writing +wasitests::nightly_2022_10_18::mem_fs::close_preopen_fd +wasitests::nightly_2022_10_18::mem_fs::create_dir +wasitests::nightly_2022_10_18::mem_fs::envvar +wasitests::nightly_2022_10_18::mem_fs::fd_allocate +wasitests::nightly_2022_10_18::mem_fs::fd_close +wasitests::nightly_2022_10_18::mem_fs::fd_pread +wasitests::nightly_2022_10_18::mem_fs::fd_read +wasitests::nightly_2022_10_18::mem_fs::poll_oneoff +wasitests::nightly_2022_10_18::mem_fs::readlink +wasitests::nightly_2022_10_18::mem_fs::unix_open_special_files +wasitests::nightly_2022_10_18::mem_fs::writing + +# These tests are failing in CI for some reason, but didn't fail on older compiler versions +wasitests::nightly_2022_10_18::host_fs::path_symlink +wasitests::nightly_2022_10_18::mem_fs::path_symlink + +wasitests::nightly_2022_10_18::host_fs::fd_append +wasitests::nightly_2022_10_18::mem_fs::fd_append \ No newline at end of file diff --git a/tests/wasi-wast/src/main.rs b/tests/wasi-wast/src/main.rs index fabdf052478..7197e8ee75e 100644 --- a/tests/wasi-wast/src/main.rs +++ b/tests/wasi-wast/src/main.rs @@ -7,7 +7,9 @@ mod wasi_version; mod wasitests; pub use crate::set_up_toolchain::install_toolchains; -pub use crate::wasi_version::{WasiVersion, ALL_WASI_VERSIONS, LATEST_WASI_VERSION}; +pub use crate::wasi_version::{ + WasiVersion, ALL_WASI_VERSIONS, LATEST_WASI_VERSION, NIGHTLY_VERSION, +}; pub use crate::wasitests::{build, WasiOptions, WasiTest}; use gumdrop::Options; @@ -17,6 +19,8 @@ pub struct TestGenOptions { /// if you want to specify specific tests to generate #[options(free)] free: Vec, + /// Whether to use the current nightly instead of the latest snapshot0 compiler + nightly: bool, /// Whether or not to do operations for all versions of WASI or just the latest. all_versions: bool, /// Whether or not the Wasm will be generated. @@ -38,8 +42,11 @@ fn main() { let generate_all = opts.all_versions; let set_up_toolchain = opts.set_up_toolchain; let generate_wasm = opts.generate_wasm; + let nightly = opts.nightly; let wasi_versions = if generate_all { ALL_WASI_VERSIONS + } else if nightly { + NIGHTLY_VERSION } else { LATEST_WASI_VERSION }; diff --git a/tests/wasi-wast/src/wasi_version.rs b/tests/wasi-wast/src/wasi_version.rs index 88dd4c61b20..3955640aae5 100644 --- a/tests/wasi-wast/src/wasi_version.rs +++ b/tests/wasi-wast/src/wasi_version.rs @@ -1,11 +1,16 @@ pub static ALL_WASI_VERSIONS: &[WasiVersion] = &[WasiVersion::Unstable, WasiVersion::Snapshot1]; pub static LATEST_WASI_VERSION: &[WasiVersion] = &[WasiVersion::get_latest()]; +pub static NIGHTLY_VERSION: &[WasiVersion] = &[WasiVersion::current_nightly()]; #[derive(Debug, Clone, Copy)] pub enum WasiVersion { /// A.K.A. Snapshot0 Unstable, Snapshot1, + /// This is for making tests pass on Apple M1 while + /// still keeping the old test for compatibility reasons + #[allow(non_camel_case_types)] + Nightly_2022_10_18, } impl WasiVersion { @@ -13,10 +18,15 @@ impl WasiVersion { Self::Snapshot1 } + pub const fn current_nightly() -> Self { + Self::Nightly_2022_10_18 + } + pub fn get_compiler_toolchain(&self) -> &'static str { match self { WasiVersion::Unstable => "nightly-2019-09-13", WasiVersion::Snapshot1 => "1.53.0", + WasiVersion::Nightly_2022_10_18 => "nightly-2022-10-18", } } @@ -24,6 +34,7 @@ impl WasiVersion { match self { WasiVersion::Unstable => "unstable", WasiVersion::Snapshot1 => "snapshot1", + WasiVersion::Nightly_2022_10_18 => "nightly_2022_10_18", } } } diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/close_preopen_fd.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/close_preopen_fd.wasm new file mode 100755 index 00000000000..15922f84592 Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/close_preopen_fd.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/close_preopen_fd.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/close_preopen_fd.wast new file mode 100644 index 00000000000..65dda3b05c2 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/close_preopen_fd.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "close_preopen_fd.wasm" + (map_dirs "hamlet:test_fs/hamlet") + (assert_return (i64.const 0)) + (assert_stdout "accessing preopen fd was a success\nClosing preopen fd was a success\naccessing closed preopen fd was an EBADF error: true\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/create_dir.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/create_dir.wasm new file mode 100755 index 00000000000..8ddd6f89e5e Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/create_dir.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/create_dir.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/create_dir.wast new file mode 100644 index 00000000000..772264013e6 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/create_dir.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "create_dir.wasm" + (preopens "test_fs") + (assert_return (i64.const 0)) + (assert_stdout "Test file exists: false\nDir exists: false\nDir exists: false\nDir exists: false\nSuccess\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/envvar.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/envvar.wasm new file mode 100755 index 00000000000..63535d1f76f Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/envvar.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/envvar.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/envvar.wast new file mode 100644 index 00000000000..fbfe0b61e09 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/envvar.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "envvar.wasm" + (envs "DOG=1" "CAT=2") + (assert_return (i64.const 0)) + (assert_stdout "Env vars:\nCAT=2\nDOG=1\nDOG Ok(\"1\")\nDOG_TYPE Err(NotPresent)\nSET VAR Ok(\"HELLO\")\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fd_allocate.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_allocate.wast new file mode 100644 index 00000000000..784294e1e8a --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_allocate.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "fd_allocate.wasm" + (temp_dirs ".") + (assert_return (i64.const 0)) + (assert_stdout "171\n1405\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fd_append.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_append.wasm new file mode 100755 index 00000000000..44783c9b95d Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_append.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fd_append.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_append.wast new file mode 100644 index 00000000000..c0063884a42 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_append.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "fd_append.wasm" + (temp_dirs ".") + (assert_return (i64.const 101)) + (assert_stderr "thread 'main' panicked at 'Couldn't create file: Os { code: 2, kind: NotFound, message: \"No such file or directory\" }', /Users/fs/Development/wasmer/tests/wasi-wast/wasi/tests/fd_append.rs:27:14\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fd_close.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_close.wast new file mode 100644 index 00000000000..82dc9d52145 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_close.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "fd_close.wasm" + (map_dirs ".:test_fs/hamlet") + (assert_return (i64.const 0)) + (assert_stdout "Successfully closed file!\nSuccessfully closed stderr!\nSuccessfully closed stdin!\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fd_pread.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_pread.wast new file mode 100644 index 00000000000..d320f87956d --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_pread.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "fd_pread.wasm" + (preopens "test_fs") + (assert_return (i64.const 0)) + (assert_stdout " POLONIUS\n\n He will come straight. Look you lay home to him:\n\n POLONIUS\n\n He will come straight. Look you lay home to him:\n\nRead the same data? true\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fd_read.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_read.wast new file mode 100644 index 00000000000..23bbb15c1c5 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_read.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "fd_read.wasm" + (map_dirs ".:test_fs/hamlet") + (assert_return (i64.const 0)) + (assert_stdout "SCENE IV. The Queen's closet.\n\n Enter QUEEN GERTRUDE and POLO\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fd_rename_path.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_rename_path.wasm new file mode 100755 index 00000000000..8d8bd808c2b Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_rename_path.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fd_rename_path.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_rename_path.wast new file mode 100644 index 00000000000..fd3e59714b3 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_rename_path.wast @@ -0,0 +1,6 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "fd_rename_path.wasm" + (preopens "test_fs") + (assert_return (i64.const 0)) +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fd_rights.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_rights.wasm new file mode 100755 index 00000000000..431cb187b6c Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_rights.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fd_rights.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_rights.wast new file mode 100644 index 00000000000..13bf6720b86 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_rights.wast @@ -0,0 +1,5 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "fd_rights.wasm" + (assert_return (i64.const 0)) +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fd_sync.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_sync.wasm new file mode 100755 index 00000000000..a455bd40234 Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_sync.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fd_sync.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_sync.wast new file mode 100644 index 00000000000..ad592f9b244 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/fd_sync.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "fd_sync.wasm" + (temp_dirs ".") + (assert_return (i64.const 0)) + (assert_stdout "170\n1404\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/file_metadata.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/file_metadata.wasm new file mode 100755 index 00000000000..3d257a53e0c Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/file_metadata.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/file_metadata.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/file_metadata.wast new file mode 100644 index 00000000000..7761ef199b1 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/file_metadata.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "file_metadata.wasm" + (preopens "test_fs") + (assert_return (i64.const 0)) + (assert_stdout "is dir: false\nfiletype: false true false\nfile info: 8866\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fs_sandbox_test.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/fs_sandbox_test.wasm new file mode 100755 index 00000000000..98ca61e0031 Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/fs_sandbox_test.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fs_sandbox_test.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/fs_sandbox_test.wast new file mode 100644 index 00000000000..4574470858e --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/fs_sandbox_test.wast @@ -0,0 +1,6 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "fs_sandbox_test.wasm" + (assert_return (i64.const 0)) + (assert_stdout "Reading the parent directory was okay? false\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fseek.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/fseek.wasm new file mode 100755 index 00000000000..c3c38454fb3 Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/fseek.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/fseek.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/fseek.wast new file mode 100644 index 00000000000..f9e9ba70a8a --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/fseek.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "fseek.wasm" + (map_dirs ".:test_fs/hamlet") + (assert_return (i64.const 0)) + (assert_stdout "SCENE III. A room in Polonius' h\nouse.\n\n Enter LAERTES and OPH\n And, sister, as the winds gi\nr talk with the Lord Hamlet.\n \nuits,\n Breathing like sanctif\nis is for all:\n I would not, \n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/hello.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/hello.wasm new file mode 100755 index 00000000000..5adae6c32ed Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/hello.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/hello.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/hello.wast new file mode 100644 index 00000000000..55885a887c7 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/hello.wast @@ -0,0 +1,6 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "hello.wasm" + (assert_return (i64.const 0)) + (assert_stdout "Hello, world!\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/isatty.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/isatty.wasm new file mode 100755 index 00000000000..1a7e49a944e Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/isatty.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/isatty.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/isatty.wast new file mode 100644 index 00000000000..c33255a1168 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/isatty.wast @@ -0,0 +1,6 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "isatty.wasm" + (assert_return (i64.const 0)) + (assert_stdout "stdin: 1\nstdout: 1\nstderr: 1\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/mapdir.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/mapdir.wasm new file mode 100755 index 00000000000..998d9b91b99 Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/mapdir.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/mapdir.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/mapdir.wast new file mode 100644 index 00000000000..4808a8e5e0d --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/mapdir.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "mapdir.wasm" + (map_dirs ".:test_fs/hamlet") + (assert_return (i64.const 0)) + (assert_stdout "\"./README.md\"\n\"./act1\"\n\"./act2\"\n\"./act3\"\n\"./act4\"\n\"./act5\"\n\"./bookmarks\"\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/mapdir_with_leading_slash.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/mapdir_with_leading_slash.wasm new file mode 100755 index 00000000000..12c45ceb6d1 Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/mapdir_with_leading_slash.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/mapdir_with_leading_slash.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/mapdir_with_leading_slash.wast new file mode 100644 index 00000000000..945e660f72c --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/mapdir_with_leading_slash.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "mapdir_with_leading_slash.wasm" + (map_dirs "/hamlet:test_fs/hamlet") + (assert_return (i64.const 0)) + (assert_stdout "File exists? true\nSCENE III. A room in the castle.\n\n Enter KING CLAUDIUS, ROSENCRANTZ, and GUILDENSTERN \n\nKING CLAUDIUS\n\n I like him not, nor stands it safe with us\n To let his madness range. Therefore prepare you;\n I your commission will forthwith dispatch,\n \n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/path_link.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/path_link.wasm new file mode 100755 index 00000000000..a2d2c479b14 Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/path_link.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/path_link.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/path_link.wast new file mode 100644 index 00000000000..6beca4e97e9 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/path_link.wast @@ -0,0 +1,8 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "path_link.wasm" + (map_dirs "act5:test_fs/hamlet/act5") + (temp_dirs "temp") + (assert_return (i64.const 0)) + (assert_stdout "ACT V\nSCENE I. A churchyard.\n\n Enter two Clowns, with spades,\nACT V\nSCENE I. A churchyard.\n\n Enter two Clowns, with spades,\nPath still exists\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/path_rename.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/path_rename.wasm new file mode 100755 index 00000000000..51baba029d2 Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/path_rename.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/path_rename.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/path_rename.wast new file mode 100644 index 00000000000..6177dda4921 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/path_rename.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "path_rename.wasm" + (temp_dirs "temp") + (assert_return (i64.const 0)) + (assert_stdout "The original file does not still exist!\nFound item: path_renamed_file.txt\n柴犬\nThe original file does not still exist!\nFound item: path_renamed_file.txt\n柴犬\nrun_with_sub_dir: The original file does not still exist!\nrun_with_different_sub_dirs: The original file does not still exist!\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/path_symlink.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/path_symlink.wasm new file mode 100755 index 00000000000..131d8821730 Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/path_symlink.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/path_symlink.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/path_symlink.wast new file mode 100644 index 00000000000..111f88dcc54 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/path_symlink.wast @@ -0,0 +1,8 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "path_symlink.wasm" + (map_dirs "hamlet:test_fs/hamlet") + (temp_dirs "temp") + (assert_return (i64.const 101)) + (assert_stderr "thread 'main' panicked at 'Could not open file: Os { code: 2, kind: NotFound, message: \"No such file or directory\" }', /Users/fs/Development/wasmer/tests/wasi-wast/wasi/tests/path_symlink.rs:21:44\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/pipe_reverse.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/pipe_reverse.wasm new file mode 100755 index 00000000000..213ef60c4f9 Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/pipe_reverse.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/pipe_reverse.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/pipe_reverse.wast new file mode 100644 index 00000000000..efaa1ab291a --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/pipe_reverse.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "pipe_reverse.wasm" + (assert_return (i64.const 0)) + (stdin "Hello, world!") + (assert_stdout "!dlrow ,olleH\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/poll_oneoff.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/poll_oneoff.wast new file mode 100644 index 00000000000..377ad038147 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/poll_oneoff.wast @@ -0,0 +1,8 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "poll_oneoff.wasm" + (map_dirs "hamlet:test_fs/hamlet") + (temp_dirs "temp") + (assert_return (i64.const 101)) + (assert_stderr "thread 'main' panicked at 'Could not open file: Os { code: 2, kind: NotFound, message: \"No such file or directory\" }', /Users/fs/Development/wasmer/tests/wasi-wast/wasi/tests/poll_oneoff.rs:155:14\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/quine.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/quine.wasm new file mode 100755 index 00000000000..33cd3854a26 Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/quine.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/quine.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/quine.wast new file mode 100644 index 00000000000..c45d16b6688 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/quine.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "quine.wasm" + (preopens "test_fs") + (assert_return (i64.const 0)) + (assert_stdout "SCENE II. A room of state in the castle.\n\n Enter KING CLAUDIUS, QUEEN GERTRUDE, HAMLET, POLONIUS, LAERTES, VOLTIMAND, CORNELIUS, Lords, and Attendants \n\nKING CLAUDIUS\n\n Though yet of Hamlet our dear brother's death\n The memory be green, and that it us befitted\n To bear our hearts in grief and our whole kingdom\n To be contracted in one brow of woe,\n Yet so far hath discretion fought with nature\n That we with wisest sorrow think on him,\n Together with remembrance of ourselves.\n Therefore our sometime sister, now our queen,\n The imperial jointress to this warlike state,\n Have we, as 'twere with a defeated joy,--\n With an auspicious and a dropping eye,\n With mirth in funeral and with dirge in marriage,\n In equal scale weighing delight and dole,--\n Taken to wife: nor have we herein barr'd\n Your better wisdoms, which have freely gone\n With this affair along. For all, our thanks.\n Now follows, that you know, young Fortinbras,\n Holding a weak supposal of our worth,\n Or thinking by our late dear brother's death\n Our state to be disjoint and out of frame,\n Colleagued with the dream of his advantage,\n He hath not fail'd to pester us with message,\n Importing the surrender of those lands\n Lost by his father, with all bonds of law,\n To our most valiant brother. So much for him.\n Now for ourself and for this time of meeting:\n Thus much the business is: we have here writ\n To Norway, uncle of young Fortinbras,--\n Who, impotent and bed-rid, scarcely hears\n Of this his nephew's purpose,--to suppress\n His further gait herein; in that the levies,\n The lists and full proportions, are all made\n Out of his subject: and we here dispatch\n You, good Cornelius, and you, Voltimand,\n For bearers of this greeting to old Norway;\n Giving to you no further personal power\n To business with the king, more than the scope\n Of these delated articles allow.\n Farewell, and let your haste commend your duty.\n\nCORNELIUS VOLTIMAND\n\n In that and all things will we show our duty.\n\nKING CLAUDIUS\n\n We doubt it nothing: heartily farewell.\n\n Exeunt VOLTIMAND and CORNELIUS\n And now, Laertes, what's the news with you?\n You told us of some suit; what is't, Laertes?\n You cannot speak of reason to the Dane,\n And loose your voice: what wouldst thou beg, Laertes,\n That shall not be my offer, not thy asking?\n The head is not more native to the heart,\n The hand more instrumental to the mouth,\n Than is the throne of Denmark to thy father.\n What wouldst thou have, Laertes?\n\nLAERTES\n\n My dread lord,\n Your leave and favour to return to France;\n From whence though willingly I came to Denmark,\n To show my duty in your coronation,\n Yet now, I must confess, that duty done,\n My thoughts and wishes bend again toward France\n And bow them to your gracious leave and pardon.\n\nKING CLAUDIUS\n\n Have you your father's leave? What says Polonius?\n\nLORD POLONIUS\n\n He hath, my lord, wrung from me my slow leave\n By laboursome petition, and at last\n Upon his will I seal'd my hard consent:\n I do beseech you, give him leave to go.\n\nKING CLAUDIUS\n\n Take thy fair hour, Laertes; time be thine,\n And thy best graces spend it at thy will!\n But now, my cousin Hamlet, and my son,--\n\nHAMLET\n\n [Aside] A little more than kin, and less than kind.\n\nKING CLAUDIUS\n\n How is it that the clouds still hang on you?\n\nHAMLET\n\n Not so, my lord; I am too much i' the sun.\n\nQUEEN GERTRUDE\n\n Good Hamlet, cast thy nighted colour off,\n And let thine eye look like a friend on Denmark.\n Do not for ever with thy vailed lids\n Seek for thy noble father in the dust:\n Thou know'st 'tis common; all that lives must die,\n Passing through nature to eternity.\n\nHAMLET\n\n Ay, madam, it is common.\n\nQUEEN GERTRUDE\n\n If it be,\n Why seems it so particular with thee?\n\nHAMLET\n\n Seems, madam! nay it is; I know not 'seems.'\n 'Tis not alone my inky cloak, good mother,\n Nor customary suits of solemn black,\n Nor windy suspiration of forced breath,\n No, nor the fruitful river in the eye,\n Nor the dejected 'havior of the visage,\n Together with all forms, moods, shapes of grief,\n That can denote me truly: these indeed seem,\n For they are actions that a man might play:\n But I have that within which passeth show;\n These but the trappings and the suits of woe.\n\nKING CLAUDIUS\n\n 'Tis sweet and commendable in your nature, Hamlet,\n To give these mourning duties to your father:\n But, you must know, your father lost a father;\n That father lost, lost his, and the survivor bound\n In filial obligation for some term\n To do obsequious sorrow: but to persever\n In obstinate condolement is a course\n Of impious stubbornness; 'tis unmanly grief;\n It shows a will most incorrect to heaven,\n A heart unfortified, a mind impatient,\n An understanding simple and unschool'd:\n For what we know must be and is as common\n As any the most vulgar thing to sense,\n Why should we in our peevish opposition\n Take it to heart? Fie! 'tis a fault to heaven,\n A fault against the dead, a fault to nature,\n To reason most absurd: whose common theme\n Is death of fathers, and who still hath cried,\n From the first corse till he that died to-day,\n 'This must be so.' We pray you, throw to earth\n This unprevailing woe, and think of us\n As of a father: for let the world take note,\n You are the most immediate to our throne;\n And with no less nobility of love\n Than that which dearest father bears his son,\n Do I impart toward you. For your intent\n In going back to school in Wittenberg,\n It is most retrograde to our desire:\n And we beseech you, bend you to remain\n Here, in the cheer and comfort of our eye,\n Our chiefest courtier, cousin, and our son.\n\nQUEEN GERTRUDE\n\n Let not thy mother lose her prayers, Hamlet:\n I pray thee, stay with us; go not to Wittenberg.\n\nHAMLET\n\n I shall in all my best obey you, madam.\n\nKING CLAUDIUS\n\n Why, 'tis a loving and a fair reply:\n Be as ourself in Denmark. Madam, come;\n This gentle and unforced accord of Hamlet\n Sits smiling to my heart: in grace whereof,\n No jocund health that Denmark drinks to-day,\n But the great cannon to the clouds shall tell,\n And the king's rouse the heavens all bruit again,\n Re-speaking earthly thunder. Come away.\n\n Exeunt all but HAMLET\n\nHAMLET\n\n O, that this too too solid flesh would melt\n Thaw and resolve itself into a dew!\n Or that the Everlasting had not fix'd\n His canon 'gainst self-slaughter! O God! God!\n How weary, stale, flat and unprofitable,\n Seem to me all the uses of this world!\n Fie on't! ah fie! 'tis an unweeded garden,\n That grows to seed; things rank and gross in nature\n Possess it merely. That it should come to this!\n But two months dead: nay, not so much, not two:\n So excellent a king; that was, to this,\n Hyperion to a satyr; so loving to my mother\n That he might not beteem the winds of heaven\n Visit her face too roughly. Heaven and earth!\n Must I remember? why, she would hang on him,\n As if increase of appetite had grown\n By what it fed on: and yet, within a month--\n Let me not think on't--Frailty, thy name is woman!--\n A little month, or ere those shoes were old\n With which she follow'd my poor father's body,\n Like Niobe, all tears:--why she, even she--\n O, God! a beast, that wants discourse of reason,\n Would have mourn'd longer--married with my uncle,\n My father's brother, but no more like my father\n Than I to Hercules: within a month:\n Ere yet the salt of most unrighteous tears\n Had left the flushing in her galled eyes,\n She married. O, most wicked speed, to post\n With such dexterity to incestuous sheets!\n It is not nor it cannot come to good:\n But break, my heart; for I must hold my tongue.\n\n Enter HORATIO, MARCELLUS, and BERNARDO\n\nHORATIO\n\n Hail to your lordship!\n\nHAMLET\n\n I am glad to see you well:\n Horatio,--or I do forget myself.\n\nHORATIO\n\n The same, my lord, and your poor servant ever.\n\nHAMLET\n\n Sir, my good friend; I'll change that name with you:\n And what make you from Wittenberg, Horatio? Marcellus?\n\nMARCELLUS\n\n My good lord--\n\nHAMLET\n\n I am very glad to see you. Good even, sir.\n But what, in faith, make you from Wittenberg?\n\nHORATIO\n\n A truant disposition, good my lord.\n\nHAMLET\n\n I would not hear your enemy say so,\n Nor shall you do mine ear that violence,\n To make it truster of your own report\n Against yourself: I know you are no truant.\n But what is your affair in Elsinore?\n We'll teach you to drink deep ere you depart.\n\nHORATIO\n\n My lord, I came to see your father's funeral.\n\nHAMLET\n\n I pray thee, do not mock me, fellow-student;\n I think it was to see my mother's wedding.\n\nHORATIO\n\n Indeed, my lord, it follow'd hard upon.\n\nHAMLET\n\n Thrift, thrift, Horatio! the funeral baked meats\n Did coldly furnish forth the marriage tables.\n Would I had met my dearest foe in heaven\n Or ever I had seen that day, Horatio!\n My father!--methinks I see my father.\n\nHORATIO\n\n Where, my lord?\n\nHAMLET\n\n In my mind's eye, Horatio.\n\nHORATIO\n\n I saw him once; he was a goodly king.\n\nHAMLET\n\n He was a man, take him for all in all,\n I shall not look upon his like again.\n\nHORATIO\n\n My lord, I think I saw him yesternight.\n\nHAMLET\n\n Saw? who?\n\nHORATIO\n\n My lord, the king your father.\n\nHAMLET\n\n The king my father!\n\nHORATIO\n\n Season your admiration for awhile\n With an attent ear, till I may deliver,\n Upon the witness of these gentlemen,\n This marvel to you.\n\nHAMLET\n\n For God's love, let me hear.\n\nHORATIO\n\n Two nights together had these gentlemen,\n Marcellus and Bernardo, on their watch,\n In the dead vast and middle of the night,\n Been thus encounter'd. A figure like your father,\n Armed at point exactly, cap-a-pe,\n Appears before them, and with solemn march\n Goes slow and stately by them: thrice he walk'd\n By their oppress'd and fear-surprised eyes,\n Within his truncheon's length; whilst they, distilled\n Almost to jelly with the act of fear,\n Stand dumb and speak not to him. This to me\n In dreadful secrecy impart they did;\n And I with them the third night kept the watch;\n Where, as they had deliver'd, both in time,\n Form of the thing, each word made true and good,\n The apparition comes: I knew your father;\n These hands are not more like.\n\nHAMLET\n\n But where was this?\n\nMARCELLUS\n\n My lord, upon the platform where we watch'd.\n\nHAMLET\n\n Did you not speak to it?\n\nHORATIO\n\n My lord, I did;\n But answer made it none: yet once methought\n It lifted up its head and did address\n Itself to motion, like as it would speak;\n But even then the morning cock crew loud,\n And at the sound it shrunk in haste away,\n And vanish'd from our sight.\n\nHAMLET\n\n 'Tis very strange.\n\nHORATIO\n\n As I do live, my honour'd lord, 'tis true;\n And we did think it writ down in our duty\n To let you know of it.\n\nHAMLET\n\n Indeed, indeed, sirs, but this troubles me.\n Hold you the watch to-night?\n\nMARCELLUS BERNARDO\n\n We do, my lord.\n\nHAMLET\n\n Arm'd, say you?\n\nMARCELLUS BERNARDO\n\n Arm'd, my lord.\n\nHAMLET\n\n From top to toe?\n\nMARCELLUS BERNARDO\n\n My lord, from head to foot.\n\nHAMLET\n\n Then saw you not his face?\n\nHORATIO\n\n O, yes, my lord; he wore his beaver up.\n\nHAMLET\n\n What, look'd he frowningly?\n\nHORATIO\n\n A countenance more in sorrow than in anger.\n\nHAMLET\n\n Pale or red?\n\nHORATIO\n\n Nay, very pale.\n\nHAMLET\n\n And fix'd his eyes upon you?\n\nHORATIO\n\n Most constantly.\n\nHAMLET\n\n I would I had been there.\n\nHORATIO\n\n It would have much amazed you.\n\nHAMLET\n\n Very like, very like. Stay'd it long?\n\nHORATIO\n\n While one with moderate haste might tell a hundred.\n\nMARCELLUS BERNARDO\n\n Longer, longer.\n\nHORATIO\n\n Not when I saw't.\n\nHAMLET\n\n His beard was grizzled--no?\n\nHORATIO\n\n It was, as I have seen it in his life,\n A sable silver'd.\n\nHAMLET\n\n I will watch to-night;\n Perchance 'twill walk again.\n\nHORATIO\n\n I warrant it will.\n\nHAMLET\n\n If it assume my noble father's person,\n I'll speak to it, though hell itself should gape\n And bid me hold my peace. I pray you all,\n If you have hitherto conceal'd this sight,\n Let it be tenable in your silence still;\n And whatsoever else shall hap to-night,\n Give it an understanding, but no tongue:\n I will requite your loves. So, fare you well:\n Upon the platform, 'twixt eleven and twelve,\n I'll visit you.\n\nAll\n\n Our duty to your honour.\n\nHAMLET\n\n Your loves, as mine to you: farewell.\n\n Exeunt all but HAMLET\n My father's spirit in arms! all is not well;\n I doubt some foul play: would the night were come!\n Till then sit still, my soul: foul deeds will rise,\n Though all the earth o'erwhelm them, to men's eyes.\n\n Exit\n\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/readlink.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/readlink.wasm new file mode 100755 index 00000000000..fbc408f4f1d Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/readlink.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/readlink.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/readlink.wast new file mode 100644 index 00000000000..6eb1ffc445b --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/readlink.wast @@ -0,0 +1,8 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "readlink.wasm" + (preopens "test_fs") + (assert_return (i64.const 0)) + (assert_stdout "true\n../act1/scene2.txt\nSCENE II. A room of state in the castle.\n\n Enter KING CLAUDIUS, QUEEN GERTRUDE, HAMLET, POLONIUS, LAERTES, VOLTIMAND, CORNELI\n") + (assert_stderr "[/Users/fs/Development/wasmer/tests/wasi-wast/wasi/tests/readlink.rs:10] &p = \"test_fs/hamlet/bookmarks/2019-07-16\"\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/unix_open_special_files.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/unix_open_special_files.wasm new file mode 100755 index 00000000000..785bf2d5f16 Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/unix_open_special_files.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/unix_open_special_files.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/unix_open_special_files.wast new file mode 100644 index 00000000000..7da0c830dad --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/unix_open_special_files.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "unix_open_special_files.wasm" + (map_dirs "/dev:/dev") + (assert_return (i64.const 0)) + (assert_stdout "13\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/wasi_sees_virtual_root.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/wasi_sees_virtual_root.wasm new file mode 100755 index 00000000000..6a7cab01328 Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/wasi_sees_virtual_root.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/wasi_sees_virtual_root.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/wasi_sees_virtual_root.wast new file mode 100644 index 00000000000..c60fa5fda26 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/wasi_sees_virtual_root.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "wasi_sees_virtual_root.wasm" + (map_dirs "act1:test_fs/hamlet/act1" "act2:test_fs/hamlet/act2" "act1-again:test_fs/hamlet/act1") + (assert_return (i64.const 0)) + (assert_stdout "\"/act1\"\n\"/act1-again\"\n\"/act2\"\n\"/act1\"\n\"/act1-again\"\n\"/act2\"\n\"/act1\"\n\"/act1-again\"\n\"/act2\"\n\"/act1\"\n\"/act1-again\"\n\"/act2\"\nROOT IS SAFE\n") +) diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/writing.wasm b/tests/wasi-wast/wasi/nightly_2022_10_18/writing.wasm new file mode 100755 index 00000000000..b8596fbf46e Binary files /dev/null and b/tests/wasi-wast/wasi/nightly_2022_10_18/writing.wasm differ diff --git a/tests/wasi-wast/wasi/nightly_2022_10_18/writing.wast b/tests/wasi-wast/wasi/nightly_2022_10_18/writing.wast new file mode 100644 index 00000000000..3835a25f631 --- /dev/null +++ b/tests/wasi-wast/wasi/nightly_2022_10_18/writing.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "writing.wasm" + (map_dirs "act1:test_fs/hamlet/act1" "act2:test_fs/hamlet/act2" "act1-again:test_fs/hamlet/act1") + (assert_return (i64.const 0)) + (assert_stdout "abcdefghijklmnopqrstuvwxyz\nfile is gone\n") +) diff --git a/tests/wasi-wast/wasi/tests/fd_rights.rs b/tests/wasi-wast/wasi/tests/fd_rights.rs new file mode 100644 index 00000000000..a11194b61f3 --- /dev/null +++ b/tests/wasi-wast/wasi/tests/fd_rights.rs @@ -0,0 +1,14 @@ +use std::io::{Read, Write}; + +fn main() { + let mut filehandle = std::fs::OpenOptions::new() + .read(false) // <- should only be writeable, not readable + .write(true) + .create(true) + .open("foo.txt") + .unwrap(); + filehandle.write_all(b"test"); + + let mut contents = String::new(); + assert!(filehandle.read_to_string(&mut contents).is_err()); +}