test_ford: test_platform_codes_fuzzy_fw

pull/31124/head
Cameron Clough 2 years ago
parent 5356b39b4a
commit 1055cb02f0
  1. 13
      selfdrive/car/ford/tests/test_ford.py

@ -1,12 +1,13 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import unittest import unittest
from parameterized import parameterized
from typing import Dict, Iterable, Optional, Tuple from typing import Dict, Iterable, Optional, Tuple
import capnp import capnp
from parameterized import parameterized
from hypothesis import settings, given, strategies as st
from cereal import car from cereal import car
from openpilot.selfdrive.car.ford.values import FW_QUERY_CONFIG from openpilot.selfdrive.car.ford.values import FW_QUERY_CONFIG, get_platform_codes
from openpilot.selfdrive.car.ford.fingerprints import FW_VERSIONS from openpilot.selfdrive.car.ford.fingerprints import FW_VERSIONS
Ecu = car.CarParams.Ecu Ecu = car.CarParams.Ecu
@ -76,6 +77,14 @@ class TestFordFW(unittest.TestCase):
self.assertIn(core, ECU_FW_CORE[ecu], f"Unexpected FW core for {ecu}") self.assertIn(core, ECU_FW_CORE[ecu], f"Unexpected FW core for {ecu}")
self.assertIn(len(suffix), (2, 3), "Expected FW suffix to be 2-3 characters") self.assertIn(len(suffix), (2, 3), "Expected FW suffix to be 2-3 characters")
@settings(max_examples=100)
@given(data=st.data())
def test_platform_codes_fuzzy_fw(self, data):
"""Ensure function doesn't raise an exception"""
fw_strategy = st.lists(st.binary())
fws = data.draw(fw_strategy)
get_platform_codes(fws)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

Loading…
Cancel
Save