Files
redox-kernel/src/tests/mod.rs
jD91mZM2 fe705d9b63 Switch to 2018 edition
Most of this was generated by the absolutely extraordinary `cargo fix`
subcommand. There were still 2 errors and a few warnings to patch up,
but compared to the normal 600+ errors, I'd say the fixer did a damn
good job! I'm also amazed that I could still start the VM after this,
I half expected some kinds of runtime failure...
2019-06-21 12:12:01 +02:00

30 lines
795 B
Rust

use syscall::{self, Error};
/// Test stdio
#[test]
fn 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()));
}
/// Test that invalid reads/writes cause errors
#[test]
fn invalid_path() {
assert_eq!(syscall::read(999, &mut []), Err(Error::new(syscall::EBADF)));
assert_eq!(syscall::write(999, &[]), Err(Error::new(syscall::EBADF)));
}