Commits (6)
......@@ -45,6 +45,7 @@ test:redox:
variables:
TARGET: x86_64-unknown-redox
script:
- export CARGO="redoxer"
- export RUSTUP_TOOLCHAIN="$HOME/.redoxer/toolchain"
- export PATH="$RUSTUP_TOOLCHAIN/bin:$PATH"
- export TEST_RUNNER="redoxer exec --folder . -- sh --"
......
......@@ -88,6 +88,7 @@ sysroot: all
touch $@
test: sysroot
$(CARGO) test
$(MAKE) -C tests verify
# Debug targets
......
/*
* MIT License
* Copyright (c) 2020 Rich Felker musl-libc
*/
#ifndef _FEATURES_H
#define _FEATURES_H
#if __STDC_VERSION__ >= 199901L
#define __restrict restrict
#elif !defined(__GNUC__)
#define __restrict
#endif
#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
#define __inline inline
#elif !defined(__GNUC__)
#define __inline
#endif
#if __STDC_VERSION__ >= 201112L
#elif defined(__GNUC__)
#define _Noreturn __attribute__((__noreturn__))
#else
#define _Noreturn
#endif
#endif
......@@ -4,12 +4,20 @@
#define NULL 0
typedef signed long long ptrdiff_t;
#ifndef __PTRDIFF_TYPE__
#define __PTRDIFF_TYPE__ long int
#endif
typedef __PTRDIFF_TYPE__ ptrdiff_t;
#ifndef __cplusplus
typedef int32_t wchar_t;
#endif /* #ifndef __cplusplus */
typedef int32_t wint_t;
typedef unsigned long long size_t;
typedef long unsigned int size_t;
typedef struct { long long __ll; long double __ld; } max_align_t;
#define offsetof(type, member) __builtin_offsetof(type, member)
......
......@@ -5,7 +5,7 @@ use crate::{
platform::{self, types::*, Pal, Sys},
};
use self::constants::*;
pub use self::constants::*;
pub mod constants;
mod strftime;
......
......@@ -26,6 +26,9 @@ mod sys;
#[path = "redox/mod.rs"]
mod sys;
#[cfg(test)]
mod test;
mod pte;
pub use self::rlb::{Line, RawLineBuffer};
......
use crate::platform::{PalEpoll, Sys};
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);
}
}