|  |  |  | @ -1,6 +1,4 @@ | 
			
		
	
		
			
				
					|  |  |  |  | #!/usr/bin/env python3 | 
			
		
	
		
			
				
					|  |  |  |  | import os | 
			
		
	
		
			
				
					|  |  |  |  | import unittest | 
			
		
	
		
			
				
					|  |  |  |  | from parameterized import parameterized | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | from cereal import log, car | 
			
		
	
	
		
			
				
					|  |  |  | @ -36,10 +34,6 @@ CX5_FW_VERSIONS = [ | 
			
		
	
		
			
				
					|  |  |  |  |   (Ecu.transmission, 0x7e1, None, b'PYNC-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'), | 
			
		
	
		
			
				
					|  |  |  |  | ] | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | class TestStartup(unittest.TestCase): | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   def tearDown(self): | 
			
		
	
		
			
				
					|  |  |  |  |     managed_processes['controlsd'].stop() | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | @parameterized.expand([ | 
			
		
	
		
			
				
					|  |  |  |  |   # TODO: test EventName.startup for release branches | 
			
		
	
	
		
			
				
					|  |  |  | @ -64,7 +58,7 @@ class TestStartup(unittest.TestCase): | 
			
		
	
		
			
				
					|  |  |  |  |   (EventName.startupMaster, TOYOTA.COROLLA, COROLLA_FW_VERSIONS_FUZZY, "toyota"), | 
			
		
	
		
			
				
					|  |  |  |  |   (EventName.startupMaster, TOYOTA.COROLLA, COROLLA_FW_VERSIONS_FUZZY, "toyota"), | 
			
		
	
		
			
				
					|  |  |  |  | ]) | 
			
		
	
		
			
				
					|  |  |  |  |   def test_startup_alert(self, expected_event, car_model, fw_versions, brand): | 
			
		
	
		
			
				
					|  |  |  |  | def test_startup_alert(expected_event, car_model, fw_versions, brand): | 
			
		
	
		
			
				
					|  |  |  |  |   controls_sock = messaging.sub_sock("controlsState") | 
			
		
	
		
			
				
					|  |  |  |  |   pm = messaging.PubMaster(['can', 'pandaStates']) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -97,6 +91,7 @@ class TestStartup(unittest.TestCase): | 
			
		
	
		
			
				
					|  |  |  |  |   assert pm.wait_for_readers_to_update('can', 5) | 
			
		
	
		
			
				
					|  |  |  |  |   pm.send('can', can_list_to_can_capnp([[0, 0, b"", 0]])) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   assert pm.wait_for_readers_to_update('pandaStates', 5) | 
			
		
	
		
			
				
					|  |  |  |  |   msg = messaging.new_message('pandaStates', 1) | 
			
		
	
		
			
				
					|  |  |  |  |   msg.pandaStates[0].pandaType = log.PandaState.PandaType.uno | 
			
		
	
		
			
				
					|  |  |  |  |   pm.send('pandaStates', msg) | 
			
		
	
	
		
			
				
					|  |  |  | @ -114,16 +109,12 @@ class TestStartup(unittest.TestCase): | 
			
		
	
		
			
				
					|  |  |  |  |       params.put_bool("ObdMultiplexingChanged", True) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     pm.send('can', can_list_to_can_capnp(msgs)) | 
			
		
	
		
			
				
					|  |  |  |  |       assert pm.wait_for_readers_to_update('can', 2, dt=0.001) | 
			
		
	
		
			
				
					|  |  |  |  |     assert pm.wait_for_readers_to_update('can', 5, dt=0.001), f"step: {_}" | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     ctrls = messaging.drain_sock(controls_sock) | 
			
		
	
		
			
				
					|  |  |  |  |     if len(ctrls): | 
			
		
	
		
			
				
					|  |  |  |  |       event_name = ctrls[0].controlsState.alertType.split("/")[0] | 
			
		
	
		
			
				
					|  |  |  |  |         self.assertEqual(EVENT_NAME[expected_event], event_name, | 
			
		
	
		
			
				
					|  |  |  |  |                          f"expected {EVENT_NAME[expected_event]} for '{car_model}', got {event_name}") | 
			
		
	
		
			
				
					|  |  |  |  |       assert EVENT_NAME[expected_event] == event_name, f"expected {EVENT_NAME[expected_event]} for '{car_model}', got {event_name}" | 
			
		
	
		
			
				
					|  |  |  |  |       break | 
			
		
	
		
			
				
					|  |  |  |  |   else: | 
			
		
	
		
			
				
					|  |  |  |  |       self.fail(f"failed to fingerprint {car_model}") | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | if __name__ == "__main__": | 
			
		
	
		
			
				
					|  |  |  |  |   unittest.main() | 
			
		
	
		
			
				
					|  |  |  |  |     raise Exception(f"failed to fingerprint {car_model}") | 
			
		
	
	
		
			
				
					|  |  |  | 
 |