diff mbox series

[RFC,v2,28/48] test: cedit: use allocated address for reading file

Message ID 20240704073544.670249-29-sughosh.ganu@linaro.org
State Superseded
Headers show
Series Make U-Boot memory reservations coherent | expand

Commit Message

Sughosh Ganu July 4, 2024, 7:35 a.m. UTC
Instead of a randomly selected address, use an LMB allocated one for
reading the file into memory. With the LMB map now being persistent
and global, the address used for reading the file might be already
allocated as non-overwritable, resulting in a failure. Get a valid
address from LMB and then read the file to that address.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
Changes since V1:
* Free up the memory allocated once done with it.

 test/boot/cedit.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/test/boot/cedit.c b/test/boot/cedit.c
index fd19da0a0c..923ddd1481 100644
--- a/test/boot/cedit.c
+++ b/test/boot/cedit.c
@@ -7,6 +7,7 @@ 
 #include <cedit.h>
 #include <env.h>
 #include <expo.h>
+#include <lmb.h>
 #include <mapmem.h>
 #include <dm/ofnode.h>
 #include <test/ut.h>
@@ -61,7 +62,7 @@  static int cedit_fdt(struct unit_test_state *uts)
 	struct video_priv *vid_priv;
 	extern struct expo *cur_exp;
 	struct scene_obj_menu *menu;
-	ulong addr = 0x1000;
+	ulong addr;
 	struct ofprop prop;
 	struct scene *scn;
 	oftree tree;
@@ -86,6 +87,8 @@  static int cedit_fdt(struct unit_test_state *uts)
 	str = abuf_data(&tline->buf);
 	strcpy(str, "my-machine");
 
+	addr = lmb_alloc(1024, 1024);
+	ut_asserteq(!!addr, !0);
 	ut_assertok(run_command("cedit write_fdt hostfs - settings.dtb", 0));
 	ut_assertok(run_commandf("load hostfs - %lx settings.dtb", addr));
 	ut_assert_nextlinen("1024 bytes read");
@@ -94,6 +97,7 @@  static int cedit_fdt(struct unit_test_state *uts)
 	tree = oftree_from_fdt(fdt);
 	node = ofnode_find_subnode(oftree_root(tree), CEDIT_NODE_NAME);
 	ut_assert(ofnode_valid(node));
+	lmb_free(addr, 1024);
 
 	ut_asserteq(ID_CPU_SPEED_2,
 		    ofnode_read_u32_default(node, "cpu-speed", 0));