Add stdout/stderr tests

This commit is contained in:
Jeremy Soller 2016-08-14 18:22:50 -06:00
parent 4e270bb807
commit d97e2e4b4a
2 changed files with 24 additions and 2 deletions

View file

@ -12,7 +12,7 @@ pub mod fs;
pub mod process;
/// System call list
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Call {
/// Exit syscall
Exit,
@ -47,7 +47,7 @@ impl From<usize> for Call {
}
/// The error number for an invalid value
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Error {
/// Operation not permitted
NotPermitted,

View file

@ -1,5 +1,7 @@
use arch::interrupt::{enable_interrupts, halt};
use syscall;
#[test]
fn halt_with_interrupts() {
unsafe {
@ -7,3 +9,23 @@ fn halt_with_interrupts() {
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()));
}