Handle backspace for k210/qemu platform && Add lots of user tests.

This commit is contained in:
Yifan Wu 2020-12-11 01:44:07 +08:00
parent f69b3e11dd
commit 48a11e53ff
20 changed files with 361 additions and 35 deletions

30
user/src/bin/sleep.rs Normal file
View file

@ -0,0 +1,30 @@
#![no_std]
#![no_main]
#[macro_use]
extern crate user_lib;
use user_lib::{sleep, exit, get_time, fork, waitpid};
fn sleepy() {
let time: usize = 100;
for i in 0..5 {
sleep(time);
println!("sleep {} x {} msecs.", i + 1, time);
}
exit(0);
}
#[no_mangle]
pub fn main() -> i32 {
let current_time = get_time();
let pid = fork();
let mut xstate: i32 = 0;
if pid == 0 {
sleepy();
}
assert!(waitpid(pid as usize, &mut xstate) == pid && xstate == 0);
println!("use {} msecs.", get_time() - current_time);
println!("sleep pass.");
0
}