mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-21 04:14:34 +00:00
efi_selftest: do not execute test if setup failed
Executing a test after failed setup may lead to unexpected behavior like an illegal memory access. So after a setup failure we should skip to teardown. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
c524997acb
commit
b5cd6878e4
2 changed files with 9 additions and 7 deletions
|
@ -114,6 +114,7 @@ u16 efi_st_get_key(void);
|
||||||
* @setup: set up the unit test
|
* @setup: set up the unit test
|
||||||
* @teardown: tear down the unit test
|
* @teardown: tear down the unit test
|
||||||
* @execute: execute the unit test
|
* @execute: execute the unit test
|
||||||
|
* @setup_ok: setup was successful (set at runtime)
|
||||||
* @on_request: test is only executed on request
|
* @on_request: test is only executed on request
|
||||||
*/
|
*/
|
||||||
struct efi_unit_test {
|
struct efi_unit_test {
|
||||||
|
@ -123,6 +124,7 @@ struct efi_unit_test {
|
||||||
const struct efi_system_table *systable);
|
const struct efi_system_table *systable);
|
||||||
int (*execute)(void);
|
int (*execute)(void);
|
||||||
int (*teardown)(void);
|
int (*teardown)(void);
|
||||||
|
int setup_ok;
|
||||||
bool on_request;
|
bool on_request;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -77,20 +77,20 @@ void efi_st_exit_boot_services(void)
|
||||||
*/
|
*/
|
||||||
static int setup(struct efi_unit_test *test, unsigned int *failures)
|
static int setup(struct efi_unit_test *test, unsigned int *failures)
|
||||||
{
|
{
|
||||||
int ret;
|
if (!test->setup) {
|
||||||
|
test->setup_ok = EFI_ST_SUCCESS;
|
||||||
if (!test->setup)
|
|
||||||
return EFI_ST_SUCCESS;
|
return EFI_ST_SUCCESS;
|
||||||
|
}
|
||||||
efi_st_printc(EFI_LIGHTBLUE, "\nSetting up '%s'\n", test->name);
|
efi_st_printc(EFI_LIGHTBLUE, "\nSetting up '%s'\n", test->name);
|
||||||
ret = test->setup(handle, systable);
|
test->setup_ok = test->setup(handle, systable);
|
||||||
if (ret != EFI_ST_SUCCESS) {
|
if (test->setup_ok != EFI_ST_SUCCESS) {
|
||||||
efi_st_error("Setting up '%s' failed\n", test->name);
|
efi_st_error("Setting up '%s' failed\n", test->name);
|
||||||
++*failures;
|
++*failures;
|
||||||
} else {
|
} else {
|
||||||
efi_st_printc(EFI_LIGHTGREEN,
|
efi_st_printc(EFI_LIGHTGREEN,
|
||||||
"Setting up '%s' succeeded\n", test->name);
|
"Setting up '%s' succeeded\n", test->name);
|
||||||
}
|
}
|
||||||
return ret;
|
return test->setup_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -200,7 +200,7 @@ void efi_st_do_tests(const u16 *testname, unsigned int phase,
|
||||||
continue;
|
continue;
|
||||||
if (steps & EFI_ST_SETUP)
|
if (steps & EFI_ST_SETUP)
|
||||||
setup(test, failures);
|
setup(test, failures);
|
||||||
if (steps & EFI_ST_EXECUTE)
|
if (steps & EFI_ST_EXECUTE && test->setup_ok == EFI_ST_SUCCESS)
|
||||||
execute(test, failures);
|
execute(test, failures);
|
||||||
if (steps & EFI_ST_TEARDOWN)
|
if (steps & EFI_ST_TEARDOWN)
|
||||||
teardown(test, failures);
|
teardown(test, failures);
|
||||||
|
|
Loading…
Add table
Reference in a new issue