[opentitantool] Remove backtrace on console exit_failure matches
Nobody has claimed this yet.
- Dominant language
- SystemVerilog
- Stars
- 3.6k
- Forks
- 1.1k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 141
Description
Description
Most device tests will send a success/failure string over the UART which OpenTitanTool will check.
OpenTitanTool treats matches of the failure string as errors, and prints a Rust backtrace. This suggests there was some error inside OpenTitanTool and clogs up stdout when trying to debug a failing test.
OpenTitanTool should be updated to treat matching a failure string as a success, but still return ExitCode::FAILURE to show Bazel that the test itself failed.
Example of what OpenTitanTool currently outputs:
Expand
Starting interactive console
[CTRL+C] to exit.
I00000 test_rom.c:158] kChipInfo: scm_revision=b939a1c6
I00001 test_rom.c:184] TestROM:2934f5bb
I00002 test_rom.c:190] Boot strap requested
I00000 test_rom.c:158] kChipInfo: scm_revision=b939a1c6
I00001 test_rom.c:184] TestROM:2934f5bb
I00002 test_rom.c:230] Test ROM complete, jumping to flash (addr: 20000480)!
I00000 ottf_main.c:154] Running sw/device/tests/sram_ctrl_subword_access_test.c
I00001 sram_ctrl_subword_access_test.c:53] 0000006b
I00002 sram_ctrl_subword_access_test.c:53] 0000006b
E00003 sram_ctrl_subword_access_test.c:63] CHECK-fail: reading 2 bytes at offset 0: byte 1 = 4a, expected = 00
I00004 status.c:34] FAIL!
Exiting interactive console.
[2023-10-24T09:44:16Z INFO opentitantool::command::console] ExitFailure("FAIL!\r\n")
[2023-10-24T09:44:16Z INFO opentitantool] Command result: Matched exit_failure expression
Stack backtrace:
0: <opentitantool::command::console::Console as opentitanlib::app::command::CommandDispatch>::run
1: opentitantool::main
2: std::sys_common::backtrace::__rust_begin_short_backtrace
3: std::rt::lang_start::{{closure}}
4: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/core/src/ops/function.rs:284:13
std::panicking::try::do_call
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/panicking.rs:524:40
std::panicking::try
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/panicking.rs:488:19
std::panic::catch_unwind
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/panic.rs:142:14
std::rt::lang_start_internal::{{closure}}
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/rt.rs:148:48
std::panicking::try::do_call
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/panicking.rs:524:40
std::panicking::try
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/panicking.rs:488:19
std::panic::catch_unwind
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/panic.rs:142:14
std::rt::lang_start_internal
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/rt.rs:148:20
5: main
6: __libc_start_call_main
at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
7: __libc_start_main_impl
at ./csu/../csu/libc-start.c:392:3
8: _start
Error: Matched exit_failure expression
Stack backtrace:
0: <opentitantool::command::console::Console as opentitanlib::app::command::CommandDispatch>::run
1: opentitantool::main
2: std::sys_common::backtrace::__rust_begin_short_backtrace
3: std::rt::lang_start::{{closure}}
4: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/core/src/ops/function.rs:284:13
std::panicking::try::do_call
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/panicking.rs:524:40
std::panicking::try
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/panicking.rs:488:19
std::panic::catch_unwind
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/panic.rs:142:14
std::rt::lang_start_internal::{{closure}}
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/rt.rs:148:48
std::panicking::try::do_call
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/panicking.rs:524:40
std::panicking::try
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/panicking.rs:488:19
std::panic::catch_unwind
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/panic.rs:142:14
std::rt::lang_start_internal
at /rustc/32303b219d4dffa447aa606bc11c7a648f44a862/library/std/src/rt.rs:148:20
5: main
6: __libc_start_call_main
at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
7: __libc_start_main_impl
at ./csu/../csu/libc-start.c:392:3
8: _start
FAIL: //sw/device/tests:sram_ctrl_subword_access_test_fpga_cw310_test_rom (see /home/jw/.cache/bazel/_bazel_jw/7e172ccc9b1d5908d84fded9a2ecf9f4/execroot/lowrisc_opentitan/bazel-out/k8-fastbuild-ST-2cc462681f62/testlogs/sw/device/tests/sram_ctrl_subword_access_test_fpga_cw310_test_rom/test.log)
INFO: Elapsed time: 2.253s, Critical Path: 2.12s
INFO: 6 processes: 3 linux-sandbox, 3 local.
INFO: Build completed, 1 test FAILED, 6 total actions
//sw/device/tests:sram_ctrl_subword_access_test_fpga_cw310_test_rom FAILED in 1.9s
/home/jw/.cache/bazel/_bazel_jw/7e172ccc9b1d5908d84fded9a2ecf9f4/execroot/lowrisc_opentitan/bazel-out/k8-fastbuild-ST-2cc462681f62/testlogs/sw/device/tests/sram_ctrl_subword_access_test_fpga_cw310_test_rom/test.log
Executed 1 out of 1 test: 1 fails locally.
The useful information is right at the top, but gets pushed away by the (two?) backtraces, which are just noise in this context.
And what we'd like it to output:
Expand
Starting interactive console
[CTRL+C] to exit.
I00000 test_rom.c:158] kChipInfo: scm_revision=b939a1c6
I00001 test_rom.c:184] TestROM:2934f5bb
I00002 test_rom.c:190] Boot strap requested
I00000 test_rom.c:158] kChipInfo: scm_revision=b939a1c6
I00001 test_rom.c:184] TestROM:2934f5bb
I00002 test_rom.c:230] Test ROM complete, jumping to flash (addr: 20000480)!
I00000 ottf_main.c:154] Running sw/device/tests/sram_ctrl_subword_access_test.c
I00001 sram_ctrl_subword_access_test.c:53] 0000006b
I00002 sram_ctrl_subword_access_test.c:53] 0000006b
E00003 sram_ctrl_subword_access_test.c:63] CHECK-fail: reading 2 bytes at offset 0: byte 1 = 4a, expected = 00
I00004 status.c:34] FAIL!
Exiting interactive console.
[2023-10-24T09:44:16Z INFO opentitantool::command::console] ExitFailure("FAIL!\r\n")
[2023-10-24T09:44:16Z INFO opentitantool] Command result: Matched exit_failure expression
FAIL: //sw/device/tests:sram_ctrl_subword_access_test_fpga_cw310_test_rom (see /home/jw/.cache/bazel/_bazel_jw/7e172ccc9b1d5908d84fded9a2ecf9f4/execroot/lowrisc_opentitan/bazel-out/k8-fastbuild-ST-2cc462681f62/testlogs/sw/device/tests/sram_ctrl_subword_access_test_fpga_cw310_test_rom/test.log)
INFO: Elapsed time: 2.253s, Critical Path: 2.12s
INFO: 6 processes: 3 linux-sandbox, 3 local.
INFO: Build completed, 1 test FAILED, 6 total actions
//sw/device/tests:sram_ctrl_subword_access_test_fpga_cw310_test_rom FAILED in 1.9s
/home/jw/.cache/bazel/_bazel_jw/7e172ccc9b1d5908d84fded9a2ecf9f4/execroot/lowrisc_opentitan/bazel-out/k8-fastbuild-ST-2cc462681f62/testlogs/sw/device/tests/sram_ctrl_subword_access_test_fpga_cw310_test_rom/test.log
Executed 1 out of 1 test: 1 fails locally.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the OpenTitanTool console command, identified in the output as opentitantool::command::console::Console, and inspect handling of exit_failure expression matches. Verify that a failure-string match no longer emits Rust backtraces while still returning ExitCode::FAILURE; compare the command output with the expected example in this issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100