]> git.ipfire.org Git - thirdparty/u-boot.git/blame - test/cmd/history.c
test: Remove <common.h> and add needed includes
[thirdparty/u-boot.git] / test / cmd / history.c
CommitLineData
33eb0b9e
SG
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Tests for history command
4 *
5 * Copyright 2023 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
7 */
8
33eb0b9e
SG
9#include <cli.h>
10#include <command.h>
11#include <test/lib.h>
12#include <test/test.h>
13#include <test/ut.h>
14
15static 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}
48LIB_TEST(lib_test_history, UT_TESTF_CONSOLE_REC);