diff options
author | Yuval Peress <peress@google.com> | 2022-11-01 22:50:24 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-11-03 23:02:59 +0000 |
commit | 35e6179e8a2fed88461ec16e52618c74bf52dfe6 (patch) | |
tree | 30f2a96244de99097859f8858c36bb7330fe6176 | |
parent | 118bcdb316ae1d652d22af6425dfc6c3c5eda1d9 (diff) | |
download | chrome-ec-35e6179e8a2fed88461ec16e52618c74bf52dfe6.tar.gz |
test: Add tests to the debug host commands
Enable the charge state debug host commands and run them to make sure
that they all succeed. This test is more of a general check to make
sure that these constant IDs remain working and return an OK.
BRANCH=none
BUG=none
TEST=twister
Signed-off-by: Yuval Peress <peress@google.com>
Change-Id: I9e91f8f932042666de3a80c2b505e3725ccecb05
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3998266
Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r-- | util/config_allowed.txt | 1 | ||||
-rw-r--r-- | zephyr/Kconfig.charger | 8 | ||||
-rw-r--r-- | zephyr/shim/include/config_chip.h | 5 | ||||
-rw-r--r-- | zephyr/test/drivers/Kconfig | 1 | ||||
-rw-r--r-- | zephyr/test/drivers/host_cmd/src/charge_manager.c | 44 |
5 files changed, 58 insertions, 1 deletions
diff --git a/util/config_allowed.txt b/util/config_allowed.txt index 074490612e..a98833624e 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -169,7 +169,6 @@ CONFIG_CHARGE_MANAGER_BAT_PCT_SAFE_MODE_EXIT CONFIG_CHARGE_MANAGER_DRP_CHARGING CONFIG_CHARGE_MANAGER_EXTERNAL_POWER_LIMIT CONFIG_CHARGE_MANAGER_SAFE_MODE -CONFIG_CHARGE_STATE_DEBUG CONFIG_CHIPSET_ALDERLAKE CONFIG_CHIPSET_APL_GLK CONFIG_CHIPSET_APOLLOLAKE diff --git a/zephyr/Kconfig.charger b/zephyr/Kconfig.charger index f408797d17..58a094e553 100644 --- a/zephyr/Kconfig.charger +++ b/zephyr/Kconfig.charger @@ -63,6 +63,14 @@ config PLATFORM_EC_CHARGE_MANAGER source is available on the hardware, so cannot be built without PLATFORM_EC_USBC. +config PLATFORM_EC_CHARGE_STATE_DEBUG + bool "Debug information about the charge state" + depends on PLATFORM_EC_CHARGE_MANAGER + help + Enables debug information regarding the current charge state. Enabling + this config will allow the EC_CMD_CHARGE_STATE host command to use the + CHARGE_STATE_CMD_GET_PARAM command to query the current charge state. + config PLATFORM_EC_CHARGESPLASH bool "Charging splashscreen support" help diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index bfef3427a8..f69713fada 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -1029,6 +1029,11 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256]; #endif +#undef CONFIG_CHARGE_STATE_DEBUG +#ifdef CONFIG_PLATFORM_EC_CHARGE_STATE_DEBUG +#define CONFIG_CHARGE_STATE_DEBUG +#endif + #undef CONFIG_CHARGESPLASH #ifdef CONFIG_PLATFORM_EC_CHARGESPLASH #define CONFIG_CHARGESPLASH diff --git a/zephyr/test/drivers/Kconfig b/zephyr/test/drivers/Kconfig index ed57c7c16e..a256c0b700 100644 --- a/zephyr/test/drivers/Kconfig +++ b/zephyr/test/drivers/Kconfig @@ -36,6 +36,7 @@ config LINK_TEST_SUITE_COMMON_CHARGER bool "Link and execute the common/charger.c tests" config LINK_TEST_SUITE_HOST_COMMANDS + select PLATFORM_EC_CHARGE_STATE_DEBUG bool "Link and test the host command tests" config LINK_TEST_SUITE_ISL923X diff --git a/zephyr/test/drivers/host_cmd/src/charge_manager.c b/zephyr/test/drivers/host_cmd/src/charge_manager.c index 7298b8e135..50a476dd99 100644 --- a/zephyr/test/drivers/host_cmd/src/charge_manager.c +++ b/zephyr/test/drivers/host_cmd/src/charge_manager.c @@ -44,5 +44,49 @@ ZTEST_USER(charge_manager, test_port_override__0_from_off) zassert_ok(host_command_process(&args)); } +ZTEST_USER(charge_manager, test_charge_state_get_debug_params) +{ + struct ec_params_charge_state params = { + .cmd = CHARGE_STATE_CMD_GET_PARAM, + }; + struct ec_response_charge_state response = { 0 }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_CHARGE_STATE, 0, response, params); + + /* Check that the following get commands work on these debug parameters. + * The values being asserted are the default values when nothing is + * plugged in. This should be enough since the test only needs to verify + * that the command gets the current value. Tests that verify the + * charging behavior exist elsewhere (under + * default/src/integration/usbc). + */ + params.get_param.param = CS_PARAM_DEBUG_CTL_MODE; + zassert_ok(host_command_process(&args)); + zassert_equal(0, response.get_param.value); + + params.get_param.param = CS_PARAM_DEBUG_MANUAL_CURRENT; + zassert_ok(host_command_process(&args)); + zassert_equal(0xffffffff, response.get_param.value); + + params.get_param.param = CS_PARAM_DEBUG_MANUAL_VOLTAGE; + zassert_ok(host_command_process(&args)); + zassert_equal(0xffffffff, response.get_param.value); + + params.get_param.param = CS_PARAM_DEBUG_SEEMS_DEAD; + zassert_ok(host_command_process(&args)); + zassert_equal(0, response.get_param.value); + + params.get_param.param = CS_PARAM_DEBUG_SEEMS_DISCONNECTED; + zassert_ok(host_command_process(&args)); + zassert_equal(0, response.get_param.value); + + params.get_param.param = CS_PARAM_DEBUG_BATT_REMOVED; + zassert_ok(host_command_process(&args)); + zassert_equal(0, response.get_param.value); + + params.get_param.param = CS_PARAM_DEBUG_MAX; + zassert_equal(EC_ERROR_INVAL, host_command_process(&args)); +} + ZTEST_SUITE(charge_manager, drivers_predicate_post_main, NULL, NULL, NULL, NULL); |