diff options
author | Aaron Massey <aaronmassey@google.com> | 2022-10-18 13:15:03 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-10-19 20:20:01 +0000 |
commit | d57182c14a86ba260c3a2371d5cd25cf8e21eded (patch) | |
tree | 11f68e2eeda8fc9416f726f4687a73739d122227 | |
parent | a86cbeb75a9079e741a0209eebf47c824ec3fbf9 (diff) | |
download | chrome-ec-d57182c14a86ba260c3a2371d5cd25cf8e21eded.tar.gz |
test: EC_CMD_DISPLAY_SOC
Verify that the EC_CMD_DISPLAY_SOC host command fetches the displayed
state of charge and the constants: full-factor and
shutdown-state-of-charge in values where each increment is 1/10th of a
percent.
BRANCH=none
BUG=b:236075098
TEST=twister --clobber -i -s zephyr/test/drivers/drivers.host_cmd
Signed-off-by: Aaron Massey <aaronmassey@google.com>
Change-Id: Ife2400b7d887214b791e0608a836355e6cf34316
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3966712
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
-rw-r--r-- | zephyr/test/drivers/host_cmd/CMakeLists.txt | 1 | ||||
-rw-r--r-- | zephyr/test/drivers/host_cmd/src/battery_display_soc.c | 32 |
2 files changed, 33 insertions, 0 deletions
diff --git a/zephyr/test/drivers/host_cmd/CMakeLists.txt b/zephyr/test/drivers/host_cmd/CMakeLists.txt index 286685089b..4529e6c570 100644 --- a/zephyr/test/drivers/host_cmd/CMakeLists.txt +++ b/zephyr/test/drivers/host_cmd/CMakeLists.txt @@ -5,6 +5,7 @@ target_sources(app PRIVATE src/adc.c src/battery_cut_off.c + src/battery_display_soc.c src/get_panic_info.c src/get_pd_port_caps.c src/host_event_commands.c diff --git a/zephyr/test/drivers/host_cmd/src/battery_display_soc.c b/zephyr/test/drivers/host_cmd/src/battery_display_soc.c new file mode 100644 index 0000000000..029551a49b --- /dev/null +++ b/zephyr/test/drivers/host_cmd/src/battery_display_soc.c @@ -0,0 +1,32 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include <zephyr/ztest.h> + +#include "battery.h" +#include "charge_state.h" +#include "host_command.h" +#include "test/drivers/test_state.h" + +ZTEST_USER(battery_display_soc, happy_path) +{ + const uint32_t full_charge_as_tenths = + CONFIG_BATT_HOST_FULL_FACTOR * 10; + const uint32_t host_shutdown_charge_as_tenths = + CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE * 10; + struct ec_response_display_soc response; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND_RESPONSE(EC_CMD_DISPLAY_SOC, 0, response); + + zassert_ok(host_command_process(&args)); + + zassert_equal(args.response_size, sizeof(response)); + zassert_equal(response.display_soc, charge_get_display_charge()); + zassert_equal(response.full_factor, full_charge_as_tenths); + zassert_equal(response.shutdown_soc, host_shutdown_charge_as_tenths); +} + +ZTEST_SUITE(battery_display_soc, drivers_predicate_post_main, NULL, NULL, NULL, + NULL); |