Skip to content

Commit

Permalink
fix(tests): remove explicit QEMU debug exit
Browse files Browse the repository at this point in the history
  • Loading branch information
mkroening committed Jan 2, 2025
1 parent 2813672 commit b046302
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 36 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ memory_addresses = { version = "0.2.2", default-features = false, features = [
[dev-dependencies]
float-cmp = "0.10"
num-traits = { version = "0.2", default-features = false }
x86 = { version = "0.52", default-features = false }

[build-dependencies]
anyhow = "1"
Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ use core::hint::spin_loop;
use core::sync::atomic::{AtomicU32, Ordering};

use arch::core_local::*;
// Used for integration test status.
#[doc(hidden)]
pub use env::is_uhyve as _is_uhyve;

pub(crate) use crate::arch::*;
pub use crate::config::DEFAULT_STACK_SIZE;
Expand Down
34 changes: 3 additions & 31 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ use hermit::{print, println};
//use std::borrow::Cow;
//use std::fmt;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u32)]
pub enum QemuExitCode {
Success = 0x10,
Failed = 0x11,
}

//From libtest types.rs-----------------------------------------------------
/*
/// Type of the test according to the [rust book](https://doc.rust-lang.org/cargo/guide/tests.html)
Expand Down Expand Up @@ -195,31 +188,10 @@ pub fn test_case_runner(tests: &[&dyn Testable]) {
}

pub fn exit(failure: bool) -> ! {
// temporarily make this public. FIXME: we could also pass an argument to main indicating uhyve or qemu
if hermit::_is_uhyve() {
match failure {
//ToDo: Add uhyve exit code enum
true => hermit::syscalls::sys_exit(1),
false => hermit::syscalls::sys_exit(0),
}
} else {
match failure {
true => exit_qemu(QemuExitCode::Failed),
false => exit_qemu(QemuExitCode::Success),
}
}
}

/// Debug exit from qemu with a returncode
/// '-device', 'isa-debug-exit,iobase=0xf4,iosize=0x04' must be passed to qemu for this to work
pub fn exit_qemu(exit_code: QemuExitCode) -> ! {
use x86::io::outl;

unsafe {
outl(0xf4, exit_code as u32);
match failure {
true => hermit::syscalls::sys_exit(1),
false => hermit::syscalls::sys_exit(0),
}
println!("Warning - Failed to debug exit qemu - exiting via sys_exit()");
hermit::syscalls::sys_exit(0) //sys_exit exitcode on qemu gets silently dropped
}

/// defines runtime_entry and passes arguments as Rust String to main method with signature:
Expand Down
2 changes: 1 addition & 1 deletion tests/hermit_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def validate_test_success(self, rc, stdout, stderr, execution_time) -> bool:
if rc == 1:
print("Test failed due to QEMU error. Is QEMU installed?", file=sys.stderr)
return False
elif rc != 33:
elif rc != 3:
# Since we are using asserts, tests should mostly fail due to a panic
# However, other kinds of test errors using the debug_exit of qemu are also possible
print("Test failed due to error returncode: {}".format(rc), file=sys.stderr)
Expand Down

0 comments on commit b046302

Please sign in to comment.