Support compiling for host, allowing unit tests.
This commit is contained in:
+3
-7
@@ -49,8 +49,8 @@
|
||||
#![feature(naked_functions)]
|
||||
#![feature(sync_unsafe_cell)]
|
||||
#![feature(variant_count)]
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![cfg_attr(not(test), no_std)]
|
||||
#![cfg_attr(not(test), no_main)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate alloc;
|
||||
@@ -147,11 +147,7 @@ mod syscall;
|
||||
/// Time
|
||||
mod time;
|
||||
|
||||
/// Tests
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[global_allocator]
|
||||
#[cfg_attr(not(test), global_allocator)]
|
||||
static ALLOCATOR: allocator::Allocator = allocator::Allocator;
|
||||
|
||||
/// Get the current CPU's scheduling ID
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
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)));
|
||||
}
|
||||
+1
-1
Submodule syscall updated: c751f76248...e4cc6bfcd5
Reference in New Issue
Block a user