diff options
| author | Alejandro Soto <alejandro@34project.org> | 2022-10-18 04:21:42 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2022-10-18 04:21:42 -0600 |
| commit | 3a89a79518454e2fc85f38135869dbacf6ac38d2 (patch) | |
| tree | 6e88541205ded36e06fe17c1b6fb7fc7e3da2716 /tb | |
| parent | c96358d3608c264477f0e3c33dbdd0ea98d75a13 (diff) | |
Print simulator command line on test failure
Diffstat (limited to '')
| -rwxr-xr-x | tb/sim/sim.py | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/tb/sim/sim.py b/tb/sim/sim.py index 6b26f7d..f94d259 100755 --- a/tb/sim/sim.py +++ b/tb/sim/sim.py @@ -130,28 +130,35 @@ def exit(*, success): sys.exit(0 if success else 1) +def dump_regs(): + order = {item[0]: i for i, item in enumerate(all_regs)} + next_col = 0 + + for reg, value in sorted(regs.items(), key=lambda item: order[item[0]]): + if next_col > 0: + print(' ', end='', file=sys.stderr) + + print(f'{reg:<8} = 0x{value:08x}', end='', file=sys.stderr) + if next_col == 3: + print(file=sys.stderr) + next_col = 0 + else: + next_col += 1 + + if next_col != 0: + print(file=sys.stderr) + def test_assert(condition, message): if not condition: print( \ f'{COLOR_RED}While running test \'{COLOR_YELLOW}{test_name}' + \ f'{COLOR_RESET}{COLOR_RED}\'\n{message()}{COLOR_RESET}', file=sys.stderr) - order = {item[0]: i for i, item in enumerate(all_regs)} - next_col = 0 - - for reg, value in sorted(regs.items(), key=lambda item: order[item[0]]): - if next_col > 0: - print(' ', end='', file=sys.stderr) + if exec_args: + print('cmdline:', subprocess.list2cmdline(exec_args), file=sys.stderr) - print(f'{reg:<8} = 0x{value:08x}', end='', file=sys.stderr) - if next_col == 3: - print(file=sys.stderr) - next_col = 0 - else: - next_col += 1 - - if next_col != 0: - print(file=sys.stderr) + if regs: + dump_regs() exit(success=False) |
