diff options
author | Yuval Peress <peress@chromium.org> | 2021-05-04 12:21:35 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-05-05 07:03:52 +0000 |
commit | 191e710f5452e27426db5c2a4f8f43fc35528bf2 (patch) | |
tree | ee6a2ade79460136f3cc6bd2e51a27dba9499801 /test/motion_sense_fifo.c | |
parent | 47546a1431877e82d82405e1a830e1f48ca1b04e (diff) | |
download | chrome-ec-191e710f5452e27426db5c2a4f8f43fc35528bf2.tar.gz |
test: motionsense fifo: Fix time units
Convert time units in the test from ns to us
BRANCH=none
BUG=none
TEST=make run-motion_sense_fifo
Signed-off-by: Yuval Peress <peress@chromium.org>
Change-Id: I345ce43945d2bcd743347296430d76c2992a953a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2871056
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'test/motion_sense_fifo.c')
-rw-r--r-- | test/motion_sense_fifo.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/test/motion_sense_fifo.c b/test/motion_sense_fifo.c index c75cbe3c35..b20eb9a36f 100644 --- a/test/motion_sense_fifo.c +++ b/test/motion_sense_fifo.c @@ -249,17 +249,17 @@ static int test_spread_data_in_window(void) int read_count; motion_sensors[0].oversampling_ratio = 1; - motion_sensors[0].collection_rate = 20000; /* ns */ + motion_sensors[0].collection_rate = 20; /* us */ now = __hw_clock_source_read(); - motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 18000); - motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 18000); + motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 18); + motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 18); motion_sense_fifo_commit_data(); read_count = motion_sense_fifo_read( sizeof(data), CONFIG_ACCEL_FIFO_SIZE, data, &data_bytes_read); TEST_EQ(read_count, 4, "%d"); TEST_BITS_SET(data[0].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[0].timestamp, now - 18000, "%u"); + TEST_EQ(data[0].timestamp, now - 18, "%u"); TEST_BITS_SET(data[2].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); /* TODO(b/142892004): mock __hw_clock_source_read so we can check for * exact TS. @@ -275,17 +275,17 @@ static int test_spread_data_by_collection_rate(void) int read_count; motion_sensors[0].oversampling_ratio = 1; - motion_sensors[0].collection_rate = 20000; /* ns */ - motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 20500); - motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 20500); + motion_sensors[0].collection_rate = 20; /* us */ + motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 25); + motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 25); motion_sense_fifo_commit_data(); read_count = motion_sense_fifo_read( sizeof(data), CONFIG_ACCEL_FIFO_SIZE, data, &data_bytes_read); TEST_EQ(read_count, 4, "%d"); TEST_BITS_SET(data[0].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[0].timestamp, now - 20500, "%u"); + TEST_EQ(data[0].timestamp, now - 25, "%u"); TEST_BITS_SET(data[2].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[2].timestamp, now - 500, "%u"); + TEST_EQ(data[2].timestamp, now - 5, "%u"); return EC_SUCCESS; } @@ -302,19 +302,19 @@ static int test_spread_double_commit_same_timestamp(void) * allow the same timestamp to be sent. */ motion_sensors[0].oversampling_ratio = 1; - motion_sensors[0].collection_rate = 20000; /* ns */ - motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 20500); + motion_sensors[0].collection_rate = 20; /* us */ + motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 25); motion_sense_fifo_commit_data(); - motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 20500); + motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 25); motion_sense_fifo_commit_data(); read_count = motion_sense_fifo_read( sizeof(data), CONFIG_ACCEL_FIFO_SIZE, data, &data_bytes_read); TEST_EQ(read_count, 4, "%d"); TEST_BITS_SET(data[0].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[0].timestamp, now - 20500, "%u"); + TEST_EQ(data[0].timestamp, now - 25, "%u"); TEST_BITS_SET(data[2].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[2].timestamp, now - 20500, "%u"); + TEST_EQ(data[2].timestamp, now - 25, "%u"); return EC_SUCCESS; } @@ -325,25 +325,25 @@ static int test_commit_non_data_or_timestamp_entries(void) int read_count; motion_sensors[0].oversampling_ratio = 1; - motion_sensors[0].collection_rate = 20000; /* ns */ + motion_sensors[0].collection_rate = 20; /* us */ /* Insert non-data entry */ data[0].flags = MOTIONSENSE_SENSOR_FLAG_ODR; - motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 20500); + motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 25); /* Insert data entry */ data[0].flags = 0; - motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 20500); + motion_sense_fifo_stage_data(data, motion_sensors, 3, now - 25); motion_sense_fifo_commit_data(); read_count = motion_sense_fifo_read( sizeof(data), CONFIG_ACCEL_FIFO_SIZE, data, &data_bytes_read); TEST_EQ(read_count, 4, "%d"); TEST_BITS_SET(data[0].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[0].timestamp, now - 20500, "%u"); + TEST_EQ(data[0].timestamp, now - 25, "%u"); TEST_BITS_SET(data[1].flags, MOTIONSENSE_SENSOR_FLAG_ODR); TEST_BITS_SET(data[2].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[2].timestamp, now - 20500, "%u"); + TEST_EQ(data[2].timestamp, now - 25, "%u"); return EC_SUCCESS; } |