blob: dff8a97d1396d5f000b815711b591d6085a158c8 [file] [log] [blame]
Rui Miguel Silvabfef72e2022-05-11 10:55:40 +01001// 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
Rui Miguel Silvabfef72e2022-05-11 10:55:40 +010012#include <console.h>
13#include <mapmem.h>
14#include <asm/global_data.h>
15#include <dm/test.h>
16#include <test/suites.h>
17#include <test/test.h>
18#include <test/ut.h>
19
20#define BUF_SIZE 0x100
21
22#define LOADM_TEST(_name, _flags) UNIT_TEST(_name, _flags, loadm_test)
23
24static int loadm_test_params(struct unit_test_state *uts)
25{
26 ut_assertok(console_record_reset_enable());
27 run_command("loadm", 0);
28 ut_assert_nextline("loadm - load binary blob from source address to destination address");
29
30 ut_assertok(console_record_reset_enable());
31 run_command("loadm 0x12345678", 0);
32 ut_assert_nextline("loadm - load binary blob from source address to destination address");
33
34 ut_assertok(console_record_reset_enable());
35 run_command("loadm 0x12345678 0x12345678", 0);
36 ut_assert_nextline("loadm - load binary blob from source address to destination address");
37
38 ut_assertok(console_record_reset_enable());
39 run_command("loadm 0x12345678 0x12345678 0", 0);
40 ut_assert_nextline("loadm: can not load zero bytes");
41
42 return 0;
43}
44LOADM_TEST(loadm_test_params, UT_TESTF_CONSOLE_REC);
45
46static int loadm_test_load (struct unit_test_state *uts)
47{
48 char *buf;
49
50 buf = map_sysmem(0, BUF_SIZE);
51 memset(buf, '\0', BUF_SIZE);
52 memset(buf, 0xaa, BUF_SIZE / 2);
53
54 ut_assertok(console_record_reset_enable());
55 run_command("loadm 0x0 0x80 0x80", 0);
56 ut_assert_nextline("loaded bin to memory: size: 128");
57
58 unmap_sysmem(buf);
59
60 return 0;
61}
62LOADM_TEST(loadm_test_load, UT_TESTF_CONSOLE_REC);
63
64int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
65{
66 struct unit_test *tests = UNIT_TEST_SUITE_START(loadm_test);
67 const int n_ents = UNIT_TEST_SUITE_COUNT(loadm_test);
68
69 return cmd_ut_category("loadm", "loadm_test_", tests, n_ents, argc,
70 argv);
71}