Skip to content

Commit

Permalink
CI: make bootkick test robust to health struct changes (commaai#1711)
Browse files Browse the repository at this point in the history
* CI: make bootkick test robust to health struct changes

* comment

* panda
  • Loading branch information
adeebshihadeh authored Nov 9, 2023
1 parent 3f25cca commit cd0f0bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions tests/som/on-device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 7 additions & 1 deletion tests/som/test_bootkick.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import time
import pytest
import datetime

from panda import Panda, PandaJungle

Expand All @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit cd0f0bd

Please sign in to comment.