|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
| 2 | +/* |
| 3 | + * Tests for pause command |
| 4 | + * |
| 5 | + * Copyright 2022, Samuel Dionne-Riel <[email protected]> |
| 6 | + */ |
| 7 | + |
| 8 | +#include <common.h> |
| 9 | +#include <asm/global_data.h> |
| 10 | +#include <test/lib.h> |
| 11 | +#include <test/ut.h> |
| 12 | + |
| 13 | +DECLARE_GLOBAL_DATA_PTR; |
| 14 | + |
| 15 | +static int lib_test_hush_pause(struct unit_test_state *uts) |
| 16 | +{ |
| 17 | + /* Test default message */ |
| 18 | + console_record_reset_enable(); |
| 19 | + /* Cook a newline when the command is expected to pause */ |
| 20 | + console_in_puts("\n"); |
| 21 | + ut_assertok(run_command("pause", 0)); |
| 22 | + console_record_readline(uts->actual_str, sizeof(uts->actual_str)); |
| 23 | + ut_asserteq_str("Press any key to continue...", uts->actual_str); |
| 24 | + ut_assertok(ut_check_console_end(uts)); |
| 25 | + |
| 26 | + /* Test provided message */ |
| 27 | + console_record_reset_enable(); |
| 28 | + /* Cook a newline when the command is expected to pause */ |
| 29 | + console_in_puts("\n"); |
| 30 | + ut_assertok(run_command("pause 'Prompt for pause...'", 0)); |
| 31 | + console_record_readline(uts->actual_str, sizeof(uts->actual_str)); |
| 32 | + ut_asserteq_str("Prompt for pause...", uts->actual_str); |
| 33 | + ut_assertok(ut_check_console_end(uts)); |
| 34 | + |
| 35 | + /* Test providing more than one params */ |
| 36 | + console_record_reset_enable(); |
| 37 | + /* No newline cooked here since the command is expected to fail */ |
| 38 | + ut_asserteq(1, run_command("pause a b", 0)); |
| 39 | + console_record_readline(uts->actual_str, sizeof(uts->actual_str)); |
| 40 | + ut_asserteq_str("pause - delay until user input", uts->actual_str); |
| 41 | + ut_asserteq(1, ut_check_console_end(uts)); |
| 42 | + |
| 43 | + return 0; |
| 44 | +} |
| 45 | +LIB_TEST(lib_test_hush_pause, 0); |
0 commit comments