mirror of
https://github.com/fluencelabs/wasmer
synced 2025-03-30 22:41:03 +00:00
Merge branch 'master' into feature/add-emscripten-core-tests
This commit is contained in:
commit
8d8f20a11c
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -811,6 +811,16 @@ dependencies = [
|
|||||||
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "time"
|
||||||
|
version = "0.1.41"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ucd-util"
|
name = "ucd-util"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
@ -900,6 +910,7 @@ dependencies = [
|
|||||||
"structopt 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"structopt 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"time 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wabt 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wabt 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wasmparser 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wasmparser 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1031,6 +1042,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625"
|
"checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625"
|
||||||
"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6"
|
"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6"
|
||||||
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
|
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
|
||||||
|
"checksum time 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "847da467bf0db05882a9e2375934a8a55cffdc9db0d128af1518200260ba1f6c"
|
||||||
"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d"
|
"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d"
|
||||||
"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
|
"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
|
||||||
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
||||||
|
@ -49,6 +49,7 @@ rayon = "1.0.3"
|
|||||||
byteorder = "1"
|
byteorder = "1"
|
||||||
indicatif = "0.10"
|
indicatif = "0.10"
|
||||||
console = "0.7.1"
|
console = "0.7.1"
|
||||||
|
time = "0.1.41"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
wabt = "0.7.2"
|
wabt = "0.7.2"
|
||||||
|
10
emtests/clock_gettime.c
Normal file
10
emtests/clock_gettime.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
// a simple program that simply calls clock_gettime
|
||||||
|
// not easy to unit test because of non-determinism and so compilation is enough for now
|
||||||
|
int main () {
|
||||||
|
struct timespec tp;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &tp);
|
||||||
|
printf("clock_gettime\n");
|
||||||
|
}
|
1
emtests/clock_gettime.out
Normal file
1
emtests/clock_gettime.out
Normal file
@ -0,0 +1 @@
|
|||||||
|
clock_gettime
|
BIN
emtests/clock_gettime.wasm
Normal file
BIN
emtests/clock_gettime.wasm
Normal file
Binary file not shown.
@ -1,11 +1,10 @@
|
|||||||
use super::utils::{copy_cstr_into_wasm, write_to_buf};
|
use super::utils::{copy_cstr_into_wasm, write_to_buf};
|
||||||
use libc::{
|
use libc::{c_char, c_int, localtime, localtime_r, time as libc_time, time_t, timespec, tm};
|
||||||
c_char, c_int, clock_gettime as libc_clock_gettime, localtime, localtime_r, time, time_t,
|
|
||||||
timespec, tm,
|
|
||||||
};
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
|
use time;
|
||||||
|
|
||||||
use crate::webassembly::Instance;
|
use crate::webassembly::Instance;
|
||||||
|
|
||||||
/// emscripten: _gettimeofday
|
/// emscripten: _gettimeofday
|
||||||
@ -41,19 +40,16 @@ pub extern "C" fn _clock_gettime(clk_id: c_int, tp: c_int, instance: &mut Instan
|
|||||||
tv_nsec: i32,
|
tv_nsec: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
let timespec = match clk_id {
|
||||||
let mut timespec = timespec {
|
0 => time::get_time(),
|
||||||
tv_sec: 0,
|
1 => panic!("Monotonic clock is not supported."),
|
||||||
tv_nsec: 0,
|
_ => panic!("Clock is not supported."),
|
||||||
};
|
};
|
||||||
let ret = libc_clock_gettime(clk_id as _, &mut timespec);
|
|
||||||
if ret != 0 {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
unsafe {
|
||||||
let timespec_struct_ptr = instance.memory_offset_addr(0, tp as _) as *mut GuestTimeSpec;
|
let timespec_struct_ptr = instance.memory_offset_addr(0, tp as _) as *mut GuestTimeSpec;
|
||||||
(*timespec_struct_ptr).tv_sec = timespec.tv_sec as _;
|
(*timespec_struct_ptr).tv_sec = timespec.sec as _;
|
||||||
(*timespec_struct_ptr).tv_nsec = timespec.tv_nsec as _;
|
(*timespec_struct_ptr).tv_nsec = timespec.nsec as _;
|
||||||
}
|
}
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
@ -244,7 +240,7 @@ pub extern "C" fn _time(time_p: u32, instance: &mut Instance) -> time_t {
|
|||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let time_p_addr = instance.memory_offset_addr(0, time_p as _) as *mut i64;
|
let time_p_addr = instance.memory_offset_addr(0, time_p as _) as *mut i64;
|
||||||
time(time_p_addr)
|
libc_time(time_p_addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
src/emtests/clock_gettime.rs
Normal file
9
src/emtests/clock_gettime.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#[test]
|
||||||
|
fn test_clock_gettime() {
|
||||||
|
assert_emscripten_output!(
|
||||||
|
"../../emtests/clock_gettime.wasm",
|
||||||
|
"clock_gettime",
|
||||||
|
vec![],
|
||||||
|
"../../emtests/clock_gettime.out"
|
||||||
|
);
|
||||||
|
}
|
@ -4,6 +4,7 @@
|
|||||||
// The _common module is not autogenerated, as it provides common macros for the emtests
|
// The _common module is not autogenerated, as it provides common macros for the emtests
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod _common;
|
mod _common;
|
||||||
|
mod clock_gettime;
|
||||||
mod emscripten_get_compiler_setting;
|
mod emscripten_get_compiler_setting;
|
||||||
mod env;
|
mod env;
|
||||||
mod fs_exports;
|
mod fs_exports;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user