Skip to content
This repository has been archived by the owner on Jun 27, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Add wasi::clock_time_get tests
This adds a couple of tests for validating the behavior of
wasi::clock_time_get.
  • Loading branch information
caspervonb committed Aug 4, 2020
1 parent f50b8d2 commit 849624d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/bin/wasi_clock_time_get_monotonic.rs
@@ -0,0 +1,14 @@
// {
// }

fn main() {
unsafe {
let time1 = wasi::clock_time_get(wasi::CLOCKID_MONOTONIC, 0).unwrap();
assert!(time1 > 0);

let time2 = wasi::clock_time_get(wasi::CLOCKID_MONOTONIC, 1).unwrap();
assert!(time2 > 0);

assert!(time1 < time2);
}
}
14 changes: 14 additions & 0 deletions src/bin/wasi_clock_time_get_process.rs
@@ -0,0 +1,14 @@
// {
// }

fn main() {
unsafe {
let time1 = wasi::clock_time_get(wasi::CLOCKID_MONOTONIC, 0).unwrap();
assert!(time1 > 0);

let time2 = wasi::clock_time_get(wasi::CLOCKID_PROCESS_CPUTIME_ID, 1).unwrap();
assert!(time2 > 0);

assert!(time1 < time2);
}
}
14 changes: 14 additions & 0 deletions src/bin/wasi_clock_time_get_realtime.rs
@@ -0,0 +1,14 @@
// {
// }

fn main() {
unsafe {
let time1 = wasi::clock_time_get(wasi::CLOCKID_REALTIME, 0).unwrap();
assert!(time1 > 0);

let time2 = wasi::clock_time_get(wasi::CLOCKID_REALTIME, 1).unwrap();
assert!(time2 > 0);

assert!(time1 < time2);
}
}
14 changes: 14 additions & 0 deletions src/bin/wasi_clock_time_get_thread.rs
@@ -0,0 +1,14 @@
// {
// }

fn main() {
unsafe {
let time1 = wasi::clock_time_get(wasi::CLOCKID_THREAD_CPUTIME_ID, 0).unwrap();
assert!(time1 > 0);

let time2 = wasi::clock_time_get(wasi::CLOCKID_THREAD_CPUTIME_ID, 1).unwrap();
assert!(time2 > 0);

assert!(time1 < time2);
}
}

0 comments on commit 849624d

Please sign in to comment.