Skip to content

Commit

Permalink
test-runner: Check that logging keeps working right up until EBS
Browse files Browse the repository at this point in the history
We've had a few bugs where logging stopped working at some point during the
tests. It's easy to miss that if you aren't paying careful attention to the log
output, so add a test for it.
  • Loading branch information
nicholasbishop committed Dec 18, 2023
1 parent 8dd21f5 commit 5049580
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 7 additions & 2 deletions uefi-test-runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,18 @@ fn shutdown(mut st: SystemTable<Boot>) -> ! {
// Get our text output back.
st.stdout().reset(false).unwrap();

info!("Testing complete, shutting down...");

// Tell the host that tests are done. We are about to exit boot
// services, so we can't easily communicate with the host any later
// than this.
send_request_to_host(st.boot_services(), HostRequest::TestsComplete);

// Send a special log to the host so that we can verify that logging works
// up until exiting boot services. See `reconnect_serial_to_console` for the
// type of regression this prevents.
info!("LOGGING_STILL_WORKING_RIGHT_BEFORE_EBS");

info!("Testing complete, shutting down...");

// Exit boot services as a proof that it works :)
let (st, _iter) = st.exit_boot_services(MemoryType::LOADER_DATA);

Expand Down
10 changes: 10 additions & 0 deletions xtask/src/qemu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ impl Io {

fn process_qemu_io(mut monitor_io: Io, mut serial_io: Io, tmp_dir: &Path) -> Result<()> {
let mut tests_complete = false;
let mut logging_still_working_right_before_ebs = false;

// This regex is used to detect and strip ANSI escape codes. These
// escapes are added by the console output protocol when writing to
Expand Down Expand Up @@ -371,6 +372,11 @@ fn process_qemu_io(mut monitor_io: Io, mut serial_io: Io, tmp_dir: &Path) -> Res
tests_complete = true;

reply_ok()?;
} else if line.ends_with("LOGGING_STILL_WORKING_RIGHT_BEFORE_EBS") {
// The app sends this right before calling
// `exit_boot_services`. This serves as a test that we didn't break
// logging by opening the serial device in exclusive mode.
logging_still_working_right_before_ebs = true;
} else {
println!("{line}");
}
Expand All @@ -380,6 +386,10 @@ fn process_qemu_io(mut monitor_io: Io, mut serial_io: Io, tmp_dir: &Path) -> Res
bail!("tests did not complete successfully");
}

if !logging_still_working_right_before_ebs {
bail!("logging stopped working sometime before exiting boot services");
}

Ok(())
}

Expand Down

0 comments on commit 5049580

Please sign in to comment.