test-programs: use wasi-c2 instead of wasmtime
This commit is contained in:
16
Cargo.lock
generated
16
Cargo.lock
generated
@@ -2140,9 +2140,9 @@ dependencies = [
|
|||||||
"pretty_env_logger",
|
"pretty_env_logger",
|
||||||
"target-lexicon",
|
"target-lexicon",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"wasi-common",
|
"wasi-c2",
|
||||||
|
"wasi-c2-wasmtime",
|
||||||
"wasmtime",
|
"wasmtime",
|
||||||
"wasmtime-wasi",
|
|
||||||
"wat",
|
"wat",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2389,6 +2389,18 @@ dependencies = [
|
|||||||
"wiggle",
|
"wiggle",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi-c2-wasmtime"
|
||||||
|
version = "0.21.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"cap-std",
|
||||||
|
"wasi-c2",
|
||||||
|
"wasmtime",
|
||||||
|
"wasmtime-wiggle",
|
||||||
|
"wiggle",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi-common"
|
name = "wasi-common"
|
||||||
version = "0.21.0"
|
version = "0.21.0"
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ members = [
|
|||||||
"crates/wiggle",
|
"crates/wiggle",
|
||||||
"crates/wiggle/wasmtime",
|
"crates/wiggle/wasmtime",
|
||||||
"crates/wasi-c2",
|
"crates/wasi-c2",
|
||||||
|
"crates/wasi-c2/wasmtime",
|
||||||
"examples/fib-debug/wasm",
|
"examples/fib-debug/wasm",
|
||||||
"examples/wasi/wasm",
|
"examples/wasi/wasm",
|
||||||
"examples/wasi-fs/wasm",
|
"examples/wasi-fs/wasm",
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ publish = false
|
|||||||
cfg-if = "1.0"
|
cfg-if = "1.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
wasi-common = { path = "../wasi-common", version = "0.21.0" }
|
wasi-c2 = { path = "../wasi-c2", version = "0.21.0" }
|
||||||
wasmtime-wasi = { path = "../wasi", version = "0.21.0" }
|
wasi-c2-wasmtime = { path = "../wasi-c2/wasmtime", version = "0.21.0" }
|
||||||
wasmtime = { path = "../wasmtime", version = "0.21.0" }
|
wasmtime = { path = "../wasmtime", version = "0.21.0" }
|
||||||
target-lexicon = "0.11.0"
|
target-lexicon = "0.11.0"
|
||||||
pretty_env_logger = "0.4.0"
|
pretty_env_logger = "0.4.0"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use anyhow::Context;
|
|||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use wasi_common::{OsOther, VirtualDirEntry};
|
use wasi_c2::WasiCtx;
|
||||||
use wasmtime::{Linker, Module, Store};
|
use wasmtime::{Linker, Module, Store};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
@@ -23,34 +23,37 @@ pub fn instantiate(
|
|||||||
|
|
||||||
// Create our wasi context with pretty standard arguments/inheritance/etc.
|
// Create our wasi context with pretty standard arguments/inheritance/etc.
|
||||||
// Additionally register any preopened directories if we have them.
|
// Additionally register any preopened directories if we have them.
|
||||||
let mut builder = wasi_common::WasiCtxBuilder::new();
|
let mut builder = wasi_c2::WasiCtx::builder();
|
||||||
|
|
||||||
builder.arg(bin_name).arg(".").inherit_stdio();
|
builder.arg(bin_name).arg(".").inherit_stdio();
|
||||||
|
|
||||||
if let Some(workspace) = workspace {
|
/*
|
||||||
match preopen_type {
|
if let Some(workspace) = workspace {
|
||||||
PreopenType::OS => {
|
match preopen_type {
|
||||||
let preopen_dir = wasi_common::preopen_dir(workspace)
|
PreopenType::OS => {
|
||||||
.context(format!("error while preopening {:?}", workspace))?;
|
let preopen_dir = wasi_common::preopen_dir(workspace)
|
||||||
builder.preopened_dir(preopen_dir, ".");
|
.context(format!("error while preopening {:?}", workspace))?;
|
||||||
}
|
builder.preopened_dir(preopen_dir, ".");
|
||||||
PreopenType::Virtual => {
|
}
|
||||||
// we can ignore the workspace path for virtual preopens because virtual preopens
|
PreopenType::Virtual => {
|
||||||
// don't exist in the filesystem anyway - no name conflict concerns.
|
// we can ignore the workspace path for virtual preopens because virtual preopens
|
||||||
builder.preopened_virt(VirtualDirEntry::empty_directory(), ".");
|
// don't exist in the filesystem anyway - no name conflict concerns.
|
||||||
|
builder.preopened_virt(VirtualDirEntry::empty_directory(), ".");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
*/
|
||||||
|
/*
|
||||||
// The nonstandard thing we do with `WasiCtxBuilder` is to ensure that
|
// The nonstandard thing we do with `WasiCtxBuilder` is to ensure that
|
||||||
// `stdin` is always an unreadable pipe. This is expected in the test suite
|
// `stdin` is always an unreadable pipe. This is expected in the test suite
|
||||||
// where `stdin` is never ready to be read. In some CI systems, however,
|
// where `stdin` is never ready to be read. In some CI systems, however,
|
||||||
// stdin is closed which causes tests to fail.
|
// stdin is closed which causes tests to fail.
|
||||||
let (reader, _writer) = os_pipe::pipe()?;
|
let (reader, _writer) = os_pipe::pipe()?;
|
||||||
let file = reader_to_file(reader);
|
let file = reader_to_file(reader);
|
||||||
let handle = OsOther::try_from(file).context("failed to create OsOther from PipeReader")?;
|
let handle = OsOther::try_from(file).context("failed to create OsOther from PipeReader")?;
|
||||||
builder.stdin(handle);
|
builder.stdin(handle);
|
||||||
let snapshot1 = wasmtime_wasi::Wasi::new(&store, builder.build()?);
|
*/
|
||||||
|
let snapshot1 = wasi_c2_wasmtime::Wasi::new(&store, builder.build()?);
|
||||||
|
|
||||||
let mut linker = Linker::new(&store);
|
let mut linker = Linker::new(&store);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user