Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
IO_DEBUG(
IO_DEBUG_test_unsigned: 1,
IO_DEBUG_test_enum: 'IO_DEBUG_test2_enum_two',
IO_DEBUG_test_signed: 3,
IO_DEBUG_test_float: 2.0
)
vcan0 1F4 [3] 01 02 03 :: unpack requires at least 32 bits to unpack (got 24)
vcan0 1F3 [3] 01 02 03 :: Unknown frame id 499 (0x1f3)
"""
stdout = StringIO()
with patch('sys.stdin', StringIO(input_data)):
with patch('sys.stdout', stdout):
with patch('sys.argv', argv):
cantools._main()
actual_output = stdout.getvalue()
self.assertEqual(actual_output, expected_output)
fuzzer_mk = basename + '_fuzzer.mk'
if os.path.exists(database_h):
os.remove(database_h)
if os.path.exists(database_c):
os.remove(database_c)
if os.path.exists(fuzzer_c):
os.remove(fuzzer_c)
if os.path.exists(fuzzer_mk):
os.remove(fuzzer_mk)
with patch('sys.argv', argv):
cantools._main()
if sys.version_info[0] > 2:
self.assert_files_equal(database_h,
'tests/files/c_source/' + database_h)
self.assert_files_equal(database_c,
'tests/files/c_source/' + database_c)
self.assertFalse(os.path.exists(fuzzer_c))
self.assertFalse(os.path.exists(fuzzer_mk))
MODULE_TEMP_34: 23066
)
vcan0 401 [6] 23 00 59 99 5C 5A ::
BATTERY_VT(
BATTERY_VT_INDEX: 35,
MODULE_VOLTAGE_35: 39257,
MODULE_TEMP_35: 23132
)
"""
stdout = StringIO()
with patch('sys.stdin', StringIO(input_data)):
with patch('sys.stdout', stdout):
with patch('sys.argv', argv):
cantools._main()
actual_output = stdout.getvalue()
self.assertEqual(actual_output, expected_output)
t +-- signal_without_sender
e
Signal tree:
-- {root}
+-- signal_without_sender
------------------------------------------------------------------------
"""
stdout = StringIO()
with patch('sys.stdout', stdout):
with patch('sys.argv', argv):
cantools._main()
actual_output = stdout.getvalue()
self.assertEqual(actual_output, expected_output)
expected_output = """\
vcan0 0C8 [8] F0 00 00 00 00 00 00 00 :: SENSOR_SONARS(SENSOR_SONARS_mux: 0, SENSOR_SONARS_err_count: 15, SENSOR_SONARS_left: 0.0, SENSOR_SONARS_middle: 0.0, SENSOR_SONARS_right: 0.0, SENSOR_SONARS_rear: 0.0)
vcan0 064 [10] F0 01 FF FF FF FF FF FF FF FF :: DRIVER_HEARTBEAT(DRIVER_HEARTBEAT_cmd: 240)
vcan0 ERROR
vcan0 1F4 [4] 01 02 03 04 :: IO_DEBUG(IO_DEBUG_test_unsigned: 1, IO_DEBUG_test_enum: 'IO_DEBUG_test2_enum_two', IO_DEBUG_test_signed: 3, IO_DEBUG_test_float: 2.0)
vcan0 1F4 [3] 01 02 03 :: unpack requires at least 32 bits to unpack (got 24)
vcan0 1F3 [3] 01 02 03 :: Unknown frame id 499 (0x1f3)
"""
stdout = StringIO()
with patch('sys.stdin', StringIO(input_data)):
with patch('sys.stdout', stdout):
with patch('sys.argv', argv):
cantools._main()
actual_output = stdout.getvalue()
self.assertEqual(actual_output, expected_output)
'--bit-fields',
'--database-name', '{}_bit_fields'.format(database),
'tests/files/dbc/{}.dbc'.format(database)
]
database_h = database + '_bit_fields.h'
database_c = database + '_bit_fields.c'
if os.path.exists(database_h):
os.remove(database_h)
if os.path.exists(database_c):
os.remove(database_c)
with patch('sys.argv', argv):
cantools._main()
if sys.version_info[0] > 2:
self.assert_files_equal(database_h,
'tests/files/c_source/' + database_h)
self.assert_files_equal(database_c,
'tests/files/c_source/' + database_c)
fuzzer_mk = basename + '_fuzzer.mk'
if os.path.exists(database_h):
os.remove(database_h)
if os.path.exists(database_c):
os.remove(database_c)
if os.path.exists(fuzzer_c):
os.remove(fuzzer_c)
if os.path.exists(fuzzer_mk):
os.remove(fuzzer_mk)
with patch('sys.argv', argv):
cantools._main()
if sys.version_info[0] > 2:
self.assert_files_equal(database_h,
'tests/files/c_source/' + database_h)
self.assert_files_equal(database_c,
'tests/files/c_source/' + database_c)
self.assertFalse(os.path.exists(fuzzer_c))
self.assertFalse(os.path.exists(fuzzer_mk))
t +-- signal_without_sender
e
Signal tree:
-- {root}
+-- signal_without_sender
------------------------------------------------------------------------
"""
stdout = StringIO()
with patch('sys.stdout', stdout):
with patch('sys.argv', argv):
cantools._main()
actual_output = stdout.getvalue()
self.assertEqual(actual_output, expected_output)
vcan0 401 [6] 1C 00 7E 99 50 5A :: BATTERY_VT(BATTERY_VT_INDEX: 28, MODULE_VOLTAGE_28: 39294, MODULE_TEMP_28: 23120)
vcan0 401 [6] 1D 00 39 9A 21 5A :: BATTERY_VT(BATTERY_VT_INDEX: 29, MODULE_VOLTAGE_29: 39481, MODULE_TEMP_29: 23073)
vcan0 401 [6] 1E 00 44 99 F9 59 :: BATTERY_VT(BATTERY_VT_INDEX: 30, MODULE_VOLTAGE_30: 39236, MODULE_TEMP_30: 23033)
vcan0 401 [6] 1F 00 60 99 1B 5A :: BATTERY_VT(BATTERY_VT_INDEX: 31, MODULE_VOLTAGE_31: 39264, MODULE_TEMP_31: 23067)
vcan0 401 [6] 20 00 42 99 0A 5A :: BATTERY_VT(BATTERY_VT_INDEX: 32, MODULE_VOLTAGE_32: 39234, MODULE_TEMP_32: 23050)
vcan0 401 [6] 21 00 C3 9A 33 5A :: BATTERY_VT(BATTERY_VT_INDEX: 33, MODULE_VOLTAGE_33: 39619, MODULE_TEMP_33: 23091)
vcan0 401 [6] 22 00 3D 99 1A 5A :: BATTERY_VT(BATTERY_VT_INDEX: 34, MODULE_VOLTAGE_34: 39229, MODULE_TEMP_34: 23066)
vcan0 401 [6] 23 00 59 99 5C 5A :: BATTERY_VT(BATTERY_VT_INDEX: 35, MODULE_VOLTAGE_35: 39257, MODULE_TEMP_35: 23132)
"""
stdout = StringIO()
with patch('sys.stdin', StringIO(input_data)):
with patch('sys.stdout', stdout):
with patch('sys.argv', argv):
cantools._main()
actual_output = stdout.getvalue()
self.assertEqual(actual_output, expected_output)
'tests/files/dbc/{}.dbc'.format(database)
]
database_h = database + '.h'
database_c = database + '.c'
expected_database_h = database + '_no_floating_point_numbers.h'
expected_database_c = database + '_no_floating_point_numbers.c'
if os.path.exists(database_h):
os.remove(database_h)
if os.path.exists(database_c):
os.remove(database_c)
with patch('sys.argv', argv):
cantools._main()
if sys.version_info[0] > 2:
self.assert_files_equal(
database_h,
'tests/files/c_source/' + expected_database_h)
self.assert_files_equal(
database_c,
'tests/files/c_source/' + expected_database_c)