Rui Miguel Silva | 433f15a | 2022-05-11 10:55:40 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Test for loadm command |
| 4 | * |
| 5 | * Copyright 2022 ARM Limited |
| 6 | * Copyright 2022 Linaro |
| 7 | * |
| 8 | * Authors: |
| 9 | * Rui Miguel Silva <rui.silva@linaro.org> |
| 10 | */ |
| 11 | |
Tom Rini | abb9a04 | 2024-05-18 20:20:43 -0600 | [diff] [blame] | 12 | #include <common.h> |
Rui Miguel Silva | 433f15a | 2022-05-11 10:55:40 +0100 | [diff] [blame] | 13 | #include <console.h> |
| 14 | #include <mapmem.h> |
| 15 | #include <asm/global_data.h> |
| 16 | #include <dm/test.h> |
| 17 | #include <test/suites.h> |
| 18 | #include <test/test.h> |
| 19 | #include <test/ut.h> |
| 20 | |
| 21 | #define BUF_SIZE 0x100 |
| 22 | |
| 23 | #define LOADM_TEST(_name, _flags) UNIT_TEST(_name, _flags, loadm_test) |
| 24 | |
| 25 | static int loadm_test_params(struct unit_test_state *uts) |
| 26 | { |
| 27 | ut_assertok(console_record_reset_enable()); |
| 28 | run_command("loadm", 0); |
| 29 | ut_assert_nextline("loadm - load binary blob from source address to destination address"); |
| 30 | |
| 31 | ut_assertok(console_record_reset_enable()); |
| 32 | run_command("loadm 0x12345678", 0); |
| 33 | ut_assert_nextline("loadm - load binary blob from source address to destination address"); |
| 34 | |
| 35 | ut_assertok(console_record_reset_enable()); |
| 36 | run_command("loadm 0x12345678 0x12345678", 0); |
| 37 | ut_assert_nextline("loadm - load binary blob from source address to destination address"); |
| 38 | |
| 39 | ut_assertok(console_record_reset_enable()); |
| 40 | run_command("loadm 0x12345678 0x12345678 0", 0); |
| 41 | ut_assert_nextline("loadm: can not load zero bytes"); |
| 42 | |
| 43 | return 0; |
| 44 | } |
| 45 | LOADM_TEST(loadm_test_params, UT_TESTF_CONSOLE_REC); |
| 46 | |
| 47 | static int loadm_test_load (struct unit_test_state *uts) |
| 48 | { |
| 49 | char *buf; |
| 50 | |
| 51 | buf = map_sysmem(0, BUF_SIZE); |
| 52 | memset(buf, '\0', BUF_SIZE); |
| 53 | memset(buf, 0xaa, BUF_SIZE / 2); |
| 54 | |
| 55 | ut_assertok(console_record_reset_enable()); |
| 56 | run_command("loadm 0x0 0x80 0x80", 0); |
| 57 | ut_assert_nextline("loaded bin to memory: size: 128"); |
| 58 | |
| 59 | unmap_sysmem(buf); |
| 60 | |
| 61 | return 0; |
| 62 | } |
| 63 | LOADM_TEST(loadm_test_load, UT_TESTF_CONSOLE_REC); |
| 64 | |
| 65 | int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
| 66 | { |
| 67 | struct unit_test *tests = UNIT_TEST_SUITE_START(loadm_test); |
| 68 | const int n_ents = UNIT_TEST_SUITE_COUNT(loadm_test); |
| 69 | |
| 70 | return cmd_ut_category("loadm", "loadm_test_", tests, n_ents, argc, |
| 71 | argv); |
| 72 | } |