-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6883f2
commit 0d0151d
Showing
11 changed files
with
239 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"llvm-target": "i686-unknown-linux-gnu", | ||
"data-layout": "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128", | ||
"target-endian": "little", | ||
"target-pointer-width": "32", | ||
"target-c-int-width": "32", | ||
"arch": "x86", | ||
"os": "linux", | ||
"executables": true, | ||
"features": "-mmx,-sse,+soft-float", | ||
"linker-flavor": "ld", | ||
"linker": "ld.lld-4.0", | ||
"panic": "abort" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#![no_std] | ||
|
||
#[macro_use] | ||
extern crate utest_macros; | ||
|
||
extern crate utest_rxinu; | ||
|
||
macro_rules! panic { | ||
($($tt:tt)*) => { | ||
upanic!($($tt)*); | ||
}; | ||
} | ||
|
||
#[test] | ||
fn foo() { | ||
assert!(true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "utest_rxinu" | ||
version = "0.1.0" | ||
authors = ["Rob Gries <robert.w.gries@gmail.com>"] | ||
|
||
[dependencies] | ||
sc = "0.2.0" | ||
rlibc = "1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use core::{fmt, slice}; | ||
use core::fmt::Write; | ||
|
||
/// STDERR File descriptor | ||
const STDERR: usize = 2; | ||
|
||
struct Stderr; | ||
|
||
impl Stderr { | ||
fn write_all(&mut self, mut buffer: &[u8]) { | ||
while !buffer.is_empty() { | ||
match unsafe { | ||
syscall!(WRITE, STDERR, buffer.as_ptr(), buffer.len()) as | ||
isize | ||
} { | ||
n if n >= 0 => { | ||
buffer = | ||
unsafe { | ||
slice::from_raw_parts(buffer.as_ptr().offset(n), | ||
buffer.len() - n as usize) | ||
} | ||
} | ||
// ignore errors | ||
_ => return, | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl Write for Stderr { | ||
fn write_str(&mut self, s: &str) -> fmt::Result { | ||
self.write_all(s.as_bytes()); | ||
Ok(()) | ||
} | ||
} | ||
|
||
pub fn write_fmt(args: fmt::Arguments) { | ||
Stderr.write_fmt(args).ok(); | ||
} | ||
|
||
pub fn write_str(string: &str) { | ||
Stderr.write_all(string.as_bytes()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use core::intrinsics; | ||
|
||
#[lang = "start"] | ||
extern "C" fn start(main: fn(), | ||
_argc: isize, | ||
_argv: *const *const u8) | ||
-> isize { | ||
main(); | ||
|
||
0 | ||
} | ||
|
||
#[lang = "panic_fmt"] | ||
unsafe extern "C" fn panic_fmt(args: ::core::fmt::Arguments, | ||
file: &'static str, | ||
line: u32) | ||
-> ! { | ||
#[allow(improper_ctypes)] | ||
extern "Rust" { | ||
fn __test_panic_fmt(args: ::core::fmt::Arguments, | ||
file: &'static str, | ||
line: u32); | ||
} | ||
|
||
__test_panic_fmt(args, file, line); | ||
|
||
intrinsics::abort() | ||
} | ||
|
||
#[lang = "eh_personality"] | ||
pub extern "C" fn eh_personality() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#![feature(compiler_builtins_lib)] | ||
#![feature(core_intrinsics)] | ||
#![feature(lang_items)] | ||
#![no_std] | ||
|
||
extern crate compiler_builtins; | ||
|
||
#[macro_use] | ||
extern crate sc; | ||
|
||
extern crate rlibc; | ||
|
||
use core::intrinsics; | ||
|
||
#[macro_use] | ||
mod macros; | ||
|
||
mod lang_items; | ||
mod io; | ||
|
||
#[no_mangle] | ||
pub fn __test_start(ntests: usize) { | ||
eprintln!("running {} tests", ntests) | ||
} | ||
|
||
#[no_mangle] | ||
pub fn __test_ignored(name: &str) { | ||
eprintln!("test {} ... ignored", name); | ||
} | ||
|
||
#[no_mangle] | ||
pub fn __test_before_run(name: &str) { | ||
eprint!("test {} ... ", name); | ||
} | ||
|
||
#[no_mangle] | ||
pub fn __test_panic_fmt(args: ::core::fmt::Arguments, | ||
file: &'static str, | ||
line: u32) { | ||
eprint!("\npanicked at '"); | ||
io::write_fmt(args); | ||
eprintln!("', {}:{}", file, line); | ||
} | ||
|
||
#[no_mangle] | ||
pub fn __test_failed(_name: &str) { | ||
eprintln!("FAILED"); | ||
} | ||
|
||
#[no_mangle] | ||
pub fn __test_success(_name: &str) { | ||
eprintln!("OK"); | ||
} | ||
|
||
#[no_mangle] | ||
pub fn __test_summary(passed: usize, failed: usize, ignored: usize) { | ||
eprintln!("\ntest result: {}. {} passed; {} failed; {} ignored", | ||
if failed == 0 { "OK" } else { "FAILED" }, | ||
passed, | ||
failed, | ||
ignored); | ||
|
||
if failed != 0 { | ||
exit(101); | ||
} | ||
} | ||
|
||
/// Entry point | ||
#[no_mangle] | ||
pub unsafe extern "C" fn _start() -> ! { | ||
extern "C" { | ||
fn main(argc: isize, argv: *const *const u8) -> isize; | ||
} | ||
|
||
main(0, ::core::ptr::null()); | ||
|
||
exit(0); | ||
} | ||
|
||
fn exit(code: i32) -> ! { | ||
unsafe { | ||
syscall!(EXIT, code as usize); | ||
|
||
intrinsics::unreachable() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
macro_rules! eprint { | ||
($s:expr) => ($crate::io::write_str($s)); | ||
($($arg:tt)*) => ($crate::io::write_fmt(format_args!($($arg)*))); | ||
} | ||
|
||
macro_rules! eprintln { | ||
() => (eprint!("\n")); | ||
($fmt:expr) => (eprint!(concat!($fmt, "\n"))); | ||
($fmt:expr, $($arg:tt)*) => (eprint!(concat!($fmt, "\n"), $($arg)*)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"llvm-target": "x86_64-none-eabi", | ||
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", | ||
"target-endian": "little", | ||
"target-pointer-width": "64", | ||
"target-c-int-width": "32", | ||
"arch": "x86_64", | ||
"os": "linux", | ||
"executables": true, | ||
"features": "-mmx,-sse,+soft-float", | ||
"linker-flavor": "ld", | ||
"linker": "ld.lld-4.0", | ||
"panic": "abort" | ||
} |