summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Massey <aaronmassey@google.com>2022-09-26 16:45:14 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-28 00:27:21 +0000
commit476ce6df63da54684da2727b1d1a8ffcc818388e (patch)
tree606b40d2bb6a06322fa1e7170aea78cca5638cd0
parente19927727d86033d873aef0d36c4002d0fbb579b (diff)
downloadchrome-ec-476ce6df63da54684da2727b1d1a8ffcc818388e.tar.gz
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 <aaronmassey@google.com> Change-Id: Ie59d37cb18c841d14f39f2395d5c4be767c8129f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3919676 Reviewed-by: Al Semjonovs <asemjonovs@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r--zephyr/test/system_common/src/system_is_locked.c31
-rw-r--r--zephyr/test/system_common/testcase.yaml9
2 files changed, 39 insertions, 1 deletions
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 <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest_assert.h>
+#include <zephyr/ztest_test_new.h>
+
+#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