Skip to content

Commit

Permalink
test: improve output information
Browse files Browse the repository at this point in the history
- Print to stdout as soon as the kernel successfully boots
- Print to stdout in run_simple_vm to make it clear that the kernel has
  been compiled
- Clarify the test-kernel being built, as the "name mismatch" between
  fs-test.rs and create_file.rs can be a bit confusing
- Add newline between build_hermit_bin + run_simple_vm output and
  output coming from the kernel
- Minor linguistic improvements

These changes may seem redundant to the trained eye (for example,
it is safe to assume that the output starting with "frequency: ..."
is from the kernel, thus everything that follows is from the kernel),
but can be very helpful to beginners.

Based on local changes that I created for personal use, so as to better
understand the debugging process.
  • Loading branch information
n0toose committed Sep 23, 2024
1 parent 08cce05 commit 355a3f4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ use uhyvelib::{params::Params, vm::UhyveVm};
/// Returns a path to the build binary.
pub fn build_hermit_bin(kernel: impl AsRef<Path>) -> PathBuf {
let kernel = kernel.as_ref();
println!("Building Kernel {}", kernel.display());
let kernel_src_path = Path::new("tests/test-kernels");
println!("Building test kernel: {}", kernel.display());

let cmd = Command::new("cargo")
.arg("build")
.arg("-Zbuild-std=std,panic_abort")
Expand All @@ -26,7 +27,8 @@ pub fn build_hermit_bin(kernel: impl AsRef<Path>) -> PathBuf {
.current_dir(kernel_src_path)
.status()
.expect("failed to execute `cargo build`");
assert!(cmd.success(), "Test binaries could not be build");

assert!(cmd.success(), "Test binaries could not be built.");
[
kernel_src_path,
Path::new("target/x86_64-unknown-hermit/debug"),
Expand All @@ -39,6 +41,7 @@ pub fn build_hermit_bin(kernel: impl AsRef<Path>) -> PathBuf {
/// Small wrapper around [`Uhyve::run`] with default parameters for a small and
/// simple Uhyve vm
pub fn run_simple_vm(kernel_path: PathBuf) {
println!("Launching kernel {}", kernel_path.display());
let params = Params {
verbose: true,
cpu_count: 2.try_into().unwrap(),
Expand Down
1 change: 1 addition & 0 deletions tests/gdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ symbol-file {bin_path} -o 0x400000
break gdb::main
continue
next
next
next
pipe print _x|cat >> {output_path}
Expand Down
2 changes: 2 additions & 0 deletions tests/test-kernels/src/bin/create_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use std::{fs::File, io::prelude::*};
use hermit as _;

fn main() {
println!("Hello from create_file!");

let mut file = File::create("/root/foo.txt").unwrap();
file.write_all(b"Hello, world!").unwrap();
}
2 changes: 2 additions & 0 deletions tests/test-kernels/src/bin/gdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use hermit as _;
static mut WATCH: u8 = 2;

fn main() {
println!("Hello from gdb!");

let _x = 5;
opaque(_x);
let _x = 3.5;
Expand Down
2 changes: 1 addition & 1 deletion tests/test-kernels/src/bin/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn virtual_to_physical(virtual_address: VirtAddr) -> Option<GuestPhysAddr> {
}

fn main() {
println!("Test");
println!("Hello from serial!");

let mut serial_byte_port = Port::new(HypercallAddress::Uart as u16);
for c in "ABCD\n".bytes() {
Expand Down

0 comments on commit 355a3f4

Please sign in to comment.