mirror of
https://github.com/hexagonal-sun/moss-kernel.git
synced 2025-12-23 22:47:55 -05:00
add another usertest
Conflicts: usertest/src/main.rs
This commit is contained in:
@@ -151,10 +151,25 @@ fn test_futex() {
|
||||
|
||||
fn test_rust_mutex() {
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread;
|
||||
|
||||
print!("Testing Rust Mutex ...");
|
||||
let mutex = Arc::new(Mutex::new(0));
|
||||
let mtx_clone = Arc::clone(&mutex);
|
||||
let mut num = mtx_clone.lock().unwrap();
|
||||
*num += 1;
|
||||
let final_count = *mutex.lock().unwrap();
|
||||
if final_count != 1 {
|
||||
panic!("Mutex test failed, expected 1 but got {}", final_count);
|
||||
}
|
||||
println!(" OK");
|
||||
}
|
||||
|
||||
fn test_rust_mutex_contention() {
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread;
|
||||
|
||||
print!("Testing Rust Mutex w/contention ...");
|
||||
let mutex = Arc::new(Mutex::new(0));
|
||||
let mut handles = vec![];
|
||||
|
||||
for _ in 0..10 {
|
||||
@@ -246,6 +261,7 @@ fn main() {
|
||||
run_test(test_write);
|
||||
run_test(test_futex);
|
||||
run_test(test_rust_mutex);
|
||||
run_test(test_rust_mutex_contention);
|
||||
run_test(test_rust_file);
|
||||
run_test(test_rust_dir);
|
||||
let end = std::time::Instant::now();
|
||||
|
||||
Reference in New Issue
Block a user