blob: 28d6b9ab517d650f1b234045d2da3cfef1ae9c55 [file] [log] [blame]
Linus Walleijbef39252023-02-01 00:16:13 +01001// 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
Linus Walleijbef39252023-02-01 00:16:13 +01008#include <command.h>
9#include <dm.h>
10#include <test/suites.h>
11#include <test/test.h>
12#include <test/ut.h>
13
14#define SEAMA_TEST(_name, _flags) UNIT_TEST(_name, _flags, seama_test)
15
16static int seama_test_noargs(struct unit_test_state *uts)
17{
18 /* Test that 'seama' with no arguments fails gracefully */
Linus Walleijbef39252023-02-01 00:16:13 +010019 run_command("seama", 0);
20 ut_assert_nextlinen("seama - Load the SEAMA image and sets envs");
21 ut_assert_skipline();
22 ut_assert_skipline();
23 ut_assert_skipline();
24 ut_assert_skipline();
25 ut_assert_console_end();
26 return 0;
27}
Simon Glass11fcfa32024-08-22 07:57:50 -060028SEAMA_TEST(seama_test_noargs, UTF_CONSOLE);
Linus Walleijbef39252023-02-01 00:16:13 +010029
30static int seama_test_addr(struct unit_test_state *uts)
31{
32 /* Test that loads SEAMA image 0 to address 0x01000000 */
Linus Walleijbef39252023-02-01 00:16:13 +010033 run_command("seama 0x01000000", 0);
34 ut_assert_nextlinen("Loading SEAMA image 0 from nand0");
35 ut_assert_nextlinen("SEMA IMAGE:");
36 ut_assert_nextlinen(" metadata size ");
37 ut_assert_nextlinen(" image size ");
38 ut_assert_nextlinen(" checksum ");
39 ut_assert_nextlinen("Decoding SEAMA image 0x01000040..");
40 ut_assert_console_end();
41 return 0;
42}
Simon Glass11fcfa32024-08-22 07:57:50 -060043SEAMA_TEST(seama_test_addr, UTF_CONSOLE);
Linus Walleijbef39252023-02-01 00:16:13 +010044
45static int seama_test_index(struct unit_test_state *uts)
46{
47 /* Test that loads SEAMA image 0 exlicitly specified */
Linus Walleijbef39252023-02-01 00:16:13 +010048 run_command("seama 0x01000000 0", 0);
49 ut_assert_nextlinen("Loading SEAMA image 0 from nand0");
50 ut_assert_nextlinen("SEMA IMAGE:");
51 ut_assert_nextlinen(" metadata size ");
52 ut_assert_nextlinen(" image size ");
53 ut_assert_nextlinen(" checksum ");
54 ut_assert_nextlinen("Decoding SEAMA image 0x01000040..");
55 ut_assert_console_end();
56 return 0;
57}
Simon Glass11fcfa32024-08-22 07:57:50 -060058SEAMA_TEST(seama_test_index, UTF_CONSOLE);
Linus Walleijbef39252023-02-01 00:16:13 +010059
60int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
61{
62 struct unit_test *tests = UNIT_TEST_SUITE_START(seama_test);
63 const int n_ents = UNIT_TEST_SUITE_COUNT(seama_test);
64
65 return cmd_ut_category("seama", "seama_test_", tests, n_ents, argc,
66 argv);
67}