Reorganize wasi-misc-tests. (#575)

* Reorganize wasi-misc-tests.

Move wasi-misc-tests out of wasi-common, to break a dependency cycle;
previously, wasmtime-* depended on wasi-common, but wasi-common
dev-dependended on wasmtime-*.

Now, wasi-common no longer dev-depends on wasmtime-*; instead, the
tests are in their own crate which depends on wasi-common and on
wasmtime-*.

Also, rename wasi-misc-tests to wasi-tests for simplicity.

This also removes the "wasm_tests" feature; it's replaced by the
"test-programs" feature.

* Update the CI script to use the new feature name.

* Update the CI script to use the new feature name in one more place.

* Change a `write!` to a `writeln!`.
This commit is contained in:
Dan Gohman
2019-11-15 08:03:43 -08:00
committed by GitHub
parent b0f558aa10
commit d4fd229e5e
49 changed files with 328 additions and 337 deletions

View File

@@ -0,0 +1,37 @@
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"
);
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 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"
);
assert_le!(first_time, time, "CLOCK_MONOTONIC should be monotonic");
}
fn main() {
// Run the tests.
unsafe { test_clock_time_get() }
}