summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/src
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-09-18 10:54:16 -0600
committerCommit Bot <commit-bot@chromium.org>2021-09-21 02:41:35 +0000
commit773a0ca0b7d2d7d9aad543e2c894fd4cf363d3cd (patch)
treef3d4664c41e2849a70148004f48bcfa118050cb0 /zephyr/test/drivers/src
parent558b809aae30c8e8e72492bc11831ce0f9aa9d24 (diff)
downloadchrome-ec-773a0ca0b7d2d7d9aad543e2c894fd4cf363d3cd.tar.gz
zephyr: test: Test failed write on soft reset register (lis2dw12)
Test the init code path that fails writing the soft reset register. BRANCH=none BUG=b:200046770 TEST=zmake configure --test zephyr/test/drivers Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ic395c7dd749c4203800b72afbb024919a71d0eae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3170535 Commit-Queue: Yuval Peress <peress@google.com> Tested-by: Yuval Peress <peress@google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr/test/drivers/src')
-rw-r--r--zephyr/test/drivers/src/lis2dw12.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/zephyr/test/drivers/src/lis2dw12.c b/zephyr/test/drivers/src/lis2dw12.c
index 06009f95a0..0b89ca88b0 100644
--- a/zephyr/test/drivers/src/lis2dw12.c
+++ b/zephyr/test/drivers/src/lis2dw12.c
@@ -45,6 +45,18 @@ static void test_lis2dw12_init__fail_who_am_i(void)
EC_ERROR_ACCESS_DENIED);
}
+static void test_lis2dw12_init__fail_write_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_write_fail_reg(lis2dw12_emul_to_i2c_emul(emul),
+ LIS2DW12_SOFT_RESET_ADDR);
+ rv = ms->drv->init(ms);
+ zassert_equal(EC_ERROR_INVAL, rv, NULL);
+}
+
void test_suite_lis2dw12(void)
{
ztest_test_suite(lis2dw12,
@@ -53,6 +65,9 @@ void test_suite_lis2dw12(void)
lis2dw12_setup, unit_test_noop),
ztest_unit_test_setup_teardown(
test_lis2dw12_init__fail_who_am_i,
+ lis2dw12_setup, unit_test_noop),
+ ztest_unit_test_setup_teardown(
+ test_lis2dw12_init__fail_write_soft_reset,
lis2dw12_setup, unit_test_noop));
ztest_run_test_suite(lis2dw12);
}