From 13a94b26a34077b2cc403386b2f398cec69ce2b0 Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Tue, 30 Aug 2022 21:56:26 +0000 Subject: zephyr: test: Set start-up battery level to 50% This will avoid the flakiness of the virtual battery test (specifically test_read_regs) due to the power-on speed. BUG=b:243816417 BRANCH=None TEST=./twister -v -T zephyr/test Signed-off-by: Daisuke Nojiri Change-Id: I10251fdd33acc184c3c0a86b93e646e326181829 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3865907 Reviewed-by: Wai-Hong Tam Code-Coverage: Zoss Reviewed-by: Al Semjonovs --- zephyr/test/drivers/common/src/utils.c | 7 ++++--- zephyr/test/drivers/default/src/virtual_battery.c | 10 ++-------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/zephyr/test/drivers/common/src/utils.c b/zephyr/test/drivers/common/src/utils.c index f559e8629a..62e1065f08 100644 --- a/zephyr/test/drivers/common/src/utils.c +++ b/zephyr/test/drivers/common/src/utils.c @@ -60,11 +60,12 @@ void test_set_chipset_to_s0(void) /* * Make sure that battery is in good condition to * not trigger hibernate in charge_state_v2.c - * Set battery voltage to expected value and capacity to 75%. Battery + * Set battery voltage to expected value and capacity to 50%. Battery * will not be full and accepts charging, but will not trigger - * hibernate. Charge level is chosen arbitrary. + * hibernate. Charge level is set to the default value of an emulator + * (emul/emul_smart_battery.c). b/244366201. */ - test_set_battery_level(75); + test_set_battery_level(50); /* The easiest way to power on seems to be the shell command. */ zassert_equal(EC_SUCCESS, shell_execute_cmd(get_ec_shell(), "power on"), diff --git a/zephyr/test/drivers/default/src/virtual_battery.c b/zephyr/test/drivers/default/src/virtual_battery.c index 5eed8296a6..6de4df6190 100644 --- a/zephyr/test/drivers/default/src/virtual_battery.c +++ b/zephyr/test/drivers/default/src/virtual_battery.c @@ -141,10 +141,7 @@ ZTEST_USER(virtual_battery, test_read_regs) expected = 100 * bat->cap / bat->full_cap; word = virtual_battery_read16(SB_RELATIVE_STATE_OF_CHARGE); - /* TODO(b/243816417): Flaky virtual battery test for mocked power */ - if (!IS_ENABLED(CONFIG_POWER_SEQUENCE_MOCK)) { - zassert_equal(expected, word, "%d != %d", expected, word); - } + zassert_equal(expected, word, "%d != %d", expected, word); word = virtual_battery_read16(SB_TEMPERATURE); zassert_equal(bat->temp, word, "%d != %d", bat->temp, word); @@ -171,10 +168,7 @@ ZTEST_USER(virtual_battery, test_read_regs) zassert_equal(bat->design_cap, word, "%d != %d", bat->design_cap, word); word = virtual_battery_read16(SB_REMAINING_CAPACITY); - /* TODO(b/243816417): Flaky virtual battery test for mocked power */ - if (!IS_ENABLED(CONFIG_POWER_SEQUENCE_MOCK)) { - zassert_equal(bat->cap, word, "%d != %d", bat->cap, word); - } + zassert_equal(bat->cap, word, "%d != %d", bat->cap, word); len = virtual_battery_read_str(SB_MANUFACTURER_NAME, &str, 32); zassert_equal(bat->mf_name_len, len, "%d != %d", bat->mf_name_len, len); -- cgit v1.2.1