Skip to content

Commit 754ad26

Browse files
committed
test(port_arm): buffer the panic message
Fixes the test runner only displaying the very first part of the panic message as shown below: Test run 'kernel_tests::compute_round_robin' failed: 'panicked at '' Failed tests: - kernel_tests::compute_round_robin Command failed.
1 parent 30fdd20 commit 754ad26

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/constance_port_arm/src/startup/cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl MemoryMapSection {
7373
/// - `physical_start` is of type `u64`, but using a large physical address
7474
/// (> 4GiB) isn't supported yet.
7575
///
76-
/// The memory section is configured as a read/writable (bot not
76+
/// The memory section is configured as a read/writable (but not
7777
/// executable) Normal memory with a Outer and Inner Write-Back,
7878
/// Write-Allocate attribute.
7979
///

src/constance_port_arm_test_driver/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ board-rza1 = [
2727

2828
output-semihosting = [
2929
"arm_semihosting",
30+
"staticvec",
3031
]
3132

3233
[dependencies]
@@ -35,6 +36,7 @@ constance_port_arm = { path = "../constance_port_arm", optional = true }
3536
arm_semihosting = { path = "../arm_semihosting", optional = true }
3637
constance = { path = "../constance", optional = true }
3738

39+
staticvec = { version = "0.10.2", optional = true, default-features = false }
3840
register = { version = "0.5.1", optional = true }
3941
log = { version = "0.4.8", optional = true }
4042

src/constance_port_arm_test_driver/src/panic_semihosting.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
use arm_semihosting::{debug, debug::EXIT_FAILURE, hio};
22
use core::{fmt::Write, panic::PanicInfo};
3+
use staticvec::StaticString;
4+
5+
static mut BUFFER: StaticString<{ 512 }> = StaticString::new();
36

47
#[panic_handler]
58
fn panic(info: &PanicInfo) -> ! {
69
// Disable interrupts
710
unsafe { llvm_asm!("cpsid i"::::"volatile") };
811

912
if let Ok(mut hstdout) = hio::hstdout() {
10-
writeln!(hstdout, "{}", info).ok();
13+
// The test runner stops reading the output when it encounters a stop
14+
// word (`panicked at`). Actually it continues reading for some time,
15+
// but semihosting output incurs a huge delay on each call and the
16+
// `Display` implementation of `PanicInfo` produces a message in small
17+
// chunks, so the test runner would stop reading after the first chunk
18+
// (`panicked at '`).
19+
//
20+
// To avoid this problem, put the whole message in a buffer and send it
21+
// with a single semihosting call.
22+
let buffer = unsafe { &mut BUFFER };
23+
buffer.clear();
24+
let _ = writeln!(buffer, "{}", info);
25+
26+
let _ = write!(hstdout, "{}", buffer);
1127
}
1228
debug::exit(EXIT_FAILURE);
1329

0 commit comments

Comments
 (0)