From 2d7fb9a715d8c9f1f7ba73a62cfd587fa6ffc24a Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 30 Jan 2024 12:44:25 +1100 Subject: [PATCH] tests/ports/rp2/rp2_dma.py: Tweak test to be more reliable. The timing of the DMA transfer can vary a bit, so tweak the allowed values. Also test the return value of `rp2.DMA.irq.flags()` to make sure the IRQ is correctly signalled. Signed-off-by: Damien George --- tests/ports/rp2/rp2_dma.py | 4 ++-- tests/ports/rp2/rp2_dma.py.exp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ports/rp2/rp2_dma.py b/tests/ports/rp2/rp2_dma.py index cd97f0357b..2459213f4c 100644 --- a/tests/ports/rp2/rp2_dma.py +++ b/tests/ports/rp2/rp2_dma.py @@ -62,7 +62,7 @@ dma.write = dest dma.count = len(dest) // 4 dma.ctrl = dma.pack_ctrl() dt = run_and_time_dma(dma) -print(60 <= dt <= 90) +print(70 <= dt <= 110) print(dest[:8], dest[-8:]) dma.close() @@ -80,7 +80,7 @@ dma.close() print("# test irq") dest = bytearray(1024) dma = rp2.DMA() -dma.irq(lambda _: print("irq fired")) +dma.irq(lambda dma: print("irq fired", dma.irq().flags())) dma.config( read=src, write=dest, count=len(dest) // 4, ctrl=dma.pack_ctrl(irq_quiet=0), trigger=True ) diff --git a/tests/ports/rp2/rp2_dma.py.exp b/tests/ports/rp2/rp2_dma.py.exp index 956aee4e34..79f17626ac 100644 --- a/tests/ports/rp2/rp2_dma.py.exp +++ b/tests/ports/rp2/rp2_dma.py.exp @@ -12,5 +12,5 @@ bytearray(b'\x00\x01\x02\x03\x04\x05\x06\x07') bytearray(b'\xf8\xf9\xfa\xfb\xfc\ # test immediate trigger bytearray(b'\x00\x01\x02\x03\x04\x05\x06\x07') bytearray(b'\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff') # test irq -irq fired +irq fired 1 bytearray(b'\x00\x01\x02\x03\x04\x05\x06\x07') bytearray(b'\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff')