Fix other usertests: xstate -> exit_code

This commit is contained in:
Yifan Wu 2021-02-08 18:08:34 +08:00
parent 5e798029b0
commit f1e772a984
5 changed files with 16 additions and 16 deletions

View File

@ -22,12 +22,12 @@ pub fn main() -> i32 {
} }
} }
let mut xstate: i32 = 0; let mut exit_code: i32 = 0;
for _ in 0..NUM { for _ in 0..NUM {
assert!(wait(&mut xstate) > 0); assert!(wait(&mut exit_code) > 0);
assert_eq!(xstate, 0); assert_eq!(exit_code, 0);
} }
assert!(wait(&mut xstate) < 0); assert!(wait(&mut exit_code) < 0);
println!("forktest2 test passed!"); println!("forktest2 test passed!");
0 0
} }

View File

@ -18,11 +18,11 @@ pub fn main() -> i32 {
100 100
} else { } else {
// parent process // parent process
let mut xstate: i32 = 0; let mut exit_code: i32 = 0;
println!("ready waiting on parent process!"); println!("ready waiting on parent process!");
assert_eq!(pid, wait(&mut xstate)); assert_eq!(pid, wait(&mut exit_code));
assert_eq!(xstate, 100); assert_eq!(exit_code, 100);
println!("child process pid = {}, exit code = {}", pid, xstate); println!("child process pid = {}, exit code = {}", pid, exit_code);
0 0
} }
} }

View File

@ -56,13 +56,13 @@ pub fn main() -> i32 {
println!("fork ok."); println!("fork ok.");
let mut xstate: i32 = 0; let mut exit_code: i32 = 0;
for _ in 0..NUM { for _ in 0..NUM {
if wait(&mut xstate) < 0 { if wait(&mut exit_code) < 0 {
panic!("wait failed."); panic!("wait failed.");
} }
} }
assert!(wait(&mut xstate) < 0); assert!(wait(&mut exit_code) < 0);
println!("matrix passed."); println!("matrix passed.");
0 0
} }

View File

@ -19,11 +19,11 @@ fn sleepy() {
pub fn main() -> i32 { pub fn main() -> i32 {
let current_time = get_time(); let current_time = get_time();
let pid = fork(); let pid = fork();
let mut xstate: i32 = 0; let mut exit_code: i32 = 0;
if pid == 0 { if pid == 0 {
sleepy(); sleepy();
} }
assert!(waitpid(pid as usize, &mut xstate) == pid && xstate == 0); assert!(waitpid(pid as usize, &mut exit_code) == pid && exit_code == 0);
println!("use {} msecs.", get_time() - current_time); println!("use {} msecs.", get_time() - current_time);
println!("sleep pass."); println!("sleep pass.");
0 0

View File

@ -29,10 +29,10 @@ pub fn main() -> i32 {
exec(*test); exec(*test);
panic!("unreachable!"); panic!("unreachable!");
} else { } else {
let mut xstate: i32 = Default::default(); let mut exit_code: i32 = Default::default();
let wait_pid = waitpid(pid as usize, &mut xstate); let wait_pid = waitpid(pid as usize, &mut exit_code);
assert_eq!(pid, wait_pid); assert_eq!(pid, wait_pid);
println!("\x1b[32mUsertests: Test {} in Process {} exited with code {}\x1b[0m", test, pid, xstate); println!("\x1b[32mUsertests: Test {} in Process {} exited with code {}\x1b[0m", test, pid, exit_code);
} }
} }
println!("Usertests passed!"); println!("Usertests passed!");