diff options
author | Zhuohao Lee <zhuohao@chromium.org> | 2022-09-08 10:14:07 +0800 |
---|---|---|
committer | Zhuohao Lee <zhuohao@chromium.org> | 2022-09-08 10:14:07 +0800 |
commit | a1c1b694ad02efd59b3573b3e7390ee8218dbba5 (patch) | |
tree | 66897f11994119f362995d00ce7c670f8feddcfe /zephyr/test/drivers/default/src/console_cmd/battery.c | |
parent | 55d4e1d3bd9c8184198d7273c192af382d7a805c (diff) | |
parent | 74bc95b54b859f5097845ed7fe7f2c0a4d5bcee8 (diff) | |
download | chrome-ec-a1c1b694ad02efd59b3573b3e7390ee8218dbba5.tar.gz |
Merge remote-tracking branch cros/main into firmware-dedede-13606.B-master
Generated by: util/update_release_branch.py --baseboard dedede --relevant_paths_file
util/dedede-relevant-paths.txt firmware-dedede-13606.B-master
Relevant changes:
git log --oneline 55d4e1d3bd..74bc95b54b -- baseboard/dedede
board/beadrix board/beetley board/blipper board/boten board/bugzzy
board/corori2 board/cret board/drawcia board/drawcia_riscv board/galtic
board/kracko board/lantis board/madoo board/magolor board/metaknight
board/pirika board/sasuke board/sasukette board/shotzo board/storo
board/waddledee board/waddledoo board/wheelie common/charge_state_v2.c
common/mkbp_* common/ocpc.c common/usbc/usb_tc_drp_acc_trysrc_sm.c
common/usbc/usb_sm.c common/usbc/*_pd_* common/usbc/dp_alt_mode.c
common/usbc/usb_prl_sm.c common/usbc/usb_pe_drp_sm.c
common/usb_charger.c common/usb_common.c common/usbc_ocp.c
driver/charger/sm5803.* driver/charger/isl923x.* driver/tcpm/raa489000.*
driver/tcpm/it83* include/power/icelake.h include/intel_x86.h
power/icelake.c power/intel_x86.c util/getversion.sh
9f1ba5d0ff shotzo: remove battery setting and charger task
37e35d3aff sm5803: add the CONFIG_BATTERY for the battery api
c749a1eace raa489000: support FRS function
2e864b2539 tree-wide: const-ify argv for console commands
e488388c6a common: Not sleep 500ms when already left safe mode
d269be62d1 usb_common: Move HPD Wake MKBP Source to TCPMv1/TCPMv2 common file
79b9283e71 usbc: Set VDM_SETUP_DONE on DR Swap fail due to PD 2.0
534ff5c3a9 drawcia_riscv: Disable CMD_ACCELS to reduce flash size
d3885baf82 TCPMv2: Release TCPC driver on port suspend request
BRANCH=None
BUG=b:243906438 b:242949656 b:244387210 b:226259582 b:220875780
BUG=b:242477979 b:240458902
TEST=`make -j buildall`
Signed-off-by: Zhuohao Lee <zhuohao@chromium.org>
Change-Id: I8c4253fbef1e6ad0f8acdf8921815939a88c0a49
Diffstat (limited to 'zephyr/test/drivers/default/src/console_cmd/battery.c')
-rw-r--r-- | zephyr/test/drivers/default/src/console_cmd/battery.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/zephyr/test/drivers/default/src/console_cmd/battery.c b/zephyr/test/drivers/default/src/console_cmd/battery.c index eb6ed0a519..25f25d918f 100644 --- a/zephyr/test/drivers/default/src/console_cmd/battery.c +++ b/zephyr/test/drivers/default/src/console_cmd/battery.c @@ -3,14 +3,42 @@ * found in the LICENSE file. */ +#include <zephyr/drivers/emul.h> #include <zephyr/shell/shell.h> #include <zephyr/ztest.h> +#include "battery_smart.h" #include "console.h" #include "ec_commands.h" +#include "emul/emul_common_i2c.h" +#include "emul/emul_smart_battery.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +struct console_cmd_battery_fixture { + const struct emul *emul; + struct i2c_common_emul_data *i2c_emul; +}; + +static void *console_cmd_battery_setup(void) +{ + static struct console_cmd_battery_fixture fixture = { + .emul = EMUL_DT_GET(DT_NODELABEL(battery)), + }; + + fixture.i2c_emul = emul_smart_battery_get_i2c_common_data(fixture.emul); + + return &fixture; +} + +static void console_cmd_battery_after(void *f) +{ + struct console_cmd_battery_fixture *fixture = f; + + i2c_common_emul_set_read_fail_reg(fixture->i2c_emul, + I2C_COMMON_EMUL_NO_FAIL_REG); +} + /* Default battery command */ ZTEST_USER(console_cmd_battery, test_battery_default) { @@ -18,6 +46,14 @@ ZTEST_USER(console_cmd_battery, test_battery_default) "Failed default print"); } +ZTEST_USER_F(console_cmd_battery, test_battery_status_i2c_error) +{ + /* Force a failure on the battery i2c write to SB_BATTERY_STATUS */ + i2c_common_emul_set_read_fail_reg(fixture->i2c_emul, SB_BATTERY_STATUS); + zassert_ok(shell_execute_cmd(get_ec_shell(), "battery"), + "Failed default print"); +} + /* Battery command with repeat */ ZTEST_USER(console_cmd_battery, test_battery_repeat) { @@ -50,4 +86,5 @@ ZTEST_USER(console_cmd_battery, test_battery_bad_repeat_sleep) EC_ERROR_INVAL, rv); } -ZTEST_SUITE(console_cmd_battery, NULL, NULL, NULL, NULL, NULL); +ZTEST_SUITE(console_cmd_battery, drivers_predicate_post_main, + console_cmd_battery_setup, NULL, console_cmd_battery_after, NULL); |