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