mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-25 14:56:03 +00:00
efi_selftest: test exit_data
Amend the unit test 'start image exit' to transfer a string as exit data. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
parent
556d8dc937
commit
a9a25cc3e7
3 changed files with 27 additions and 7 deletions
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#define EFI_ST_SUCCESS 0
|
#define EFI_ST_SUCCESS 0
|
||||||
#define EFI_ST_FAILURE 1
|
#define EFI_ST_FAILURE 1
|
||||||
|
#define EFI_ST_SUCCESS_STR L"SUCCESS"
|
||||||
/*
|
/*
|
||||||
* Prints a message.
|
* Prints a message.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <efi_api.h>
|
#include <efi_selftest.h>
|
||||||
|
|
||||||
static efi_guid_t loaded_image_protocol_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
static efi_guid_t loaded_image_protocol_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
||||||
|
|
||||||
|
@ -66,15 +66,22 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
|
||||||
struct efi_system_table *systable)
|
struct efi_system_table *systable)
|
||||||
{
|
{
|
||||||
struct efi_simple_text_output_protocol *con_out = systable->con_out;
|
struct efi_simple_text_output_protocol *con_out = systable->con_out;
|
||||||
efi_status_t ret = EFI_UNSUPPORTED;
|
efi_status_t ret;
|
||||||
|
u16 text[] = EFI_ST_SUCCESS_STR;
|
||||||
|
|
||||||
con_out->output_string(con_out, L"EFI application calling Exit\n");
|
con_out->output_string(con_out, L"EFI application calling Exit\n");
|
||||||
|
|
||||||
if (check_loaded_image_protocol(handle, systable) != EFI_SUCCESS)
|
if (check_loaded_image_protocol(handle, systable) != EFI_SUCCESS) {
|
||||||
|
con_out->output_string(con_out,
|
||||||
|
L"Loaded image protocol missing\n");
|
||||||
ret = EFI_NOT_FOUND;
|
ret = EFI_NOT_FOUND;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/* The return value is checked by the calling test */
|
/* This return value is expected by the calling test */
|
||||||
systable->boottime->exit(handle, ret, 0, NULL);
|
ret = EFI_UNSUPPORTED;
|
||||||
|
out:
|
||||||
|
systable->boottime->exit(handle, ret, sizeof(text), text);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This statement should not be reached.
|
* This statement should not be reached.
|
||||||
|
|
|
@ -123,6 +123,9 @@ static int execute(void)
|
||||||
{
|
{
|
||||||
efi_status_t ret;
|
efi_status_t ret;
|
||||||
efi_handle_t handle;
|
efi_handle_t handle;
|
||||||
|
efi_uintn_t exit_data_size = 0;
|
||||||
|
u16 *exit_data = NULL;
|
||||||
|
u16 expected_text[] = EFI_ST_SUCCESS_STR;
|
||||||
|
|
||||||
ret = boottime->load_image(false, image_handle, NULL, image,
|
ret = boottime->load_image(false, image_handle, NULL, image,
|
||||||
img.length, &handle);
|
img.length, &handle);
|
||||||
|
@ -130,11 +133,21 @@ static int execute(void)
|
||||||
efi_st_error("Failed to load image\n");
|
efi_st_error("Failed to load image\n");
|
||||||
return EFI_ST_FAILURE;
|
return EFI_ST_FAILURE;
|
||||||
}
|
}
|
||||||
ret = boottime->start_image(handle, NULL, NULL);
|
ret = boottime->start_image(handle, &exit_data_size, &exit_data);
|
||||||
if (ret != EFI_UNSUPPORTED) {
|
if (ret != EFI_UNSUPPORTED) {
|
||||||
efi_st_error("Wrong return value from application\n");
|
efi_st_error("Wrong return value from application\n");
|
||||||
return EFI_ST_FAILURE;
|
return EFI_ST_FAILURE;
|
||||||
}
|
}
|
||||||
|
if (!exit_data || exit_data_size != sizeof(expected_text) ||
|
||||||
|
efi_st_memcmp(exit_data, expected_text, sizeof(expected_text))) {
|
||||||
|
efi_st_error("Incorrect exit data\n");
|
||||||
|
return EFI_ST_FAILURE;
|
||||||
|
}
|
||||||
|
ret = boottime->free_pool(exit_data);
|
||||||
|
if (ret != EFI_SUCCESS) {
|
||||||
|
efi_st_error("Failed to free exit data\n");
|
||||||
|
return EFI_ST_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
return EFI_ST_SUCCESS;
|
return EFI_ST_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue