diff options
author | Tristan Honscheid <honscheid@google.com> | 2021-12-09 14:13:28 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-12-16 21:45:00 +0000 |
commit | 94951bdfcb670d5b4156e82da32e9f8b32333aa9 (patch) | |
tree | ee5827b3a11b2256bcecec8fdb4d7bf46bcdeb4c /zephyr/test/drivers | |
parent | eaa6e6a4939437075f13d9f91beda09fd150b1cc (diff) | |
download | chrome-ec-94951bdfcb670d5b4156e82da32e9f8b32333aa9.tar.gz |
zephyr: isl923x: Add test for raa489000_enable_asgate()
Write a test for raa489000_enable_asgate()
BRANCH=None
BUG=b:184856906
TEST=zmake -D configure --test test-drivers
Signed-off-by: Tristan Honscheid <honscheid@google.com>
Change-Id: Ib492ef600c3de45cfe93b57bc484f4aa3fe5412b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3327330
Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr/test/drivers')
-rw-r--r-- | zephyr/test/drivers/src/isl923x.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/zephyr/test/drivers/src/isl923x.c b/zephyr/test/drivers/src/isl923x.c index 4aad2ecd34..6078e93398 100644 --- a/zephyr/test/drivers/src/isl923x.c +++ b/zephyr/test/drivers/src/isl923x.c @@ -710,6 +710,32 @@ static void test_isl923x_is_acok(void) zassert_false(acok, "AC OK is true"); } +static void test_isl923x_enable_asgate(void) +{ + const struct emul *isl923x_emul = ISL923X_EMUL; + struct i2c_emul *i2c_emul = isl923x_emul_get_i2c_emul(isl923x_emul); + int rv; + + /* Part 1: Try enabling the ASGATE */ + rv = raa489000_enable_asgate(CHARGER_NUM, true); + + zassert_equal(EC_SUCCESS, rv, "Expected return code of %d but got %d", + EC_SUCCESS, rv); + zassert_true( + isl923x_emul_peek_reg(i2c_emul, RAA489000_REG_CONTROL8) & + RAA489000_C8_ASGATE_ON_READY, + "RAA489000_C8_ASGATE_ON_READY bit not set in Control Reg 8"); + + /* Part 2: Turn it back off */ + rv = raa489000_enable_asgate(CHARGER_NUM, false); + + zassert_equal(EC_SUCCESS, rv, "Expected return code of %d but got %d", + EC_SUCCESS, rv); + zassert_false(isl923x_emul_peek_reg(i2c_emul, RAA489000_REG_CONTROL8) & + RAA489000_C8_ASGATE_ON_READY, + "RAA489000_C8_ASGATE_ON_READY bit set in Control Reg 8"); +} + void test_suite_isl923x(void) { ztest_test_suite(isl923x, @@ -729,6 +755,7 @@ void test_suite_isl923x(void) ztest_unit_test(test_discharge_on_ac), ztest_unit_test(test_get_vbus_voltage), ztest_unit_test(test_init), - ztest_unit_test(test_isl923x_is_acok)); + ztest_unit_test(test_isl923x_is_acok), + ztest_unit_test(test_isl923x_enable_asgate)); ztest_run_test_suite(isl923x); } |