]> git.ipfire.org Git - thirdparty/u-boot.git/blame - test/cmd/history.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[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
d678a59d 9#include <common.h>
33eb0b9e
SG
10#include <cli.h>
11#include <command.h>
12#include <test/lib.h>
13#include <test/test.h>
14#include <test/ut.h>
15
16static int lib_test_history(struct unit_test_state *uts)
17{
18 static const char cmd1[] = "setenv fred hello";
19 static const char cmd2[] = "print fred";
20
21 /* running commands directly does not add to history */
22 ut_assertok(run_command(cmd1, 0));
23 ut_assert_console_end();
24 ut_assertok(run_command("history", 0));
25 ut_assert_console_end();
26
27 /* enter commands via the console */
28 console_in_puts(cmd1);
29 console_in_puts("\n");
30 ut_asserteq(strlen(cmd1), cli_readline(""));
31 ut_assert_nextline(cmd1);
32
33 console_in_puts(cmd2);
34 console_in_puts("\n");
35 ut_asserteq(strlen(cmd2), cli_readline(""));
36 ut_assert_nextline(cmd2);
37
38 ut_assertok(run_command("print fred", 0));
39 ut_assert_nextline("fred=hello");
40 ut_assert_console_end();
41
42 ut_assertok(run_command("history", 0));
43 ut_assert_nextline(cmd1);
44 ut_assert_nextline(cmd2);
45 ut_assert_console_end();
46
47 return 0;
48}
49LIB_TEST(lib_test_history, UT_TESTF_CONSOLE_REC);