CI: speedup CAN FD tests (#1221)

speedup canfd

Co-authored-by: Bruce Wayne <batman@comma.ai>
This commit is contained in:
Adeeb Shihadeh
2023-01-22 16:47:59 -08:00
committed by GitHub
parent 97ad63b586
commit bf3791bdf2
2 changed files with 13 additions and 22 deletions

View File

@@ -18,23 +18,21 @@ DLC_TO_LEN = [0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 20, 24, 32, 48]
def panda_reset():
panda_serials = []
if JUNGLE_SERIAL:
panda_jungle = PandaJungle(JUNGLE_SERIAL)
panda_jungle.set_panda_power(False)
time.sleep(2)
panda_jungle.set_panda_power(True)
time.sleep(4)
panda_jungle = PandaJungle(JUNGLE_SERIAL)
panda_jungle.set_panda_power(False)
time.sleep(1)
panda_jungle.set_panda_power(True)
time.sleep(4)
for serial in Panda.list():
if serial not in H7_PANDAS_EXCLUDE:
with Panda(serial=serial) as p:
if p.get_type() in H7_HW_TYPES:
assert p.recover(timeout=30)
p.reset()
panda_serials.append(serial)
if len(panda_serials) < 2:
print("Minimum two H7 type pandas should be connected.")
assert False
print("test pandas", panda_serials)
assert len(panda_serials) == 2, "Two H7 pandas required"
return panda_serials
@@ -50,7 +48,7 @@ def panda_init(serial, enable_canfd=False, enable_non_iso=False):
return p
def canfd_test(p_send, p_recv):
for _ in range(100):
for n in range(100):
sent_msgs = defaultdict(set)
to_send = []
for _ in range(200):
@@ -63,8 +61,8 @@ def canfd_test(p_send, p_recv):
p_send.can_send_many(to_send, timeout=0)
start_time = time.time()
while time.time() - start_time < 1:
start_time = time.monotonic()
while (time.monotonic() - start_time < 1) and any(len(x) > 0 for x in sent_msgs.values()):
incoming = p_recv.can_recv()
for msg in incoming:
address, _, data, bus = msg
@@ -73,15 +71,8 @@ def canfd_test(p_send, p_recv):
sent_msgs[bus].discard(k)
for bus in range(3):
assert not len(sent_msgs[bus]), f"loop : bus {bus} missing {len(sent_msgs[bus])} messages"
assert not len(sent_msgs[bus]), f"loop {n}: bus {bus} missing {len(sent_msgs[bus])} messages"
# Set back to silent mode
p_send.set_safety_mode(Panda.SAFETY_SILENT)
p_recv.set_safety_mode(Panda.SAFETY_SILENT)
p_send.set_power_save(True)
p_recv.set_power_save(True)
p_send.close()
p_recv.close()
print("Got all messages intact")

View File

@@ -23,7 +23,7 @@ if __name__ == "__main__":
PandaDFU(serial).recover()
list(exc.map(recover, pandas, timeout=20))
r.cycle_power(delay=3, ports=[1, 2])
r.cycle_power(delay=7, ports=[1, 2])
pandas = Panda.list()
print(pandas)