Start to update the wasi crate in wasi tests (#675)

* Move `wasi` to `wasi_old` in wasi-tests

Leave space for the new `wasi` crate but allow us to incrementally
update tests.

* Update the big_random_buf test

* Update clock_time_get test

* Update close_preopen test

* Review comments

* Update to latest Wasmtime API
This commit is contained in:
Alex Crichton
2019-12-09 04:08:47 -08:00
committed by Jakub Konka
parent 51f880f625
commit e13fabb276
40 changed files with 137 additions and 120 deletions

View File

@@ -1,33 +1,15 @@
use more_asserts::assert_le;
use wasi::wasi_unstable;
use wasi_tests::wasi_wrappers::wasi_clock_time_get;
unsafe fn test_clock_time_get() {
// Test that clock_time_get succeeds. Even in environments where it's not
// desirable to expose high-precision timers, it should still succeed.
// clock_res_get is where information about precision can be provided.
let mut time: wasi_unstable::Timestamp = 0;
let status = wasi_clock_time_get(wasi_unstable::CLOCK_MONOTONIC, 1, &mut time);
assert_eq!(
status,
wasi_unstable::raw::__WASI_ESUCCESS,
"clock_time_get with a precision of 1"
);
wasi::clock_time_get(wasi::CLOCKID_MONOTONIC, 1).expect("precision 1 should work");
let status = wasi_clock_time_get(wasi_unstable::CLOCK_MONOTONIC, 0, &mut time);
assert_eq!(
status,
wasi_unstable::raw::__WASI_ESUCCESS,
"clock_time_get with a precision of 0"
);
let first_time = time;
let first_time =
wasi::clock_time_get(wasi::CLOCKID_MONOTONIC, 0).expect("precision 0 should work");
let status = wasi_clock_time_get(wasi_unstable::CLOCK_MONOTONIC, 0, &mut time);
assert_eq!(
status,
wasi_unstable::raw::__WASI_ESUCCESS,
"clock_time_get with a precision of 0"
);
let time = wasi::clock_time_get(wasi::CLOCKID_MONOTONIC, 0).expect("re-fetch time should work");
assert_le!(first_time, time, "CLOCK_MONOTONIC should be monotonic");
}