diff options
author | Yuval Peress <peress@chromium.org> | 2019-10-29 15:02:37 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-13 00:56:05 +0000 |
commit | 88808c3dda819f9da22272850d2b56ab1e538c9f (patch) | |
tree | 614c8f28cb17c232ac74ac252b615fcecd554ba6 /test/motion_sense_fifo.c | |
parent | 4acc29890130946ad574ea0f314b65497efb7ce2 (diff) | |
download | chrome-ec-88808c3dda819f9da22272850d2b56ab1e538c9f.tar.gz |
common: Migrate online calibration to own module
This change moves the code that handles caching the temperature
(which is the first step in online calibration) into a new
compilational unit.
TEST=None
BRANCH=None
BUG=b:138303429,chromium:1023858
Change-Id: Ib1fe3d2234dc2436e2bbfd4febd22196e5cdafef
Signed-off-by: Yuval Peress <peress@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1906340
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'test/motion_sense_fifo.c')
-rw-r--r-- | test/motion_sense_fifo.c | 99 |
1 files changed, 3 insertions, 96 deletions
diff --git a/test/motion_sense_fifo.c b/test/motion_sense_fifo.c index 7e436bd404..9762fa61c9 100644 --- a/test/motion_sense_fifo.c +++ b/test/motion_sense_fifo.c @@ -14,46 +14,9 @@ #include "accelgyro.h" #include <sys/types.h> -struct mock_read_temp_result { - void *s; - int temp; - int ret; - int used_count; - struct mock_read_temp_result *next; -}; - -static struct mock_read_temp_result *mock_read_temp_results; - -static int mock_read_temp(const struct motion_sensor_t *s, int *temp) -{ - struct mock_read_temp_result *ptr = mock_read_temp_results; - - while (ptr) { - if (ptr->s == s) { - if (ptr->ret == EC_SUCCESS) - *temp = ptr->temp; - ptr->used_count++; - return ptr->ret; - } - ptr = ptr->next; - } - - return EC_ERROR_UNKNOWN; -} - -static struct accelgyro_drv mock_sensor_driver = { - .read_temp = mock_read_temp, -}; - -static struct accelgyro_drv empty_sensor_driver = {}; - struct motion_sensor_t motion_sensors[] = { - [BASE] = { - .drv = &mock_sensor_driver, - }, - [LID] = { - .drv = &empty_sensor_driver, - }, + [BASE] = {}, + [LID] = {}, }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); @@ -351,59 +314,6 @@ static int test_spread_double_commit_same_timestamp(void) return EC_SUCCESS; } -static int test_read_temp_on_stage(void) -{ - struct mock_read_temp_result expected = { &motion_sensors[BASE], 200, - EC_SUCCESS, 0, NULL }; - - mock_read_temp_results = &expected; - motion_sensors[0].oversampling_ratio = 1; - motion_sensors[0].collection_rate = 20000; /* ns */ - motion_sense_fifo_stage_data(data, motion_sensors, 3, - __hw_clock_source_read() - 10000); - - TEST_EQ(expected.used_count, 1, "%d"); - - return EC_SUCCESS; -} - -static int test_read_temp_from_cache_on_stage(void) -{ - struct mock_read_temp_result expected = { &motion_sensors[BASE], 200, - EC_SUCCESS, 0, NULL }; - - mock_read_temp_results = &expected; - motion_sensors[0].oversampling_ratio = 1; - motion_sensors[0].collection_rate = 20000; /* ns */ - motion_sense_fifo_stage_data(data, motion_sensors, 3, - __hw_clock_source_read() - 10000); - motion_sense_fifo_stage_data(data, motion_sensors, 3, - __hw_clock_source_read() - 5000); - - TEST_EQ(expected.used_count, 1, "%d"); - - return EC_SUCCESS; -} - -static int test_read_temp_twice_after_cache_stale(void) -{ - struct mock_read_temp_result expected = { &motion_sensors[BASE], 200, - EC_SUCCESS, 0, NULL }; - - mock_read_temp_results = &expected; - motion_sensors[0].oversampling_ratio = 1; - motion_sensors[0].collection_rate = 20000; /* ns */ - motion_sense_fifo_stage_data(data, motion_sensors, 3, - __hw_clock_source_read() - 10000); - sleep(2); - motion_sense_fifo_stage_data(data, motion_sensors, 3, - __hw_clock_source_read() - 5000); - - TEST_EQ(expected.used_count, 2, "%d"); - - return EC_SUCCESS; -} - void before_test(void) { motion_sense_fifo_commit_data(); @@ -412,13 +322,13 @@ void before_test(void) motion_sense_fifo_reset_wake_up_needed(); memset(data, 0, sizeof(data)); motion_sense_fifo_reset(); - mock_read_temp_results = NULL; } void run_test(void) { test_reset(); motion_sense_fifo_init(); + RUN_TEST(test_insert_async_event); RUN_TEST(test_wake_up_needed); RUN_TEST(test_wake_up_needed_overflow); @@ -432,9 +342,6 @@ void run_test(void) RUN_TEST(test_spread_data_in_window); RUN_TEST(test_spread_data_by_collection_rate); RUN_TEST(test_spread_double_commit_same_timestamp); - RUN_TEST(test_read_temp_on_stage); - RUN_TEST(test_read_temp_from_cache_on_stage); - RUN_TEST(test_read_temp_twice_after_cache_stale); test_print_result(); } |