From 476ce6df63da54684da2727b1d1a8ffcc818388e Mon Sep 17 00:00:00 2001 From: Aaron Massey Date: Mon, 26 Sep 2022 16:45:14 -0600 Subject: test: Syslock console command Add a test that verifies the syslock console command forces the system_is_locked function to return true. BRANCH=none BUG=b:248106876 TEST=./twister -s zephyr/test/system_common/system.default Signed-off-by: Aaron Massey Change-Id: Ie59d37cb18c841d14f39f2395d5c4be767c8129f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3919676 Reviewed-by: Al Semjonovs Code-Coverage: Zoss --- zephyr/test/system_common/src/system_is_locked.c | 31 ++++++++++++++++++++++++ zephyr/test/system_common/testcase.yaml | 9 ++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 zephyr/test/system_common/src/system_is_locked.c diff --git a/zephyr/test/system_common/src/system_is_locked.c b/zephyr/test/system_common/src/system_is_locked.c new file mode 100644 index 0000000000..2ea9f3038b --- /dev/null +++ b/zephyr/test/system_common/src/system_is_locked.c @@ -0,0 +1,31 @@ +/* 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 +#include +#include + +#include "system.h" + +ZTEST_USER(system_is_locked, test_syslock_console_cmd) +{ + /* + * Integration test that validates the syslock console command forces + * the system_is_locked command to return true + */ + + const struct shell *shell_zephyr = get_ec_shell(); + + shell_backend_dummy_clear_output(shell_zephyr); + + zassert_false(system_is_locked()); + /* + * TODO(b/249373175): Use CHECK_CONSOLE_CMD() macro + */ + zassert_ok(shell_execute_cmd(shell_zephyr, "syslock"), NULL); + zassert_true(system_is_locked()); +} + +ZTEST_SUITE(system_is_locked, NULL, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/system_common/testcase.yaml b/zephyr/test/system_common/testcase.yaml index d6977dbb6a..f30d0e52f1 100644 --- a/zephyr/test/system_common/testcase.yaml +++ b/zephyr/test/system_common/testcase.yaml @@ -1,4 +1,11 @@ common: platform_allow: native_posix tests: - system.default: {} + system.default: + extra_configs: + - CONFIG_SHELL_BACKEND_DUMMY=y + - CONFIG_SHELL_BACKEND_DUMMY_BUF_SIZE=1000 + - CONFIG_SHELL_BACKEND_SERIAL=n + tags: + common + system -- cgit v1.2.1