Skip to content

Commit

Permalink
fix blocked msgs test
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Apr 23, 2022
1 parent 908c1be commit 43f20d7
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions selfdrive/car/verify_car_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,12 @@ def verify_route(route_name):
print("---\nSUCCESS: All tests passed")


def test_blocked_msgs(lr):
pandaStates = None
for msg in list(lr)[::-1]:
if msg.which() == "pandaStates":
pandaStates = msg.pandaStates

assert pandaStates is not None and len(pandaStates), "No pandaStates packets, or list empty"
assert pandaStates[0].blockedCnt < 10, "Blocked messages {} is not less than 10".format(pandaStates[0].blockedCnt)
print('SUCCESS: Blocked messages under threshold: {} < 10'.format(pandaStates[0].blockedCnt))


def _test_fingerprint(CP):
"""
If make has FW_VERSIONS defined, then assert fingerprint source is fw
Else, just check it's not fixed
"""
# TODO: run on car params and make sure fp matches logs

fw_versions = get_interface_attr("FW_VERSIONS")[CP.carName]
has_fw_versions = fw_versions is not None and len(fw_versions)
Expand All @@ -69,6 +59,19 @@ def _test_fingerprint(CP):
print('SUCCESS: Fingerprinted: {}'.format(CP.carFingerprint))


def test_blocked_msgs(lr):
for msg in list(lr)[::-1]:
if msg.which() == "pandaStates":
if msg.pandaStates[0].ignitionCan or msg.pandaStates[0].ignitionLine:
pandaStates = msg.pandaStates
break
else:
assert False, "No pandaStates packets"

assert pandaStates[0].blockedCnt < 10, "Blocked messages {} is not less than 10".format(pandaStates[0].blockedCnt)
print('SUCCESS: Blocked messages under threshold: {} < 10'.format(pandaStates[0].blockedCnt))


def test_car_params(lr):
"""
Common carParams tests
Expand Down

0 comments on commit 43f20d7

Please sign in to comment.