Work on adding cargo test capability

This commit is contained in:
Jeremy Soller
2020-03-10 20:57:07 -06:00
parent 79f265745a
commit 2e27cf525e
4 changed files with 75 additions and 1 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ use crate::{
platform::{self, types::*, Pal, Sys},
};
use self::constants::*;
pub use self::constants::*;
pub mod constants;
mod strftime;
+3
View File
@@ -26,6 +26,9 @@ mod sys;
#[path = "redox/mod.rs"]
mod sys;
#[cfg(test)]
mod test;
mod pte;
pub use self::rlb::{Line, RawLineBuffer};
+1
View File
@@ -0,0 +1 @@
use crate::platform::{PalEpoll, Sys};
+70
View File
@@ -0,0 +1,70 @@
use crate::platform::{Pal, Sys};
// Stub for call used in exit
#[no_mangle]
pub extern "C" fn pthread_terminate() {}
mod epoll;
#[test]
fn access() {
use crate::header::{
errno,
unistd,
};
//TODO: create test files
assert_eq!(Sys::access(c_str!("not a file!"), unistd::F_OK), !0);
assert_eq!(Sys::access(c_str!("README.md"), unistd::R_OK), 0);
assert_eq!(Sys::access(c_str!("README.md"), unistd::W_OK), 0);
assert_eq!(Sys::access(c_str!("README.md"), unistd::X_OK), !0);
}
#[test]
fn brk() {
use core::ptr;
let current = Sys::brk(ptr::null_mut());
assert_ne!(current, ptr::null_mut());
let request = unsafe { current.add(4096) };
let next = Sys::brk(request);
assert_eq!(next, request);
}
#[test]
fn chdir() {
//TODO: create test files
assert_eq!(Sys::chdir(c_str!("src")), 0);
}
//TODO: chmod
//TODO: chown
#[test]
fn clock_gettime() {
use crate::header::{
time
};
{
let mut timespec = time::timespec {
tv_sec: -1,
tv_nsec: -1,
};
assert_eq!(Sys::clock_gettime(time::CLOCK_REALTIME, &mut timespec), 0);
assert_ne!(timespec.tv_sec, -1);
assert_ne!(timespec.tv_nsec, -1);
}
{
let mut timespec = time::timespec {
tv_sec: -1,
tv_nsec: -1,
};
assert_eq!(Sys::clock_gettime(time::CLOCK_MONOTONIC, &mut timespec), 0);
assert_ne!(timespec.tv_sec, -1);
assert_ne!(timespec.tv_nsec, -1);
}
}