From: Simon Glass <simon.glass@canonical.com> When parsing a kernel label, add the kernel path to the files list with type PFT_KERNEL. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- boot/pxe_parse.c | 15 +++++++-------- test/boot/pxe.c | 32 ++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index 51fce1d5737..8bd9d66f486 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -547,16 +547,15 @@ static int parse_label_kernel(char **c, struct pxe_label *label) return -ENOMEM; s = strstr(label->kernel, "#"); - if (!s) - return 1; - - label->config = strdup(s); - if (!label->config) - return -ENOMEM; + if (s) { + label->config = strdup(s); + if (!label->config) + return -ENOMEM; - *s = 0; + *s = 0; + } - return 1; + return label_add_file(label, label->kernel, PFT_KERNEL) ? : 1; } /* diff --git a/test/boot/pxe.c b/test/boot/pxe.c index df7cf2a781a..6b2d521c8e8 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -190,11 +190,13 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq_str("/initrd.img", label->initrd); ut_asserteq_str("/dtb/board.dtb", label->fdt); ut_assertnull(label->fdtdir); - ut_asserteq(2, label->files.count); - ut_asserteq_str("/dtb/overlay1.dtbo", + ut_asserteq(3, label->files.count); + ut_asserteq_str("/vmlinuz", alist_get(&label->files, 0, struct pxe_file)->path); - ut_asserteq_str("/dtb/overlay2.dtbo", + ut_asserteq_str("/dtb/overlay1.dtbo", alist_get(&label->files, 1, struct pxe_file)->path); + ut_asserteq_str("/dtb/overlay2.dtbo", + alist_get(&label->files, 2, struct pxe_file)->path); ut_asserteq_str("Booting default Linux kernel", label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -214,7 +216,9 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->initrd); ut_assertnull(label->fdt); ut_asserteq_str("/dtb/", label->fdtdir); - ut_asserteq(0, label->files.count); + ut_asserteq(1, label->files.count); + ut_asserteq_str("/vmlinuz-rescue", + alist_get(&label->files, 0, struct pxe_file)->path); ut_assertnull(label->say); ut_asserteq(3, label->ipappend); ut_asserteq(0, label->attempted); @@ -254,7 +258,9 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->initrd); ut_assertnull(label->fdt); ut_assertnull(label->fdtdir); - ut_asserteq(0, label->files.count); + ut_asserteq(1, label->files.count); + ut_asserteq_str("/boot/image.fit", + alist_get(&label->files, 0, struct pxe_file)->path); ut_assertnull(label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -274,7 +280,9 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->initrd); ut_assertnull(label->fdt); ut_assertnull(label->fdtdir); - ut_asserteq(0, label->files.count); + ut_asserteq(1, label->files.count); + ut_asserteq_str("/boot/included-kernel", + alist_get(&label->files, 0, struct pxe_file)->path); ut_assertnull(label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -296,7 +304,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) * environment, and verify overlay files can be loaded. */ label = list_first_entry(&cfg->labels, struct pxe_label, list); - ut_asserteq(2, label->files.count); + ut_asserteq(3, label->files.count); /* Set environment variables for file loading */ ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); @@ -315,15 +323,15 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq(PXE_KERNEL_ADDR, ctx.kern_addr); ut_asserteq(PXE_FDT_ADDR, ctx.fdt_addr); - /* Verify overlays were loaded to valid addresses */ - ut_assert(alist_get(&label->files, 0, - struct pxe_file)->addr >= PXE_OVERLAY_ADDR); + /* Verify overlays were loaded to valid addresses (indices 1 and 2) */ ut_assert(alist_get(&label->files, 1, struct pxe_file)->addr >= PXE_OVERLAY_ADDR); + ut_assert(alist_get(&label->files, 2, + struct pxe_file)->addr >= PXE_OVERLAY_ADDR); /* Second overlay should be at a higher address than the first */ - ut_assert(alist_get(&label->files, 1, struct pxe_file)->addr > - alist_get(&label->files, 0, struct pxe_file)->addr); + ut_assert(alist_get(&label->files, 2, struct pxe_file)->addr > + alist_get(&label->files, 1, struct pxe_file)->addr); /* Verify no more console output */ ut_assert_console_end(); -- 2.43.0