From 12076c7ad244662f00840713dfb34fc5de91f65a Mon Sep 17 00:00:00 2001 From: Matthew Leach Date: Sun, 21 Dec 2025 19:47:45 +0000 Subject: [PATCH] usertest: add `test_rust_thread` Add a simple thread spawn test. --- usertest/src/main.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/usertest/src/main.rs b/usertest/src/main.rs index fc053ac..a02c199 100644 --- a/usertest/src/main.rs +++ b/usertest/src/main.rs @@ -1,3 +1,5 @@ +use std::thread; + fn test_sync() { print!("Testing sync syscall ..."); unsafe { @@ -201,6 +203,15 @@ fn test_rust_dir() { println!(" OK"); } +fn test_rust_thread() { + print!("Testing rust threads ..."); + + let handle = thread::spawn(|| 24); + + assert_eq!(handle.join().unwrap(), 24); + println!(" OK"); +} + fn run_test(test_fn: fn()) { // Fork a new process to run the test unsafe { @@ -236,6 +247,7 @@ fn main() { run_test(test_futex); run_test(test_rust_file); run_test(test_rust_dir); + run_test(test_rust_thread); let end = std::time::Instant::now(); println!("All tests passed in {} ms", (end - start).as_millis()); }