summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/src/isl923x.c
diff options
context:
space:
mode:
authorYuval Peress <peress@google.com>2021-09-30 11:02:32 -0600
committerCommit Bot <commit-bot@chromium.org>2021-10-02 02:27:49 +0000
commitb3c535fcd0c7d0df3c2aa6a1fb827b106534146c (patch)
treed871cef3820aaa56a9ea20cbb4a4b7adcf3dbd0f /zephyr/test/drivers/src/isl923x.c
parent4bcdfecae714b175c1dc65549a33c71d55badb20 (diff)
downloadchrome-ec-b3c535fcd0c7d0df3c2aa6a1fb827b106534146c.tar.gz
zephyr: test: verify isl923x manufacturer ID code path
BRANCH=none BUG=b:201602829 TEST=zmake configure --test zephyr/test/drivers Signed-off-by: Yuval Peress <peress@google.com> Change-Id: I2000ea7ea73a311184c5f66c3aa16518261b065d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3198236 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com> Reviewed-by: Aaron Massey <aaronmassey@google.com>
Diffstat (limited to 'zephyr/test/drivers/src/isl923x.c')
-rw-r--r--zephyr/test/drivers/src/isl923x.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/zephyr/test/drivers/src/isl923x.c b/zephyr/test/drivers/src/isl923x.c
index 0eb261d837..17c87ea651 100644
--- a/zephyr/test/drivers/src/isl923x.c
+++ b/zephyr/test/drivers/src/isl923x.c
@@ -158,11 +158,33 @@ void test_isl923x_set_input_current_limit(void)
}
}
+void test_manufacturer_id(void)
+{
+ const struct emul *isl923x_emul = ISL923X_EMUL;
+ struct i2c_emul *i2c_emul = isl923x_emul_get_i2c_emul(isl923x_emul);
+ int id;
+
+ isl923x_emul_set_manufacturer_id(isl923x_emul, 0x1234);
+ zassert_ok(isl923x_drv.manufacturer_id(CHARGER_NUM, &id), NULL);
+ zassert_equal(0x1234, id, NULL);
+
+ /* Test read error */
+ i2c_common_emul_set_read_fail_reg(i2c_emul,
+ ISL923X_REG_MANUFACTURER_ID);
+ zassert_equal(EC_ERROR_INVAL,
+ isl923x_drv.manufacturer_id(CHARGER_NUM, &id), NULL);
+
+ /* Reset fail register */
+ i2c_common_emul_set_read_fail_reg(i2c_emul,
+ I2C_COMMON_EMUL_NO_FAIL_REG);
+}
+
void test_suite_isl923x(void)
{
ztest_test_suite(isl923x,
ztest_unit_test(test_isl923x_set_current),
ztest_unit_test(test_isl923x_set_voltage),
- ztest_unit_test(test_isl923x_set_input_current_limit));
+ ztest_unit_test(test_isl923x_set_input_current_limit),
+ ztest_unit_test(test_manufacturer_id));
ztest_run_test_suite(isl923x);
}