Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Jun 30, 2023
1 parent e51a787 commit dec691b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions can/tests/test_packer_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import unittest
import random
from functools import partial

import cereal.messaging as messaging
from opendbc.can.parser import CANParser
Expand Down Expand Up @@ -317,6 +318,18 @@ def test_timestamp_nanos(self):
ts_nanos = parser.ts_nanos["POWERTRAIN_DATA"].values()
self.assertEqual(set(ts_nanos), {0})

def test_undefined_signals(self):
# Ensure we don't allow messages not in the DBC
existing_signals = {"STEERING_CONTROL": ["STEER_TORQUE_REQUEST", "SET_ME_X00_2", "COUNTER"],
"CAN_FD_MESSAGE": ["SIGNED", "64_BIT_LE", "64_BIT_BE", "COUNTER"]}

for msg, sigs in existing_signals.items():
for sig in sigs:
CANParser(TEST_DBC, [(sig, msg)], [(msg, 0)])
self.assertRaises(RuntimeError, partial(CANParser, TEST_DBC, [(sig, msg + "123")], [(msg, 0)]))
self.assertRaises(RuntimeError, partial(CANParser, TEST_DBC, [(sig, msg)], [(msg + "123", 0)]))
self.assertRaises(RuntimeError, partial(CANParser, TEST_DBC, [(sig, msg + "123")], [(msg + "123", 0)]))


if __name__ == "__main__":
unittest.main()

0 comments on commit dec691b

Please sign in to comment.