From cd0f0bd034dde6814b4f5aa12da96a6f5631d141 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 8 Nov 2023 16:46:41 -0800 Subject: [PATCH] CI: make bootkick test robust to health struct changes (#1711) * CI: make bootkick test robust to health struct changes * comment * panda --- tests/som/on-device.py | 7 ++++--- tests/som/test_bootkick.py | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/som/on-device.py b/tests/som/on-device.py index c630e4e24d..f88d5a99bb 100755 --- a/tests/som/on-device.py +++ b/tests/som/on-device.py @@ -16,8 +16,9 @@ flag_set = True # shutdown when told - if p.health()['safety_mode'] == Panda.SAFETY_SILENT: + dt = p.get_datetime() + if dt.year == 2040 and dt.month == 8: os.system("sudo poweroff") - except Exception: - pass + except Exception as e: + print(str(e)) time.sleep(0.5) diff --git a/tests/som/test_bootkick.py b/tests/som/test_bootkick.py index 92441f7dc9..f55b93c5b4 100644 --- a/tests/som/test_bootkick.py +++ b/tests/som/test_bootkick.py @@ -1,5 +1,6 @@ import time import pytest +import datetime from panda import Panda, PandaJungle @@ -23,6 +24,8 @@ def pj(): @pytest.fixture(scope="function") def p(pj): + # note that the 3X's panda lib isn't updated, which + # shold be fine since it only uses stable APIs pj.set_panda_power(True) assert Panda.wait_for_panda(PANDA_SERIAL, 10) p = Panda(PANDA_SERIAL) @@ -46,7 +49,7 @@ def setup_state(panda, jungle, state): wait_for_full_poweroff(jungle) jungle.set_panda_individual_power(OBDC_PORT, 1) wait_for_boot(panda, jungle) - panda.set_safety_mode(Panda.SAFETY_SILENT) + set_som_shutdown_flag(panda) panda.send_heartbeat() wait_for_som_shutdown(panda, jungle) else: @@ -78,6 +81,9 @@ def check_som_boot_flag(panda): h = panda.health() return h['safety_mode'] == Panda.SAFETY_ELM327 and h['safety_param'] == 30 +def set_som_shutdown_flag(panda): + panda.set_datetime(datetime.datetime(year=2040, month=8, day=23)) + def wait_for_boot(panda, jungle, bootkick=False, timeout=120): st = time.monotonic()