diff options
author | Yuval Peress <peress@google.com> | 2022-04-19 13:19:55 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-04-20 15:25:15 +0000 |
commit | 665fe5a5045ada7750a352c1696ffaae765cdbcd (patch) | |
tree | 7bc39f2005593096236d4ac6f70f63d04963660b /zephyr/test | |
parent | d47d8c6ed87926764ff02f36de61cec9791869c5 (diff) | |
download | chrome-ec-665fe5a5045ada7750a352c1696ffaae765cdbcd.tar.gz |
test: add tests for the accelinfo command
BRANCH=none
BUG=b:224614211
TEST=zmake test test-drivers
Signed-off-by: Yuval Peress <peress@google.com>
Change-Id: I043bca8a20fb8dd50c5f66a1f9416bfa9cc61378
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3594484
Reviewed-by: Al Semjonovs <asemjonovs@google.com>
Commit-Queue: Al Semjonovs <asemjonovs@google.com>
Diffstat (limited to 'zephyr/test')
-rw-r--r-- | zephyr/test/drivers/CMakeLists.txt | 1 | ||||
-rw-r--r-- | zephyr/test/drivers/prj.conf | 3 | ||||
-rw-r--r-- | zephyr/test/drivers/src/console_cmd/accelinfo.c | 51 |
3 files changed, 55 insertions, 0 deletions
diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt index 283593c53d..3a65b41205 100644 --- a/zephyr/test/drivers/CMakeLists.txt +++ b/zephyr/test/drivers/CMakeLists.txt @@ -21,6 +21,7 @@ target_sources(app PRIVATE src/charge_manager.c src/console_cmd/charge_manager.c src/console_cmd/charge_state.c + src/console_cmd/accelinfo.c src/cros_cbi.c src/espi.c src/gpio.c diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index 0f230410df..a83434bcf6 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -160,3 +160,6 @@ CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y CONFIG_PLATFORM_EC_CHARGER_PSYS=y CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y + +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y diff --git a/zephyr/test/drivers/src/console_cmd/accelinfo.c b/zephyr/test/drivers/src/console_cmd/accelinfo.c new file mode 100644 index 0000000000..5df520f300 --- /dev/null +++ b/zephyr/test/drivers/src/console_cmd/accelinfo.c @@ -0,0 +1,51 @@ +/* Copyright 2022 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include <shell/shell.h> +#include <ztest.h> + +#include "console.h" +#include "ec_commands.h" +#include "test/drivers/test_state.h" + +static void console_cmd_accelinfo_after(void *fixture) +{ + ARG_UNUSED(fixture); + shell_execute_cmd(get_ec_shell(), "accelinfo off"); +} + +ZTEST_SUITE(console_cmd_accelinfo, drivers_predicate_post_main, NULL, NULL, + console_cmd_accelinfo_after, NULL); + +ZTEST_USER(console_cmd_accelinfo, test_too_many_args) +{ + int rv = shell_execute_cmd(get_ec_shell(), "accelinfo arg1 arg2"); + + zassert_equal(rv, EC_ERROR_PARAM_COUNT, "Expected %d, but got %d", + EC_ERROR_PARAM_COUNT, rv); +} + +ZTEST_USER(console_cmd_accelinfo, test_print_once) +{ + zassert_ok(shell_execute_cmd(get_ec_shell(), "accelinfo"), NULL); +} + +ZTEST_USER(console_cmd_accelinfo, test_invalid_arg) +{ + int rv = shell_execute_cmd(get_ec_shell(), "accelinfo bar"); + + zassert_equal(rv, EC_ERROR_PARAM1, "Expected %d, but got %d", + EC_ERROR_PARAM1, rv); +} + +ZTEST_USER(console_cmd_accelinfo, test_enable_disable) +{ + /* + * There's no way to verify what is being printed to the console yet, so + * just assert that the command executed and returned 0. + */ + zassert_ok(shell_execute_cmd(get_ec_shell(), "accelinfo on"), NULL); + zassert_ok(shell_execute_cmd(get_ec_shell(), "accelinfo off"), NULL); +} |