]> Git Repo - J-u-boot.git/blob - test/cmd/history.c
test: Rename unit-test flags
[J-u-boot.git] / test / cmd / history.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Tests for history command
4  *
5  * Copyright 2023 Google LLC
6  * Written by Simon Glass <[email protected]>
7  */
8
9 #include <cli.h>
10 #include <command.h>
11 #include <test/lib.h>
12 #include <test/test.h>
13 #include <test/ut.h>
14
15 static int lib_test_history(struct unit_test_state *uts)
16 {
17         static const char cmd1[] = "setenv fred hello";
18         static const char cmd2[] = "print fred";
19
20         /* running commands directly does not add to history */
21         ut_assertok(run_command(cmd1, 0));
22         ut_assert_console_end();
23         ut_assertok(run_command("history", 0));
24         ut_assert_console_end();
25
26         /* enter commands via the console */
27         console_in_puts(cmd1);
28         console_in_puts("\n");
29         ut_asserteq(strlen(cmd1), cli_readline(""));
30         ut_assert_nextline(cmd1);
31
32         console_in_puts(cmd2);
33         console_in_puts("\n");
34         ut_asserteq(strlen(cmd2), cli_readline(""));
35         ut_assert_nextline(cmd2);
36
37         ut_assertok(run_command("print fred", 0));
38         ut_assert_nextline("fred=hello");
39         ut_assert_console_end();
40
41         ut_assertok(run_command("history", 0));
42         ut_assert_nextline(cmd1);
43         ut_assert_nextline(cmd2);
44         ut_assert_console_end();
45
46         return 0;
47 }
48 LIB_TEST(lib_test_history, UTF_CONSOLE_REC);
This page took 0.027561 seconds and 4 git commands to generate.