summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-09-18 15:09:32 -0600
committerCommit Bot <commit-bot@chromium.org>2021-09-21 02:41:38 +0000
commitdf6a8a118ba190cecd14d7e8b56e1945d739f390 (patch)
treec2feb09cf95de5467405ea77547711fe796a0824
parent773a0ca0b7d2d7d9aad543e2c894fd4cf363d3cd (diff)
downloadchrome-ec-df6a8a118ba190cecd14d7e8b56e1945d739f390.tar.gz
zephyr: test: test lis2dw12_init timeout
BRANCH=none BUG=b:200046770 TEST=zmake configure --test zephyr/projects/drivers Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Icae6ca1a5b5a222893380975880979e68c3d941b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3170537 Commit-Queue: Yuval Peress <peress@google.com> Tested-by: Yuval Peress <peress@google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/test/drivers/src/lis2dw12.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/zephyr/test/drivers/src/lis2dw12.c b/zephyr/test/drivers/src/lis2dw12.c
index 0b89ca88b0..c5b82a4e19 100644
--- a/zephyr/test/drivers/src/lis2dw12.c
+++ b/zephyr/test/drivers/src/lis2dw12.c
@@ -57,6 +57,19 @@ static void test_lis2dw12_init__fail_write_soft_reset(void)
zassert_equal(EC_ERROR_INVAL, rv, NULL);
}
+static void test_lis2dw12_init__timeout_read_soft_reset(void)
+{
+ const struct emul *emul = emul_get_binding(EMUL_LABEL);
+ struct motion_sensor_t *ms = &motion_sensors[LIS2DW12_SENSOR_ID];
+ int rv;
+
+ i2c_common_emul_set_read_fail_reg(lis2dw12_emul_to_i2c_emul(emul),
+ LIS2DW12_SOFT_RESET_ADDR);
+ rv = ms->drv->init(ms);
+ zassert_equal(EC_ERROR_TIMEOUT, rv, "init returned %d but expected %d",
+ rv, EC_ERROR_TIMEOUT);
+}
+
void test_suite_lis2dw12(void)
{
ztest_test_suite(lis2dw12,
@@ -68,6 +81,9 @@ void test_suite_lis2dw12(void)
lis2dw12_setup, unit_test_noop),
ztest_unit_test_setup_teardown(
test_lis2dw12_init__fail_write_soft_reset,
+ lis2dw12_setup, unit_test_noop),
+ ztest_unit_test_setup_teardown(
+ test_lis2dw12_init__timeout_read_soft_reset,
lis2dw12_setup, unit_test_noop));
ztest_run_test_suite(lis2dw12);
}