tb: axis_mii_tx.py: Rework test_underflow

This test has a lot of duplication, which makes it harder to modify.
Stick most of it in a loop.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
This commit is contained in:
Sean Anderson 2023-01-11 17:26:20 -05:00
parent 68751229a0
commit a3ae038f4f
1 changed files with 19 additions and 23 deletions

View File

@ -216,29 +216,25 @@ async def test_underflow(mac):
send, status = await start(mac, range(32), ratio=30)
await underflow(mac, send, status)
send, status = await start(mac, [*range(56), None])
await underflow(mac, send, status)
send, status = await start(mac, [*range(58), None])
await underflow(mac, send, status)
send, status = await start(mac, [*range(60), None])
#from math import floor
# Solution to (IPG + PREAMBLE + x) * BIT_TIME = ratio * x
# end = floor(200 / (ratio - 10))
for x in (56, 58, 60):
# Error on last byte
send, status = await start(mac, [*range(x), None])
await underflow(mac, send, status)
send, status = await start(mac, [*range(56), None, 1])
await underflow(mac, send, status)
send, status = await start(mac, [*range(58), None, 1])
await underflow(mac, send, status)
send, status = await start(mac, [*range(60), None, 1])
# Error with more to come
send, status = await start(mac, [*range(x), None, 1])
await underflow(mac, send, status)
send, status = await start(mac, [*range(56), None])
await restart(mac, (8 + 55) * BYTE_TIME_NS)
# Underflow with collision
send, status = await start(mac, [*range(x), None])
await restart(mac, (8 + x) * BYTE_TIME_NS - 1)
if x <= 56:
await underflow(mac, send, status)
send, status = await start(mac, [*range(58), None])
await restart(mac, (8 + 57) * BYTE_TIME_NS)
await send.join()
assert await status.join() == Status.LATE_COLLISION
send, status = await start(mac, [*range(60), None])
await restart(mac, (8 + 59) * BYTE_TIME_NS)
else:
await send.join()
assert await status.join() == Status.LATE_COLLISION