Linus Walleij | bef3925 | 2023-02-01 00:16:13 +0100 | [diff] [blame] | 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 | |
Linus Walleij | bef3925 | 2023-02-01 00:16:13 +0100 | [diff] [blame] | 8 | #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 | |
| 16 | static int seama_test_noargs(struct unit_test_state *uts) |
| 17 | { |
| 18 | /* Test that 'seama' with no arguments fails gracefully */ |
| 19 | console_record_reset(); |
| 20 | run_command("seama", 0); |
| 21 | ut_assert_nextlinen("seama - Load the SEAMA image and sets envs"); |
| 22 | ut_assert_skipline(); |
| 23 | ut_assert_skipline(); |
| 24 | ut_assert_skipline(); |
| 25 | ut_assert_skipline(); |
| 26 | ut_assert_console_end(); |
| 27 | return 0; |
| 28 | } |
| 29 | SEAMA_TEST(seama_test_noargs, UT_TESTF_CONSOLE_REC); |
| 30 | |
| 31 | static int seama_test_addr(struct unit_test_state *uts) |
| 32 | { |
| 33 | /* Test that loads SEAMA image 0 to address 0x01000000 */ |
| 34 | console_record_reset(); |
| 35 | run_command("seama 0x01000000", 0); |
| 36 | ut_assert_nextlinen("Loading SEAMA image 0 from nand0"); |
| 37 | ut_assert_nextlinen("SEMA IMAGE:"); |
| 38 | ut_assert_nextlinen(" metadata size "); |
| 39 | ut_assert_nextlinen(" image size "); |
| 40 | ut_assert_nextlinen(" checksum "); |
| 41 | ut_assert_nextlinen("Decoding SEAMA image 0x01000040.."); |
| 42 | ut_assert_console_end(); |
| 43 | return 0; |
| 44 | } |
| 45 | SEAMA_TEST(seama_test_addr, UT_TESTF_CONSOLE_REC); |
| 46 | |
| 47 | static int seama_test_index(struct unit_test_state *uts) |
| 48 | { |
| 49 | /* Test that loads SEAMA image 0 exlicitly specified */ |
| 50 | console_record_reset(); |
| 51 | run_command("seama 0x01000000 0", 0); |
| 52 | ut_assert_nextlinen("Loading SEAMA image 0 from nand0"); |
| 53 | ut_assert_nextlinen("SEMA IMAGE:"); |
| 54 | ut_assert_nextlinen(" metadata size "); |
| 55 | ut_assert_nextlinen(" image size "); |
| 56 | ut_assert_nextlinen(" checksum "); |
| 57 | ut_assert_nextlinen("Decoding SEAMA image 0x01000040.."); |
| 58 | ut_assert_console_end(); |
| 59 | return 0; |
| 60 | } |
| 61 | SEAMA_TEST(seama_test_index, UT_TESTF_CONSOLE_REC); |
| 62 | |
| 63 | int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
| 64 | { |
| 65 | struct unit_test *tests = UNIT_TEST_SUITE_START(seama_test); |
| 66 | const int n_ents = UNIT_TEST_SUITE_COUNT(seama_test); |
| 67 | |
| 68 | return cmd_ut_category("seama", "seama_test_", tests, n_ents, argc, |
| 69 | argv); |
| 70 | } |