When the EFI boot manager fails, efi_mgr_boot() assigns the status returned by efi_bootmgr_run() to a local variable and then returns 0. A zero return from a bootmeth's boot() method means "should not get here", so bootflow_boot() reports -EFAULT for every boot manager failure and the real cause (no boot option loadable, load error, ...) is lost. The unused assignment also trips -Wunused-but-set-variable on newer compilers.
Patch 1 maps the EFI status to an errno instead: EFI_NOT_FOUND (no BootOrder) becomes -ENOENT and any other failure -EIO, so 'bootflow boot' now prints an error that reflects what actually happened. Patch 2 adds a bootstd test for the error path, which was previously unreachable from any test: it binds the efi_mgr bootmeth, removes the BootOrder variable so that the boot manager has nothing to load and checks that booting the bootflow returns -ENOENT rather than -EFAULT. Running the real boot manager initialises the EFI subsystem in the sandbox process, which would leak into later tests, so the test is also added to the restart list in test_ut.py like the other session-changing tests. Tested on sandbox: the new test fails with -EFAULT before patch 1 and passes after it, and the full bootstd suite passes at each commit. The test also passes with Heinrich's "cmd/efidebug: do not allow invalid boot order" applied on top. Changes in v2: - Remove BootOrder in the test instead of pointing it at a non-existent load option, which relied on efidebug accepting invalid input (Heinrich) Aristo Chen (2): bootmeth: efi_mgr: Do not discard the EFI boot manager error test: boot: Check that efi_mgr boot failures are reported boot/bootmeth_efi_mgr.c | 5 ++++- test/boot/bootflow.c | 40 ++++++++++++++++++++++++++++++++++++++++ test/py/tests/test_ut.py | 3 ++- 3 files changed, 46 insertions(+), 2 deletions(-) -- 2.43.0
