[Concept,04/16] boot: pxe: Stop after first boot attempt on sandbox

Message ID 20260109015323.3411528-5-sjg@u-boot.org
State New
Headers
Series test: pxe: Add some decent tests for the PXE/extlinux parser |

Commit Message

Simon Glass Jan. 9, 2026, 1:53 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Sandbox cannot actually boot a kernel, so there is no point in trying
subsequent labels after the first boot attempt fails. Return success
after the boot attempt so that sysboot stops, allowing tests to verify
that files were loaded correctly.

This change only affects sandbox builds.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 boot/pxe_utils.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
  

Patch

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 981023a3012..ba1f7c41512 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -849,9 +849,15 @@  static int label_boot(struct pxe_context *ctx, struct pxe_label *label)
 	label_run_boot(ctx, label, kern_addr_str, kern_addr, kern_size,
 		       initrd_addr, initrd_size, initrd_str, conf_fdt_str,
 		       conf_fdt);
-	/* ignore the error value since we are going to fail anyway */
 
-	return 1;	/* returning is always failure */
+	/*
+	 * Sandbox cannot boot a real kernel, so stop after the first attempt.
+	 * On real hardware, returning is always failure, so try next label.
+	 */
+	if (IS_ENABLED(CONFIG_SANDBOX))
+		return 0;
+
+	return 1;
 }
 
 /*