mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 06:15:33 +00:00
Merge branch 'master' into feature/map-dir
This commit is contained in:
commit
97a2237255
@ -6,6 +6,7 @@ branches:
|
||||
only:
|
||||
- staging
|
||||
- trying
|
||||
- master
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
@ -17,6 +18,7 @@ environment:
|
||||
cache:
|
||||
- 'C:\Users\appveyor\.cargo'
|
||||
- target
|
||||
- wapm-cli-target
|
||||
|
||||
install:
|
||||
# # Install LLVM
|
||||
@ -47,7 +49,21 @@ install:
|
||||
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
|
||||
build_script:
|
||||
- cargo build --release --verbose
|
||||
- cargo build --release --verbose
|
||||
# Now we build wapm
|
||||
- git submodule init
|
||||
- git submodule update
|
||||
# Cache wapm cli target in dir above to prevent breaking git submodule on windows
|
||||
- if not exist wapm-cli-target mkdir wapm-cli-target
|
||||
- move wapm-cli-target wapm-cli
|
||||
- cd wapm-cli
|
||||
- rename wapm-cli-target target
|
||||
- cd ..
|
||||
- cargo build --release --manifest-path wapm-cli/Cargo.toml --features telemetry
|
||||
- cd wapm-cli
|
||||
- rename target wapm-cli-target
|
||||
- cd ..
|
||||
- move wapm-cli\wapm-cli-target wapm-cli-target
|
||||
|
||||
test_script:
|
||||
- cargo test --manifest-path lib/spectests/Cargo.toml --features clif
|
||||
@ -66,7 +82,7 @@ deploy:
|
||||
description: 'WasmerInstaller'
|
||||
artifact: /.*\.exe/
|
||||
auth_token:
|
||||
secure: CaKtncy7S1PWxzDUQ0p2264pe3HwxzDn5VIyRizDaa72/SVfskNcoMjwwRh0ut22
|
||||
secure: BbreGNDJy20922za7OhJG5TERzfX+dJSBQwttNTJkLvszbqMov6hhAtRb3P45hpf
|
||||
provider: GitHub
|
||||
on:
|
||||
branch: master
|
||||
|
@ -220,7 +220,7 @@ jobs:
|
||||
name: "Pull dependencies"
|
||||
command: |
|
||||
git submodule init
|
||||
git submodule update --remote
|
||||
git submodule update
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v8-cargo-cache-darwin-nightly-{{ arch }}-{{ checksum "Cargo.lock" }}
|
||||
@ -314,13 +314,15 @@ jobs:
|
||||
tar xf clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz
|
||||
rustup toolchain install nightly
|
||||
rustup target add wasm32-wasi --toolchain nightly
|
||||
- run: |
|
||||
rustup default nightly
|
||||
make test-wasi-singlepass
|
||||
make test-wasi-clif
|
||||
- run: rustup default nightly-2019-04-11
|
||||
- run: |
|
||||
export LLVM_SYS_70_PREFIX="`pwd`/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/"
|
||||
make test
|
||||
make test-singlepass
|
||||
make test-wasi-singlepass
|
||||
make test-wasi-clif
|
||||
make test-emscripten-clif
|
||||
make test-emscripten-singlepass
|
||||
- save_cache:
|
||||
|
@ -10,6 +10,7 @@ Blocks of changes will separated by version increments.
|
||||
|
||||
## 0.4.2 - 2019-05-16
|
||||
|
||||
- [#457](https://github.com/wasmerio/wasmer/pull/457) Implement file metadata for WASI, fix bugs in WASI clock code for Unix platforms
|
||||
- [#416](https://github.com/wasmerio/wasmer/pull/416) Remote code loading framework
|
||||
- [#449](https://github.com/wasmerio/wasmer/pull/449) Fix bugs: opening host files in filestat and opening with write permissions unconditionally in path_open
|
||||
- [#442](https://github.com/wasmerio/wasmer/pull/442) Misc. WASI FS fixes and implement readdir
|
||||
|
@ -487,3 +487,64 @@ pub fn host_file_type_to_wasi_file_type(file_type: fs::FileType) -> __wasi_filet
|
||||
__WASI_FILETYPE_UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_stat_for_kind(kind: &Kind) -> Option<__wasi_filestat_t> {
|
||||
match kind {
|
||||
Kind::File { handle } => match handle {
|
||||
WasiFile::HostFile(hf) => {
|
||||
let md = hf.metadata().ok()?;
|
||||
|
||||
Some(__wasi_filestat_t {
|
||||
st_filetype: host_file_type_to_wasi_file_type(md.file_type()),
|
||||
st_size: md.len(),
|
||||
st_atim: md
|
||||
.accessed()
|
||||
.ok()?
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.ok()?
|
||||
.as_nanos() as u64,
|
||||
st_mtim: md
|
||||
.modified()
|
||||
.ok()?
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.ok()?
|
||||
.as_nanos() as u64,
|
||||
st_ctim: md
|
||||
.created()
|
||||
.ok()
|
||||
.and_then(|ct| ct.duration_since(SystemTime::UNIX_EPOCH).ok())
|
||||
.map(|ct| ct.as_nanos() as u64)
|
||||
.unwrap_or(0),
|
||||
..__wasi_filestat_t::default()
|
||||
})
|
||||
}
|
||||
},
|
||||
Kind::Dir { path, .. } => {
|
||||
let md = path.metadata().ok()?;
|
||||
Some(__wasi_filestat_t {
|
||||
st_filetype: host_file_type_to_wasi_file_type(md.file_type()),
|
||||
st_size: md.len(),
|
||||
st_atim: md
|
||||
.accessed()
|
||||
.ok()?
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.ok()?
|
||||
.as_nanos() as u64,
|
||||
st_mtim: md
|
||||
.modified()
|
||||
.ok()?
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.ok()?
|
||||
.as_nanos() as u64,
|
||||
st_ctim: md
|
||||
.created()
|
||||
.ok()
|
||||
.and_then(|ct| ct.duration_since(SystemTime::UNIX_EPOCH).ok())
|
||||
.map(|ct| ct.as_nanos() as u64)
|
||||
.unwrap_or(0),
|
||||
..__wasi_filestat_t::default()
|
||||
})
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ use self::types::*;
|
||||
use crate::{
|
||||
ptr::{Array, WasmPtr},
|
||||
state::{
|
||||
host_file_type_to_wasi_file_type, Fd, InodeVal, Kind, WasiFile, WasiState, MAX_SYMLINKS,
|
||||
get_stat_for_kind, host_file_type_to_wasi_file_type, Fd, InodeVal, Kind, WasiFile,
|
||||
WasiState, MAX_SYMLINKS,
|
||||
},
|
||||
ExitCode,
|
||||
};
|
||||
@ -187,7 +188,10 @@ pub fn clock_time_get(
|
||||
precision: __wasi_timestamp_t,
|
||||
time: WasmPtr<__wasi_timestamp_t>,
|
||||
) -> __wasi_errno_t {
|
||||
debug!("wasi::clock_time_get");
|
||||
debug!(
|
||||
"wasi::clock_time_get clock_id: {}, precision: {}",
|
||||
clock_id, precision
|
||||
);
|
||||
let memory = ctx.memory(0);
|
||||
|
||||
let out_addr = wasi_try!(time.deref(memory));
|
||||
@ -1082,7 +1086,7 @@ pub fn path_create_directory(
|
||||
entries: Default::default(),
|
||||
};
|
||||
let new_inode = state.fs.inodes.insert(InodeVal {
|
||||
stat: __wasi_filestat_t::default(),
|
||||
stat: wasi_try!(get_stat_for_kind(&kind).ok_or(__WASI_EIO)),
|
||||
is_preopened: false,
|
||||
name: path_vec[0].clone(),
|
||||
kind,
|
||||
@ -1226,10 +1230,7 @@ pub fn path_filestat_get(
|
||||
}
|
||||
let final_path_metadata =
|
||||
wasi_try!(cumulative_path.metadata().map_err(|_| __WASI_EIO));
|
||||
__wasi_filestat_t {
|
||||
st_filetype: host_file_type_to_wasi_file_type(final_path_metadata.file_type()),
|
||||
..Default::default()
|
||||
}
|
||||
wasi_try!(get_stat_for_kind(&state.fs.inodes[inode].kind).ok_or(__WASI_EIO))
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
@ -1535,7 +1536,7 @@ pub fn path_open(
|
||||
|
||||
// record lazily loaded or newly created fd
|
||||
let new_inode = state.fs.inodes.insert(InodeVal {
|
||||
stat: __wasi_filestat_t::default(),
|
||||
stat: wasi_try!(get_stat_for_kind(&kind).ok_or(__WASI_EIO)),
|
||||
is_preopened: false,
|
||||
name: file_name.clone(),
|
||||
kind,
|
||||
|
@ -24,9 +24,9 @@ pub struct __wasi_ciovec_t {
|
||||
unsafe impl ValueType for __wasi_ciovec_t {}
|
||||
|
||||
pub type __wasi_clockid_t = u32;
|
||||
pub const __WASI_CLOCK_MONOTONIC: u32 = 0;
|
||||
pub const __WASI_CLOCK_PROCESS_CPUTIME_ID: u32 = 1;
|
||||
pub const __WASI_CLOCK_REALTIME: u32 = 2;
|
||||
pub const __WASI_CLOCK_REALTIME: u32 = 0;
|
||||
pub const __WASI_CLOCK_MONOTONIC: u32 = 1;
|
||||
pub const __WASI_CLOCK_PROCESS_CPUTIME_ID: u32 = 2;
|
||||
pub const __WASI_CLOCK_THREAD_CPUTIME_ID: u32 = 3;
|
||||
|
||||
pub type __wasi_device_t = u64;
|
||||
|
@ -23,7 +23,8 @@ pub fn platform_clock_res_get(
|
||||
(clock_getres(unix_clock_id, &mut timespec_out), timespec_out)
|
||||
};
|
||||
|
||||
resolution.set(timespec_out.tv_nsec as __wasi_timestamp_t);
|
||||
let t_out = (timespec_out.tv_sec * 1_000_000_000).wrapping_add(timespec_out.tv_nsec);
|
||||
resolution.set(t_out as __wasi_timestamp_t);
|
||||
|
||||
// TODO: map output of clock_getres to __wasi_errno_t
|
||||
__WASI_ESUCCESS
|
||||
@ -50,9 +51,8 @@ pub fn platform_clock_time_get(
|
||||
)
|
||||
};
|
||||
|
||||
// TODO: adjust output by precision...
|
||||
|
||||
time.set(timespec_out.tv_nsec as __wasi_timestamp_t);
|
||||
let t_out = (timespec_out.tv_sec * 1_000_000_000).wrapping_add(timespec_out.tv_nsec);
|
||||
time.set(t_out as __wasi_timestamp_t);
|
||||
|
||||
// TODO: map output of clock_gettime to __wasi_errno_t
|
||||
__WASI_ESUCCESS
|
||||
|
@ -46,7 +46,7 @@ macro_rules! assert_wasi_output {
|
||||
.map_err(|e| format!("{:?}", e))
|
||||
.expect("start function in wasi module");
|
||||
|
||||
let _result = start.call();
|
||||
start.call().expect("execute the wasm");
|
||||
|
||||
let output = capturer.end().unwrap().0;
|
||||
let expected_output = include_str!($expected);
|
||||
|
@ -1,5 +1,4 @@
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_file_metadata() {
|
||||
assert_wasi_output!(
|
||||
"../../wasitests/file_metadata.wasm",
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +1,3 @@
|
||||
is dir: false
|
||||
file info: FileType(FileType { mode: 33188 }) 419 Ok(SystemTime { tv_sec: 1558132188, tv_nsec: 545288295 }) Ok(SystemTime { tv_sec: 1558132188, tv_nsec: 545243056 }) Ok(SystemTime { tv_sec: 1558132191, tv_nsec: 359031112 })
|
||||
filetype: false true false
|
||||
file info: 456
|
||||
|
@ -6,12 +6,12 @@ fn main() {
|
||||
fs::File::open("wasitests/file_metadata.rs").expect("could not find src file");
|
||||
let md = this_file.metadata().unwrap();
|
||||
println!("is dir: {}", md.is_dir());
|
||||
let filetype = md.file_type();
|
||||
println!(
|
||||
"file info: {:?} {} {:?} {:?} {:?}",
|
||||
md.file_type(),
|
||||
md.len(),
|
||||
md.modified(),
|
||||
md.created(),
|
||||
md.accessed()
|
||||
"filetype: {} {} {}",
|
||||
filetype.is_dir(),
|
||||
filetype.is_file(),
|
||||
filetype.is_symlink()
|
||||
);
|
||||
println!("file info: {}", md.len());
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +1 @@
|
||||
file_metadata
|
||||
create_dir
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user