aboutsummaryrefslogtreecommitdiff
path: root/test/cmd/test_pause.c
diff options
context:
space:
mode:
authorSamuel Dionne-Riel2022-08-18 15:44:04 -0400
committerTom Rini2022-09-02 13:40:42 -0400
commitdc0d17c26a3a03634994c59adb0b657807827183 (patch)
tree991b387d3fcb0fd43082033fc0fc040ea756ef4d /test/cmd/test_pause.c
parentd88260710b212815ae1f461aec24ad926c668d36 (diff)
cmd: Add pause command
This command is being introduced with the goal of allowing user-friendly "generic use case" U-Boot builds to pause until user input under some situations. The main use case would be when a boot failure happens, to pause until the user has had time to acknowledge the current state. Tested using: make && ./u-boot -v -T -c 'ut lib lib_test_hush_pause' Signed-off-by: Samuel Dionne-Riel <samuel@dionne-riel.com> Cc: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/cmd/test_pause.c')
-rw-r--r--test/cmd/test_pause.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/cmd/test_pause.c b/test/cmd/test_pause.c
new file mode 100644
index 00000000000..2b85cce3271
--- /dev/null
+++ b/test/cmd/test_pause.c
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Tests for pause command
+ *
+ * Copyright 2022, Samuel Dionne-Riel <samuel@dionne-riel.com>
+ */
+
+#include <common.h>
+#include <asm/global_data.h>
+#include <test/lib.h>
+#include <test/ut.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int lib_test_hush_pause(struct unit_test_state *uts)
+{
+ /* Test default message */
+ console_record_reset_enable();
+ /* Cook a newline when the command is expected to pause */
+ console_in_puts("\n");
+ ut_assertok(run_command("pause", 0));
+ console_record_readline(uts->actual_str, sizeof(uts->actual_str));
+ ut_asserteq_str("Press any key to continue...", uts->actual_str);
+ ut_assertok(ut_check_console_end(uts));
+
+ /* Test provided message */
+ console_record_reset_enable();
+ /* Cook a newline when the command is expected to pause */
+ console_in_puts("\n");
+ ut_assertok(run_command("pause 'Prompt for pause...'", 0));
+ console_record_readline(uts->actual_str, sizeof(uts->actual_str));
+ ut_asserteq_str("Prompt for pause...", uts->actual_str);
+ ut_assertok(ut_check_console_end(uts));
+
+ /* Test providing more than one params */
+ console_record_reset_enable();
+ /* No newline cooked here since the command is expected to fail */
+ ut_asserteq(1, run_command("pause a b", 0));
+ console_record_readline(uts->actual_str, sizeof(uts->actual_str));
+ ut_asserteq_str("pause - delay until user input", uts->actual_str);
+ ut_asserteq(1, ut_check_console_end(uts));
+
+ return 0;
+}
+LIB_TEST(lib_test_hush_pause, 0);