Commit cf249eb3 authored by Jonathan Schwender's avatar Jonathan Schwender Committed by Stefan Lankes
Browse files

Fix issues caused by rebase

parent 3de23978
......@@ -22,7 +22,7 @@ exclude = ["/img/*", "./CMakeLists.txt", "/.travis.yml", "/.gitlab-ci.yml", ".gi
travis-ci = { repository = "hermitcore/libhermit-rs" }
[lib]
crate-type = ["staticlib"]
crate-type = ["staticlib", "lib"] # "lib" required for integration tests
name = "hermit"
[[test]]
......@@ -31,6 +31,10 @@ harness = false
[[test]]
name = "basic_math"
harness = true
[[test]]
name = "measure_startup_time"
harness = false
[features]
......@@ -55,7 +59,7 @@ bitflags = "1.2"
num-derive = "0.3"
[dependencies.num]
version = "0.3"
version = "0.2"
default-features = false
[dependencies.num-traits]
......@@ -78,11 +82,12 @@ default-features = false
[profile.dev]
opt-level = 1 # controls the `--opt-level` the compiler builds with
debug = true # controls whether the compiler passes `-C debuginfo`
# a value of `true` is equivalent to `2`
# a value of `true` is equivalent to `2`
rpath = false # controls whether the compiler passes `-C rpath`
lto = false # controls `-C lto` for binaries and staticlibs
debug-assertions = true # controls whether debug assertions are enabled
panic = "abort" # Call abort on panic https://github.com/rust-lang/rust/pull/32900
# Disabled because of https://github.com/rust-lang/cargo/issues/7359
#panic = "abort" # Call abort on panic https://github.com/rust-lang/rust/pull/32900
# The release profile, used for `cargo build --release`.
[profile.release]
......@@ -91,4 +96,4 @@ debug = false
rpath = false
lto = "thin"
debug-assertions = false
panic = "abort"
#panic = "abort"
......@@ -109,6 +109,15 @@ pub fn _print(args: ::core::fmt::Arguments) {
crate::console::CONSOLE.lock().write_fmt(args).unwrap();
}
#[cfg(test)]
#[cfg(target_os = "hermit")]
#[no_mangle]
extern "C" fn runtime_entry(_argc: i32, _argv: *const *const u8, _env: *const *const u8) -> ! {
println!("Executing hermit unittests. Any arguments are dropped");
test_main();
sys_exit(0);
}
//https://github.com/rust-lang/rust/issues/50297#issuecomment-524180479
#[cfg(test)]
pub fn test_runner(tests: &[&dyn Fn()]) {
......
......@@ -8,8 +8,9 @@
//use core::panic::PanicInfo;
extern crate hermit;
mod common;
#[macro_use]
use common::*;
mod common;
/// Print all Strings the application got passed as arguments
#[no_mangle]
......@@ -19,3 +20,5 @@ pub fn main(args: Vec<String>) -> Result<(), ()> {
}
Ok(()) // real assertion is done by the runner
}
runtime_entry_with_args!();
......@@ -228,7 +228,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) -> ! {
}
// ToDo: Maybe we could add a hard limit on the length of `s` to make this slightly safer?
unsafe fn parse_str(s: *const u8) -> Result<String, ()> {
pub unsafe fn parse_str(s: *const u8) -> Result<String, ()> {
let mut vec: Vec<u8> = Vec::new();
let mut off = s;
while *off != 0 {
......@@ -241,40 +241,42 @@ unsafe fn parse_str(s: *const u8) -> Result<String, ()> {
Err(_) => Err(()), //Convert error here since we might want to add another error type later
}
}
/*
// Workaround if the "real" runtime_entry function (defined in libstd) is not available
// We only need this if we build without std
#[no_mangle]
extern "C" fn runtime_entry(argc: i32, argv: *const *const u8, _env: *const *const u8) -> ! {
extern "Rust" {
/// main functions of integration test get their arguments as a Vec<String> and
/// must return a Result<(), ()> indicating success or failure of the tests
fn main(args: Vec<String>) -> Result<(), ()>;
}
/// defines runtime_entry and passes arguments as Rust String to main method with signature:
/// `fn main(args: Vec<String>) -> Result<(), ()>;`
#[macro_export]
macro_rules! runtime_entry_with_args {
() => {
#[no_mangle]
extern "C" fn runtime_entry(
argc: i32,
argv: *const *const u8,
_env: *const *const u8,
) -> ! {
let mut str_vec: Vec<String> = Vec::new();
let mut off = argv;
for i in 0..argc {
let s = unsafe { common::parse_str(*off) };
unsafe {
off = off.offset(1);
}
match s {
Ok(s) => str_vec.push(s),
Err(_) => println!(
"Warning: Application argument {} is not valid utf-8 - Dropping it",
i
),
}
}
let mut str_vec: Vec<String> = Vec::new();
let mut off = argv;
for i in 0..argc {
let s = unsafe { parse_str(*off) };
unsafe {
off = off.offset(1);
}
match s {
Ok(s) => str_vec.push(s),
Err(_) => println!(
"Warning: Application argument {} is not valid utf-8 - Dropping it",
i
),
let res = main(str_vec);
match res {
Ok(_) => exit(false),
Err(_) => exit(true),
}
}
}
let res = unsafe { main(str_vec) };
match res {
Ok(_) => exit(false),
Err(_) => exit(true),
}
};
}
*/
//adapted from: https://rust-lang.github.io/rfcs/2360-bench-black-box.html
#[inline(always)]
pub fn value_fence<T>(x: T) -> T {
......
......@@ -181,7 +181,8 @@ test_name = os.path.basename(test_exe)
test_name = clean_test_name(test_name)
if test_name == "hermit":
print("Executing the Unittests is currently broken... Skipping Test and marking as failed")
exit(-1)
print("Note: If you want to execute all tests, consider adding the '--no-fail-fast' flag")
exit(36)
if args.bootloader_path is not None:
test_runner = QemuTestRunner(test_exe, args.bootloader_path)
......
......@@ -3,9 +3,11 @@
extern crate hermit;
mod common;
#[macro_use]
use common::*;
mod common;
/// This Test lets the runner measure the basic overhead of the tests including
/// - hypervisor startup time
/// - kernel boot-time
......@@ -14,3 +16,5 @@ use common::*;
pub fn main(args: Vec<String>) -> Result<(), ()> {
Ok(())
}
runtime_entry_with_args!();
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment