summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtest/hil/hil_flash.py11
-rw-r--r--test/hil/test/test_hil_select.py32
2 files changed, 30 insertions, 13 deletions
diff --git a/test/hil/hil_flash.py b/test/hil/hil_flash.py
index 26d13e6ff..579da3f37 100755
--- a/test/hil/hil_flash.py
+++ b/test/hil/hil_flash.py
@@ -100,10 +100,14 @@ def _openocd_cmd_base(flasher):
print(f'warning: {uid} has a malformed vid_pid {flasher["vid_pid"]!r} '
f'(want "0xVVVV 0xPPPP"); probe pin DROPPED, so discovery will open '
f'foreign usbfs nodes', file=sys.stderr, flush=True)
- elif flasher.get('uid') not in _VID_PID_WARNED:
+ elif ('interface/jlink.cfg' not in (flasher.get('args') or '')
+ and flasher.get('uid') not in _VID_PID_WARNED):
# stderr, once per probe: test_example captures stdout, so a passing run would
# swallow this and the operator would never learn discovery still opens every
- # usbfs node
+ # usbfs node. Skipped over the jlink driver: libjaylink discovery gates on
+ # idVendor == 0x1366 before libusb_open (same rationale as convoy_safe's
+ # docstring), so it never opens a foreign node regardless of the missing pin --
+ # the warning would be false there.
_VID_PID_WARNED.add(flasher.get('uid'))
print(f'warning: openocd flasher {flasher.get("uid", "?")} has no vid_pid pin; '
f'probe discovery will open every usbfs node (hangs on a wedged one)',
@@ -149,6 +153,9 @@ def flash_openocd_seq(board, firmware, timeout=None):
def reset_openocd_seq(board, timeout=None):
+ # Behaviorally reset_openocd, but this exact invocation is what was bench-validated
+ # over the jlink transport on all seven flasher_recover boards — don't fold into
+ # reset_openocd (or change either) without re-benching the recovery path.
flasher = board['flasher']
return hil_util.run_cmd(
f'{_openocd_cmd_base(flasher)} -c "init" -c "reset run" -c "shutdown"',
diff --git a/test/hil/test/test_hil_select.py b/test/hil/test/test_hil_select.py
index e174a95c2..e5350a02b 100644
--- a/test/hil/test/test_hil_select.py
+++ b/test/hil/test/test_hil_select.py
@@ -638,20 +638,28 @@ class TestRosterFlashersDispatch(unittest.TestCase):
def test_flash_and_reset_exist_for_every_roster_flasher(self):
for path, board in roster_flashers():
- name = board['flasher']['name'].lower()
- for fn in (f'flash_{name}', f'reset_{name}'):
- self.assertTrue(callable(getattr(hil_flash, fn, None)),
- f'{path}: {board["name"]} uses flasher "{name}" '
- f'but hil_flash.{fn} does not exist')
+ flashers = [board['flasher']]
+ if board.get('flasher_recover'):
+ flashers.append(board['flasher_recover'])
+ for f in flashers:
+ name = f['name'].lower()
+ for fn in (f'flash_{name}', f'reset_{name}'):
+ self.assertTrue(callable(getattr(hil_flash, fn, None)),
+ f'{path}: {board["name"]} uses flasher "{name}" '
+ f'but hil_flash.{fn} does not exist')
def test_firmware_suffix_known_for_every_roster_flasher(self):
"""find_firmware falls back to accepting .elf-or-.bin when a flasher is missing
from FLASHER_SUFFIX, silently restoring the mismatch that map exists to catch."""
for path, board in roster_flashers():
- name = board['flasher']['name'].lower()
- self.assertIn(name, hil_flash.FLASHER_SUFFIX,
- f'{path}: {board["name"]} uses flasher "{name}" '
- f'with no hil_flash.FLASHER_SUFFIX entry')
+ flashers = [board['flasher']]
+ if board.get('flasher_recover'):
+ flashers.append(board['flasher_recover'])
+ for f in flashers:
+ name = f['name'].lower()
+ self.assertIn(name, hil_flash.FLASHER_SUFFIX,
+ f'{path}: {board["name"]} uses flasher "{name}" '
+ f'with no hil_flash.FLASHER_SUFFIX entry')
class FlasherRecoverEntry(unittest.TestCase):
@@ -694,7 +702,7 @@ class FlasherRecoverEntry(unittest.TestCase):
from helper import hil_util
seen = {}
real = hil_util.run_cmd
- hil_util.run_cmd = lambda cmd, **k: seen.setdefault('cmd', cmd) or real('true')
+ hil_util.run_cmd = lambda cmd, **k: seen.setdefault('cmd', cmd)
try:
hil_flash.flash_openocd_seq(
{'flasher': {'name': 'openocd_seq', 'uid': 'X', 'vid_pid': '0x1366 0x0101',
@@ -713,8 +721,10 @@ class FlasherRecoverEntry(unittest.TestCase):
for b in recover:
f = b['flasher_recover']
self.assertEqual(f['name'], 'openocd_seq', b['name'])
+ self.assertEqual(f['uid'], b['flasher']['uid'], b['name'])
self.assertIn('interface/jlink.cfg', f['args'], b['name'])
- self.assertIn('adapter speed', f['args'], b['name']) # required; see below
+ # examination fails outright on the jlink driver without `adapter speed`
+ self.assertIn('adapter speed', f['args'], b['name'])
self.assertTrue(hil_flash.convoy_safe(f), b['name'])