Tx test supports multiple MIDI commands

This commit is contained in:
Ed
2024-04-26 13:05:52 +01:00
parent 9ddfff1d60
commit 7acd4ffe99
3 changed files with 33 additions and 8 deletions

View File

@@ -59,4 +59,4 @@ def test_midi_loopback(capfd, build_midi):
print("CAPTURE:", capture)
print("EXPECTED:", expected)
assert result
assert result

View File

@@ -43,7 +43,6 @@ def test_rx(capfd, config, build_midi):
stop = 1
midi_commands_flattened = [item for row in midi_commands for item in row]
# midi_commands_flattened.append(0x00) # send a null afterwards to give RXChecker to complete
simthreads = [
UARTRxChecker(tx_port, rx_port, parity, baud, stop, bpb, midi_commands_flattened, debug=False)
@@ -69,4 +68,4 @@ def test_rx(capfd, config, build_midi):
print("EXPECTED:", expected)
assert result, f"expected: {expected}\n capture: {capture}"
assert result, f"expected: {expected}\n capture: {capture}"

View File

@@ -23,11 +23,23 @@ def test_tx(capfd, config, build_midi):
copy_tree(build_midi, tmpdirname)
xe = str(Path(tmpdirname) / f"{config}/test_midi_{config}.xe")
midi_commands = [[0x90, 60, 81]]
# midi_commands = [[0x90, 0x91, 0x90],# Invalid and should be discarded
# [0x90, 60, 81], # Note on
# [0x80, 60, 81]] # Note off
midi_commands = [
[0x90, 60, 81], # Note on
[0x80, 60, 81]] # Note off
# midi_command_expected = midi_commands[1:] # should skip invalid first message
# Make a 1D list from the 2D list
midi_command_expected = [[item for row in midi_commands for item in row]]
create_midi_tx_file(midi_commands)
create_midi_rx_file()
expected = midi_expect_tx().expect(midi_commands)
expected = midi_expect_tx().expect(midi_command_expected)
tester = testers.ComparisonTester(expected, ordered = True)
tx_port = "tile[1]:XS1_PORT_4C"
@@ -42,9 +54,9 @@ def test_tx(capfd, config, build_midi):
]
simargs = ["--max-cycles", str(MAX_CYCLES)]
simargs = ["--max-cycles", str(MAX_CYCLES), "-o", "trace.txt"]
#This is just for local debug so we can capture the traces if needed. It slows xsim down so not needed
# simargs.extend(["--trace-to", "trace.txt", "--vcd-tracing", "-tile tile[1] -ports -o trace.vcd"])
# simargs.extend(["--vcd-tracing", "-tile tile[1] -ports -o trace.vcd"])
# with capfd.disabled(): # use to see xsim and tester output
Pyxsim.run_with_pyxsim(
@@ -56,4 +68,18 @@ def test_tx(capfd, config, build_midi):
capture = capfd.readouterr().out
result = tester.run(capture.split("\n"))
assert result, f"expected: {expected}\n capture: {capture}"
# Print to console
with capfd.disabled():
print("CAPTURE:", capture)
print("EXPECTED:", expected)
# Show tail of trace if there is an error
if not result:
with capfd.disabled():
print("Simulator trace tail:")
with open("trace.txt") as trace:
output = trace.readlines()
print("".join(output[-25:]))
assert result, f"expected: {expected}\n capture: {capture}"