1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Executes tests for SEAMA (SEAttle iMAge) command
4 *
5 * Copyright (C) 2021 Linus Walleij <linus.walleij@linaro.org>
6 */
7
8 #include <common.h>
9 #include <command.h>
10 #include <dm.h>
11 #include <test/suites.h>
12 #include <test/test.h>
13 #include <test/ut.h>
14
15 #define SEAMA_TEST(_name, _flags) UNIT_TEST(_name, _flags, seama_test)
16
seama_test_noargs(struct unit_test_state * uts)17 static int seama_test_noargs(struct unit_test_state *uts)
18 {
19 /* Test that 'seama' with no arguments fails gracefully */
20 console_record_reset();
21 run_command("seama", 0);
22 ut_assert_nextlinen("seama - Load the SEAMA image and sets envs");
23 ut_assert_skipline();
24 ut_assert_skipline();
25 ut_assert_skipline();
26 ut_assert_skipline();
27 ut_assert_console_end();
28 return 0;
29 }
30 SEAMA_TEST(seama_test_noargs, UT_TESTF_CONSOLE_REC);
31
seama_test_addr(struct unit_test_state * uts)32 static int seama_test_addr(struct unit_test_state *uts)
33 {
34 /* Test that loads SEAMA image 0 to address 0x01000000 */
35 console_record_reset();
36 run_command("seama 0x01000000", 0);
37 ut_assert_nextlinen("Loading SEAMA image 0 from nand0");
38 ut_assert_nextlinen("SEMA IMAGE:");
39 ut_assert_nextlinen(" metadata size ");
40 ut_assert_nextlinen(" image size ");
41 ut_assert_nextlinen(" checksum ");
42 ut_assert_nextlinen("Decoding SEAMA image 0x01000040..");
43 ut_assert_console_end();
44 return 0;
45 }
46 SEAMA_TEST(seama_test_addr, UT_TESTF_CONSOLE_REC);
47
seama_test_index(struct unit_test_state * uts)48 static int seama_test_index(struct unit_test_state *uts)
49 {
50 /* Test that loads SEAMA image 0 exlicitly specified */
51 console_record_reset();
52 run_command("seama 0x01000000 0", 0);
53 ut_assert_nextlinen("Loading SEAMA image 0 from nand0");
54 ut_assert_nextlinen("SEMA IMAGE:");
55 ut_assert_nextlinen(" metadata size ");
56 ut_assert_nextlinen(" image size ");
57 ut_assert_nextlinen(" checksum ");
58 ut_assert_nextlinen("Decoding SEAMA image 0x01000040..");
59 ut_assert_console_end();
60 return 0;
61 }
62 SEAMA_TEST(seama_test_index, UT_TESTF_CONSOLE_REC);
63
do_ut_seama(struct cmd_tbl * cmdtp,int flag,int argc,char * const argv[])64 int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
65 {
66 struct unit_test *tests = UNIT_TEST_SUITE_START(seama_test);
67 const int n_ents = UNIT_TEST_SUITE_COUNT(seama_test);
68
69 return cmd_ut_category("seama", "seama_test_", tests, n_ents, argc,
70 argv);
71 }
72