diff options
author | Aaron Massey <aaronmassey@google.com> | 2021-11-01 15:20:40 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-02 17:16:22 +0000 |
commit | 6101d302b19506bece6c6bead44c3aa6910b6fa4 (patch) | |
tree | ad04637262817aac7629e8ebeef77c2f6bc17d20 | |
parent | 1c27d8e06fc810b6cd86a106742f4e890d3b75e4 (diff) | |
download | chrome-ec-6101d302b19506bece6c6bead44c3aa6910b6fa4.tar.gz |
zephyr: test: ln9310 state change on mode change
Test ln9310 driver only changes power state on mode change interrupt.
BRANCH=none
BUG=b:184856083
TEST=zmake configure --test zephyr/test/drivers
Signed-off-by: Aaron Massey <aaronmassey@google.com>
Change-Id: Ie54aec6f10d47c756d74ad8b2c79793fe3962e86
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3252928
Reviewed-by: Yuval Peress <peress@google.com>
-rw-r--r-- | zephyr/test/drivers/src/ln9310.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/zephyr/test/drivers/src/ln9310.c b/zephyr/test/drivers/src/ln9310.c index 7b3ae1617f..8ee397fb8a 100644 --- a/zephyr/test/drivers/src/ln9310.c +++ b/zephyr/test/drivers/src/ln9310.c @@ -635,6 +635,41 @@ static void test_ln9310_update_startup_seq_fails(void) i2c_common_emul_set_read_func(i2c_emul, NULL, NULL); } +static void test_ln9310_state_change_only_on_mode_change_interrupt(void) +{ + const struct emul *emulator = + emul_get_binding(DT_LABEL(DT_NODELABEL(ln9310))); + struct i2c_emul *i2c_emul = ln9310_emul_get_i2c_emul(emulator); + struct reg_to_intercept test_data = { + .reg = LN9310_REG_INT1, + .replace_val = 0, + }; + + zassert_not_null(emulator, NULL); + zassert_not_null(i2c_emul, NULL); + + ln9310_emul_set_context(emulator); + ln9310_emul_reset(emulator); + /* Battery and chip rev won't matter here so only testing one pair */ + ln9310_emul_set_battery_cell_type(emulator, BATTERY_CELL_TYPE_2S); + ln9310_emul_set_version(emulator, LN9310_BC_STS_C_CHIP_REV_FIXED); + + zassert_ok(ln9310_init(), NULL); + zassert_true(ln9310_emul_is_init(emulator), NULL); + + i2c_common_emul_set_read_func(i2c_emul, &mock_read_interceptor, + &test_data); + + ln9310_software_enable(true); + + /* TODO(b/201420132) */ + k_msleep(TEST_DELAY_MS); + + zassert_false(ln9310_power_good(), NULL); + + i2c_common_emul_set_read_func(i2c_emul, NULL, NULL); +} + static void reset_ln9310_state(void) { ln9310_reset_to_initial_state(); @@ -646,6 +681,10 @@ void test_suite_ln9310(void) ztest_test_suite( ln9310, ztest_unit_test_setup_teardown( + test_ln9310_state_change_only_on_mode_change_interrupt, + reset_ln9310_state, + reset_ln9310_state), + ztest_unit_test_setup_teardown( test_ln9310_update_startup_seq_fails, reset_ln9310_state, reset_ln9310_state), |