mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-19 08:12:07 +08:00
c817cb942d
* timing test * test * fix * print * loop * clean up * wider range * Update selfdrive/car/tests/test_models.py * Apply suggestions from code review * run many times * Update selfdrive/car/tests/test_models.py * run for many its * run with unittest and print as list * Update .github/workflows/selfdrive_tests.yaml * Update .github/workflows/selfdrive_tests.yaml * total time is super inconsistent (body) * Update selfdrive/car/tests/test_models.py * clean up * clean up * clean up * this works! * draft * test suite not as modular * try something like this * can do kb, but not too representative * clean up * remove kb? it depends on signals * clean up * more clean up * rename * just measure all CANParsers * can do all this manually * but this is way simpler * comment * stash * draft * draft * remove old script * clean up * revert * use it * remove test * opt * no partial * remove * revert test_models * test can fingerprinting * so much simpler! * fix dict resizing * simplify * need to do this * fix * move to new file * rename * comment * ignore function-uses-loop-variable old-commit-hash: fd8f8d8785dd07777f150bd61c7ba9a0ed00d786
28 lines
1.0 KiB
Python
Executable File
28 lines
1.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
from parameterized import parameterized
|
|
import unittest
|
|
|
|
from cereal import log, messaging
|
|
from selfdrive.car.car_helpers import can_fingerprint
|
|
from selfdrive.car.fingerprints import _FINGERPRINTS as FINGERPRINTS
|
|
|
|
|
|
class TestCanFingerprint(unittest.TestCase):
|
|
@parameterized.expand([(c, f) for c, f in FINGERPRINTS.items()])
|
|
def test_can_fingerprint(self, car_model, fingerprints):
|
|
# Tests online fingerprinting function on offline fingerprints
|
|
for fingerprint in fingerprints: # can have multiple fingerprints for each platform
|
|
can = messaging.new_message('can', 1)
|
|
can.can = [log.CanData(address=address, dat=b'\x00' * length)
|
|
for address, length in fingerprint.items()]
|
|
|
|
fingerprint_iter = iter([can])
|
|
empty_can = messaging.new_message('can', 0)
|
|
car_fingerprint, finger = can_fingerprint(lambda: next(fingerprint_iter, empty_can)) # noqa: B023
|
|
|
|
self.assertEqual(car_fingerprint, car_model)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|