usertest: add test_clock_sleep (#87)

Add a test to ensure sleeping and clock getttime functions are correct.
This commit is contained in:
Matthew Leach
2025-12-24 17:40:13 +00:00
committed by GitHub
parent efe34026fa
commit 5259654e36

View File

@@ -12,6 +12,16 @@ fn test_sync() {
println!(" OK");
}
fn test_clock_sleep() {
const SLEEP_LEN: Duration = Duration::from_millis(100);
print!("Testing clock and sleep syscalls ...");
let now = Instant::now();
sleep(SLEEP_LEN);
assert!(now.elapsed() >= SLEEP_LEN);
println!(" OK");
}
fn test_opendir() {
print!("Testing opendir syscall ...");
let path = std::ffi::CString::new("/").unwrap();
@@ -494,6 +504,7 @@ fn main() {
println!("Running userspace tests ...");
let start = std::time::Instant::now();
run_test(test_sync);
run_test(test_clock_sleep);
run_test(test_opendir);
run_test(test_readdir);
run_test(test_chdir);