blob: 927fe174d74a9f1defd4cdf37a9333c13f4245b3 [file] [log] [blame]
Samuel Dionne-Riele69e1f12022-08-18 15:44:04 -04001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Tests for pause command
4 *
5 * Copyright 2022, Samuel Dionne-Riel <samuel@dionne-riel.com>
6 */
7
Samuel Dionne-Riele69e1f12022-08-18 15:44:04 -04008#include <asm/global_data.h>
9#include <test/lib.h>
10#include <test/ut.h>
11
12DECLARE_GLOBAL_DATA_PTR;
13
14static int lib_test_hush_pause(struct unit_test_state *uts)
15{
16 /* Test default message */
Samuel Dionne-Riele69e1f12022-08-18 15:44:04 -040017 /* Cook a newline when the command is expected to pause */
18 console_in_puts("\n");
19 ut_assertok(run_command("pause", 0));
20 console_record_readline(uts->actual_str, sizeof(uts->actual_str));
21 ut_asserteq_str("Press any key to continue...", uts->actual_str);
22 ut_assertok(ut_check_console_end(uts));
23
24 /* Test provided message */
Samuel Dionne-Riele69e1f12022-08-18 15:44:04 -040025 /* Cook a newline when the command is expected to pause */
26 console_in_puts("\n");
27 ut_assertok(run_command("pause 'Prompt for pause...'", 0));
28 console_record_readline(uts->actual_str, sizeof(uts->actual_str));
29 ut_asserteq_str("Prompt for pause...", uts->actual_str);
30 ut_assertok(ut_check_console_end(uts));
31
32 /* Test providing more than one params */
Samuel Dionne-Riele69e1f12022-08-18 15:44:04 -040033 /* No newline cooked here since the command is expected to fail */
34 ut_asserteq(1, run_command("pause a b", 0));
35 console_record_readline(uts->actual_str, sizeof(uts->actual_str));
36 ut_asserteq_str("pause - delay until user input", uts->actual_str);
37 ut_asserteq(1, ut_check_console_end(uts));
38
39 return 0;
40}
Simon Glass56228252024-08-22 07:57:58 -060041LIB_TEST(lib_test_hush_pause, UTF_CONSOLE);