Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(wasi): Move capabilities into root submodule #3666

Merged
merged 2 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/wasi/src/http/client_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::string::FromUtf8Error;
use std::sync::Arc;

use crate::bindings::wasix_http_client_v1 as sys;
use crate::{Capabilities, WasiRuntime};
use crate::{capabilities::Capabilities, WasiRuntime};

use crate::{
http::{DynHttpClient, HttpClientCapabilityV1},
Expand Down
4 changes: 3 additions & 1 deletion lib/wasi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ mod syscalls;
mod utils;
pub mod wapm;

pub mod capabilities;

/// WAI based bindings.
mod bindings;

Expand Down Expand Up @@ -106,7 +108,7 @@ pub use crate::utils::is_wasix_module;

pub use crate::{
state::{
Capabilities, WasiEnv, WasiEnvBuilder, WasiEnvInit, WasiFunctionEnv, WasiInstanceHandles,
WasiEnv, WasiEnvBuilder, WasiEnvInit, WasiFunctionEnv, WasiInstanceHandles,
WasiStateCreationError, ALL_RIGHTS,
},
syscalls::types,
Expand Down
2 changes: 1 addition & 1 deletion lib/wasi/src/os/console/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ use wasmer_wasi_types::{types::__WASI_STDIN_FILENO, wasi::BusErrno};
use super::{cconst::ConsoleConst, common::*, task::TaskJoinHandle};
use crate::{
bin_factory::{spawn_exec, BinFactory, ModuleCache},
capabilities::Capabilities,
os::task::{control_plane::WasiControlPlane, process::WasiProcess},
state::Capabilities,
VirtualBusError, VirtualTaskManagerExt, WasiEnv, WasiRuntime,
};

Expand Down
3 changes: 2 additions & 1 deletion lib/wasi/src/runners/wcgi/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ use wasmer_vfs::{FileSystem, PassthruFileSystem, RootFileSystemBuilder, TmpFileS
use wcgi_host::CgiDialect;

use crate::{
capabilities::Capabilities,
http::HttpClientCapabilityV1,
runners::wcgi::{Callbacks, MappedDirectory},
Capabilities, Pipe, PluggableRuntimeImplementation, VirtualTaskManager, WasiEnv,
Pipe, PluggableRuntimeImplementation, VirtualTaskManager, WasiEnv,
};

/// The shared object that manages the instantiaion of WASI executables and
Expand Down
4 changes: 2 additions & 2 deletions lib/wasi/src/state/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ use wasmer_vfs::{ArcFile, FsError, TmpFileSystem, VirtualFile};

use crate::{
bin_factory::{BinFactory, ModuleCache},
capabilities::Capabilities,
fs::{WasiFs, WasiFsRoot, WasiInodes},
os::task::control_plane::{ControlPlaneConfig, ControlPlaneError, WasiControlPlane},
state::WasiState,
syscalls::types::{__WASI_STDERR_FILENO, __WASI_STDIN_FILENO, __WASI_STDOUT_FILENO},
Capabilities, PluggableRuntimeImplementation, WasiEnv, WasiFunctionEnv, WasiRuntime,
WasiRuntimeError,
PluggableRuntimeImplementation, WasiEnv, WasiFunctionEnv, WasiRuntime, WasiRuntimeError,
};

use super::env::WasiEnvInit;
Expand Down
3 changes: 2 additions & 1 deletion lib/wasi/src/state/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use wasmer_wasi_types::{

use crate::{
bin_factory::{BinFactory, ModuleCache},
capabilities::Capabilities,
fs::{WasiFsRoot, WasiInodes},
import_object_for_all_wasi_versions,
os::{
Expand All @@ -35,7 +36,7 @@ use crate::{
DEFAULT_STACK_SIZE,
};

use super::{Capabilities, WasiState};
use super::WasiState;

/// Various [`TypedFunction`] and [`Global`] handles for an active WASI(X) instance.
///
Expand Down
2 changes: 0 additions & 2 deletions lib/wasi/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#![allow(clippy::cognitive_complexity, clippy::too_many_arguments)]

mod builder;
mod capabilities;
mod env;
mod func_env;
mod types;
Expand All @@ -39,7 +38,6 @@ use wasmer_wasi_types::wasi::{Errno, Fd as WasiFd, Rights, Snapshot0Clockid};

pub use self::{
builder::*,
capabilities::Capabilities,
env::{WasiEnv, WasiEnvInit, WasiInstanceHandles},
func_env::WasiFunctionEnv,
types::*,
Expand Down
34 changes: 18 additions & 16 deletions tests/integration/cli/tests/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,17 @@ fn test_snapshot_cowsay() {
// assert_json_snapshot!(snapshot);
// }

// FIXME: re-enable, disabled due to flakyness
// The ability to fork the current process and run a different image but retain
// the existing open file handles (which is needed for stdin and stdout redirection)
#[cfg(not(target_os = "windows"))]
#[test]
fn test_snapshot_fork_and_exec() {
let snapshot = TestBuilder::new()
.use_coreutils()
.run_wasm(include_bytes!("./wasm/example-execve.wasm"));
assert_json_snapshot!(snapshot);
}
// #[cfg(not(target_os = "windows"))]
// #[test]
// fn test_snapshot_fork_and_exec() {
// let snapshot = TestBuilder::new()
// .use_coreutils()
// .run_wasm(include_bytes!("./wasm/example-execve.wasm"));
// assert_json_snapshot!(snapshot);
// }

// longjmp is used by C programs that save and restore the stack at specific
// points - this functionality is often used for exception handling
Expand Down Expand Up @@ -379,15 +380,16 @@ fn test_snapshot_sleep() {
assert_json_snapshot!(snapshot);
}

// FIXME: re-enable, disabled due to flakyness
// Uses `posix_spawn` to launch a sub-process and wait on it to exit
#[cfg(not(target_os = "windows"))]
#[test]
fn test_snapshot_process_spawn() {
let snapshot = TestBuilder::new()
.use_coreutils()
.run_wasm(include_bytes!("./wasm/example-spawn.wasm"));
assert_json_snapshot!(snapshot);
}
// #[cfg(not(target_os = "windows"))]
// #[test]
// fn test_snapshot_process_spawn() {
// let snapshot = TestBuilder::new()
// .use_coreutils()
// .run_wasm(include_bytes!("./wasm/example-spawn.wasm"));
// assert_json_snapshot!(snapshot);
// }

// FIXME: re-enable - hangs on windows and macos
// Connects to 8.8.8.8:53 over TCP to verify TCP clients work
Expand Down