rtio/sed: add replace unittest at the top level (#978)

This commit is contained in:
Sebastien Bourdeauducq 2018-05-02 10:58:18 +08:00
parent 83fb431cd0
commit bce8fa3ec5

View File

@ -73,7 +73,7 @@ def simulate(input_events):
run_simulation(dut, {"sys": [
gen(), monitor(),
(None for _ in range(45))
(None for _ in range(max(ts for ts, _ in input_events) + 15))
]}, {"sys": 5, "rio": 5, "rio_phy": 5})
return ttl_changes, access_results
@ -86,3 +86,16 @@ class TestSED(unittest.TestCase):
ttl_changes, access_results = simulate(input_events)
self.assertEqual(ttl_changes, [e[0] + latency for e in input_events])
self.assertEqual(access_results, [("ok", 0)]*len(input_events))
def test_replace(self):
input_events = []
now = 19
for i in range(5):
now += 10
input_events += [(now, 1)]
now += 10
input_events += [(now, 1), (now, 0)]
ttl_changes, access_results = simulate(input_events)
self.assertEqual(ttl_changes, list(range(40, 140, 10)))
self.assertEqual(access_results, [("ok", 0)]*len(input_events))