blob: 043cd25dfb61527ca92cf83e485e7f45b256809a [file] [log] [blame]
Rui Miguel Silva433f15a2022-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 Silva433f15a2022-05-11 10:55:40 +010012#include <console.h>
13#include <mapmem.h>
14#include <asm/global_data.h>
15#include <dm/test.h>
Rui Miguel Silva433f15a2022-05-11 10:55:40 +010016#include <test/test.h>
17#include <test/ut.h>
18
19#define BUF_SIZE 0x100
20
Simon Glassb15512c2025-01-20 14:25:32 -070021#define LOADM_TEST(_name, _flags) UNIT_TEST(_name, _flags, loadm)
Rui Miguel Silva433f15a2022-05-11 10:55:40 +010022
23static int loadm_test_params(struct unit_test_state *uts)
24{
Rui Miguel Silva433f15a2022-05-11 10:55:40 +010025 run_command("loadm", 0);
26 ut_assert_nextline("loadm - load binary blob from source address to destination address");
27
28 ut_assertok(console_record_reset_enable());
29 run_command("loadm 0x12345678", 0);
30 ut_assert_nextline("loadm - load binary blob from source address to destination address");
31
32 ut_assertok(console_record_reset_enable());
33 run_command("loadm 0x12345678 0x12345678", 0);
34 ut_assert_nextline("loadm - load binary blob from source address to destination address");
35
36 ut_assertok(console_record_reset_enable());
37 run_command("loadm 0x12345678 0x12345678 0", 0);
38 ut_assert_nextline("loadm: can not load zero bytes");
39
40 return 0;
41}
Simon Glass11fcfa32024-08-22 07:57:50 -060042LOADM_TEST(loadm_test_params, UTF_CONSOLE);
Rui Miguel Silva433f15a2022-05-11 10:55:40 +010043
44static int loadm_test_load (struct unit_test_state *uts)
45{
46 char *buf;
47
48 buf = map_sysmem(0, BUF_SIZE);
49 memset(buf, '\0', BUF_SIZE);
50 memset(buf, 0xaa, BUF_SIZE / 2);
51
Rui Miguel Silva433f15a2022-05-11 10:55:40 +010052 run_command("loadm 0x0 0x80 0x80", 0);
53 ut_assert_nextline("loaded bin to memory: size: 128");
54
55 unmap_sysmem(buf);
56
57 return 0;
58}
Simon Glass11fcfa32024-08-22 07:57:50 -060059LOADM_TEST(loadm_test_load, UTF_CONSOLE);