tests: Add tests for 0.0 IIO offsets

Test both parts of iioutils_get_param_float() for 0.0 readings.
This commit is contained in:
Bastien Nocera
2021-08-16 14:27:01 +02:00
parent 8980b8b74f
commit f42263d434

View File

@@ -558,6 +558,7 @@ class Tests(dbusmock.DBusTestCase):
'buffer/enable', '0',
'trigger/current_trigger', '',
'in_accel_scale', '0.000010\n',
'in_accel_offset', '0.0\n',
'in_accel_mount_matrix', '1, 0, 0; 0, 1, 0; 0, 0, 1\n',
'scan_elements/in_accel_x_en', '0',
'scan_elements/in_accel_x_index', '0',
@@ -595,6 +596,45 @@ class Tests(dbusmock.DBusTestCase):
self.stop_daemon()
def test_iio_scale_decimal_separator_offset(self):
'''scale decimal separator with specific offset'''
top_srcdir = os.getenv('top_srcdir', '.')
mock_dev_data = self.testbed.get_root_dir() + '/iio-dev-data.bin'
accel = self.testbed.add_device('iio', 'iio-buffer-accel0', None,
['name', 'IIO Test Accelerometer',
'buffer/enable', '0',
'trigger/current_trigger', '',
'in_accel_scale', '0.000010\n',
'in_accel_x_offset', '0.0\n',
'in_accel_mount_matrix', '1, 0, 0; 0, 1, 0; 0, 0, 1\n',
'scan_elements/in_accel_x_en', '0',
'scan_elements/in_accel_x_index', '0',
'scan_elements/in_accel_x_type', 'le:s16/32>>0',
'scan_elements/in_accel_y_en', '0',
'scan_elements/in_accel_y_index', '1',
'scan_elements/in_accel_y_type', 'le:s16/32>>0',
'scan_elements/in_accel_z_en', '0',
'scan_elements/in_accel_z_index', '2',
'scan_elements/in_accel_z_type', 'le:s16/32>>0',
'scan_elements/in_timestamp_en', '1',
'scan_elements/in_timestamp_index', '3',
'scan_elements/in_timestamp_type', 'le:s64/64>>0'],
['NAME', '"IIO Accelerometer"',
'DEVNAME', '/dev/iio-buffer-accel-test',
'IIO_SENSOR_PROXY_TYPE', 'iio-buffer-accel']
)
trigger = self.testbed.add_device('iio', 'trigger0', None,
['name', 'accel_3d-dev0'],
[]
)
env = os.environ.copy()
env['LC_NUMERIC'] = 'fr_FR.UTF-8'
self.start_daemon(env=env)
self.assertEqual(self.get_dbus_property('HasAccelerometer'), True)
self.stop_daemon()
def test_iio_scale_decimal_separator2(self):
'''scale decimal separator polling'''
accel = self.testbed.add_device('iio', 'iio-accel', None,