Add stdout/stderr tests
This commit is contained in:
parent
4e270bb807
commit
d97e2e4b4a
|
@ -12,7 +12,7 @@ pub mod fs;
|
||||||
pub mod process;
|
pub mod process;
|
||||||
|
|
||||||
/// System call list
|
/// System call list
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum Call {
|
pub enum Call {
|
||||||
/// Exit syscall
|
/// Exit syscall
|
||||||
Exit,
|
Exit,
|
||||||
|
@ -47,7 +47,7 @@ impl From<usize> for Call {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The error number for an invalid value
|
/// The error number for an invalid value
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Operation not permitted
|
/// Operation not permitted
|
||||||
NotPermitted,
|
NotPermitted,
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use arch::interrupt::{enable_interrupts, halt};
|
use arch::interrupt::{enable_interrupts, halt};
|
||||||
|
|
||||||
|
use syscall;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn halt_with_interrupts() {
|
fn halt_with_interrupts() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -7,3 +9,23 @@ fn halt_with_interrupts() {
|
||||||
halt();
|
halt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn open_stdio() {
|
||||||
|
// Test opening stdin
|
||||||
|
assert_eq!(syscall::open(b"debug:", 0), Ok(0));
|
||||||
|
|
||||||
|
// Test opening stdout
|
||||||
|
assert_eq!(syscall::open(b"debug:", 0), Ok(1));
|
||||||
|
|
||||||
|
// Test opening stderr
|
||||||
|
assert_eq!(syscall::open(b"debug:", 0), Ok(2));
|
||||||
|
|
||||||
|
// Test writing stdout
|
||||||
|
let stdout_str = b"STDOUT";
|
||||||
|
assert_eq!(syscall::write(1, stdout_str), Ok(stdout_str.len()));
|
||||||
|
|
||||||
|
// Test writing stderr
|
||||||
|
let stderr_str = b"STDERR";
|
||||||
|
assert_eq!(syscall::write(2, stderr_str), Ok(stderr_str.len()));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue