Initial passing tx test using pyxsim

This commit is contained in:
Ed
2024-04-15 17:32:03 +01:00
parent 4e4ae01a35
commit 977408d3bf
4 changed files with 104 additions and 56 deletions

View File

@@ -23,11 +23,23 @@ class Midi_expect:
def __init(self):
pass
def expect(self):
expected = "Hello"
def expect(self, commands):
expected = ""
for command in commands:
while len(command) < 3:
command.append(0)
expected += "uart_tx_checker: " + " ".join([f"0x{byte:02x}" for byte in command]) + "\n"
return expected
def create_midi_tx_file(commands):
with open("midi_tx_cmds.txt", "wt") as mt:
for command in commands:
while len(command) < 3:
command.append(0)
text = " ".join([str(byte) for byte in command]) + "\n"
mt.write(text)
#####
# This test builds the spdif transmitter app with a verity of presets and tests that the output matches those presets
@@ -36,17 +48,16 @@ class Midi_expect:
def test_tx(capfd, config):
xe = str(Path(__file__).parent / f"test_midi/bin/{config}/test_midi_{config}.xe")
p_midi_out = "tile[1]:XS1_PORT_4C"
# tester = testers.ComparisonTester(
# Frames(channels=audio, no_of_blocks=no_of_blocks, sam_freq=sam_freq).expect()[
# : no_of_samples * len(audio)
# ]
# )
tester = testers.ComparisonTester(Midi_expect().expect())
midi_commands = [[0x90, 60, 81]]
create_midi_tx_file(midi_commands)
tester = testers.ComparisonTester(Midi_expect().expect(midi_commands),
regexp = "uart_tx_checker:.+",
ordered = True)
tx_port = "tile[1]:XS1_PORT_4C"
rx_port = None
baud = MIDI_RATE
bpb = 8
parity = 0
@@ -54,11 +65,11 @@ def test_tx(capfd, config):
length_of_test = 3 # characters
simthreads = [
# UARTTxChecker(rx_port, tx_port, parity, baud, length_of_test, stop, bpb)
UARTTxChecker(tx_port, parity, baud, length_of_test, stop, bpb, debug=False)
]
simargs = ["--max-cycles", str(MAX_CYCLES)]
simargs.extend(["--trace-to", "trace.txt", "--vcd-tracing", "-tile tile[1] -ports -o trace.vcd"]) #This is just for local debug so we can capture the run, pass as kwarg to run_with_pyxsim
# simargs.extend(["--trace-to", "trace.txt", "--vcd-tracing", "-tile tile[1] -ports -o trace.vcd"]) #This is just for local debug so we can capture the run, pass as kwarg to run_with_pyxsim
# result = Pyxsim.run_on_simulator(
result = Pyxsim.run_on_simulator(
@@ -68,9 +79,9 @@ def test_tx(capfd, config):
# clean_before_build=True,
clean_before_build=False,
tester=tester,
# capfd=capfd,
capfd=None,
timeout=1500,
capfd=capfd,
# capfd=None,
timeout=120,
simargs=simargs,
build_options=[
"-j",
@@ -80,4 +91,5 @@ def test_tx(capfd, config):
,
],
)
assert result