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, points BootOrder at a load option that does not exist and checks that booting the bootflow returns -EIO 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. 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 | 35 +++++++++++++++++++++++++++++++++++ test/py/tests/test_ut.py | 3 ++- 3 files changed, 41 insertions(+), 2 deletions(-) -- 2.43.0
