mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-27 16:01:27 +00:00
efi_selftest: colored test output
Add color coding to output: test section blue success green errors red todo yellow summary white others light gray Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> [agraf: Fold in move of set_attribute before the print] Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
ac02019616
commit
853540c84f
3 changed files with 40 additions and 25 deletions
|
@ -18,14 +18,20 @@
|
||||||
#define EFI_ST_SUCCESS 0
|
#define EFI_ST_SUCCESS 0
|
||||||
#define EFI_ST_FAILURE 1
|
#define EFI_ST_FAILURE 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prints a message.
|
||||||
|
*/
|
||||||
|
#define efi_st_printf(...) \
|
||||||
|
(efi_st_printc(-1, __VA_ARGS__))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prints an error message.
|
* Prints an error message.
|
||||||
*
|
*
|
||||||
* @... format string followed by fields to print
|
* @... format string followed by fields to print
|
||||||
*/
|
*/
|
||||||
#define efi_st_error(...) \
|
#define efi_st_error(...) \
|
||||||
(efi_st_printf("%s(%u):\nERROR: ", __FILE__, __LINE__), \
|
(efi_st_printc(EFI_LIGHTRED, "%s(%u):\nERROR: ", __FILE__, __LINE__), \
|
||||||
efi_st_printf(__VA_ARGS__)) \
|
efi_st_printc(EFI_LIGHTRED, __VA_ARGS__))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prints a TODO message.
|
* Prints a TODO message.
|
||||||
|
@ -33,8 +39,8 @@
|
||||||
* @... format string followed by fields to print
|
* @... format string followed by fields to print
|
||||||
*/
|
*/
|
||||||
#define efi_st_todo(...) \
|
#define efi_st_todo(...) \
|
||||||
(efi_st_printf("%s(%u):\nTODO: ", __FILE__, __LINE__), \
|
(efi_st_printc(EFI_YELLOW, "%s(%u):\nTODO: ", __FILE__, __LINE__), \
|
||||||
efi_st_printf(__VA_ARGS__)) \
|
efi_st_printc(EFI_YELLOW, __VA_ARGS__)) \
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A test may be setup and executed at boottime,
|
* A test may be setup and executed at boottime,
|
||||||
|
@ -61,14 +67,15 @@ extern struct efi_simple_input_interface *con_in;
|
||||||
void efi_st_exit_boot_services(void);
|
void efi_st_exit_boot_services(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print a pointer to an u16 string
|
* Print a colored message
|
||||||
*
|
*
|
||||||
* @pointer: pointer
|
* @color color, see constants in efi_api.h, use -1 for no color
|
||||||
* @buf: pointer to buffer address
|
* @fmt printf format
|
||||||
|
* @... arguments to be printed
|
||||||
* on return position of terminating zero word
|
* on return position of terminating zero word
|
||||||
*/
|
*/
|
||||||
void efi_st_printf(const char *fmt, ...)
|
void efi_st_printc(int color, const char *fmt, ...)
|
||||||
__attribute__ ((format (__printf__, 1, 2)));
|
__attribute__ ((format (__printf__, 2, 3)));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compare memory.
|
* Compare memory.
|
||||||
|
|
|
@ -65,7 +65,7 @@ void efi_st_exit_boot_services(void)
|
||||||
efi_st_error("ExitBootServices did not return EFI_SUCCESS\n");
|
efi_st_error("ExitBootServices did not return EFI_SUCCESS\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
efi_st_printf("\nBoot services terminated\n");
|
efi_st_printc(EFI_WHITE, "\nBoot services terminated\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -81,13 +81,14 @@ static int setup(struct efi_unit_test *test, unsigned int *failures)
|
||||||
|
|
||||||
if (!test->setup)
|
if (!test->setup)
|
||||||
return EFI_ST_SUCCESS;
|
return EFI_ST_SUCCESS;
|
||||||
efi_st_printf("\nSetting up '%s'\n", test->name);
|
efi_st_printc(EFI_LIGHTBLUE, "\nSetting up '%s'\n", test->name);
|
||||||
ret = test->setup(handle, systable);
|
ret = test->setup(handle, systable);
|
||||||
if (ret != EFI_ST_SUCCESS) {
|
if (ret != 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_printf("Setting up '%s' succeeded\n", test->name);
|
efi_st_printc(EFI_LIGHTGREEN,
|
||||||
|
"Setting up '%s' succeeded\n", test->name);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -105,13 +106,14 @@ static int execute(struct efi_unit_test *test, unsigned int *failures)
|
||||||
|
|
||||||
if (!test->execute)
|
if (!test->execute)
|
||||||
return EFI_ST_SUCCESS;
|
return EFI_ST_SUCCESS;
|
||||||
efi_st_printf("\nExecuting '%s'\n", test->name);
|
efi_st_printc(EFI_LIGHTBLUE, "\nExecuting '%s'\n", test->name);
|
||||||
ret = test->execute();
|
ret = test->execute();
|
||||||
if (ret != EFI_ST_SUCCESS) {
|
if (ret != EFI_ST_SUCCESS) {
|
||||||
efi_st_error("Executing '%s' failed\n", test->name);
|
efi_st_error("Executing '%s' failed\n", test->name);
|
||||||
++*failures;
|
++*failures;
|
||||||
} else {
|
} else {
|
||||||
efi_st_printf("Executing '%s' succeeded\n", test->name);
|
efi_st_printc(EFI_LIGHTGREEN,
|
||||||
|
"Executing '%s' succeeded\n", test->name);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -129,13 +131,14 @@ static int teardown(struct efi_unit_test *test, unsigned int *failures)
|
||||||
|
|
||||||
if (!test->teardown)
|
if (!test->teardown)
|
||||||
return EFI_ST_SUCCESS;
|
return EFI_ST_SUCCESS;
|
||||||
efi_st_printf("\nTearing down '%s'\n", test->name);
|
efi_st_printc(EFI_LIGHTBLUE, "\nTearing down '%s'\n", test->name);
|
||||||
ret = test->teardown();
|
ret = test->teardown();
|
||||||
if (ret != EFI_ST_SUCCESS) {
|
if (ret != EFI_ST_SUCCESS) {
|
||||||
efi_st_error("Tearing down '%s' failed\n", test->name);
|
efi_st_error("Tearing down '%s' failed\n", test->name);
|
||||||
++*failures;
|
++*failures;
|
||||||
} else {
|
} else {
|
||||||
efi_st_printf("Tearing down '%s' succeeded\n", test->name);
|
efi_st_printc(EFI_LIGHTGREEN,
|
||||||
|
"Tearing down '%s' succeeded\n", test->name);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -262,12 +265,12 @@ efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
efi_st_printf("\nTesting EFI API implementation\n");
|
efi_st_printc(EFI_WHITE, "\nTesting EFI API implementation\n");
|
||||||
|
|
||||||
if (testname)
|
if (testname)
|
||||||
efi_st_printf("\nSelected test: '%ps'\n", testname);
|
efi_st_printc(EFI_WHITE, "\nSelected test: '%ps'\n", testname);
|
||||||
else
|
else
|
||||||
efi_st_printf("\nNumber of tests to execute: %u\n",
|
efi_st_printc(EFI_WHITE, "\nNumber of tests to execute: %u\n",
|
||||||
ll_entry_count(struct efi_unit_test,
|
ll_entry_count(struct efi_unit_test,
|
||||||
efi_unit_test));
|
efi_unit_test));
|
||||||
|
|
||||||
|
@ -291,7 +294,7 @@ efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,
|
||||||
&failures);
|
&failures);
|
||||||
|
|
||||||
/* Give feedback */
|
/* Give feedback */
|
||||||
efi_st_printf("\nSummary: %u failures\n\n", failures);
|
efi_st_printc(EFI_WHITE, "\nSummary: %u failures\n\n", failures);
|
||||||
|
|
||||||
/* Reset system */
|
/* Reset system */
|
||||||
efi_st_printf("Preparing for reset. Press any key.\n");
|
efi_st_printf("Preparing for reset. Press any key.\n");
|
||||||
|
|
|
@ -130,12 +130,13 @@ static void int2dec(s32 value, u16 **buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print a formatted string to the EFI console
|
* Print a colored formatted string to the EFI console
|
||||||
*
|
*
|
||||||
* @fmt: format string
|
* @color color, see constants in efi_api.h, use -1 for no color
|
||||||
* @...: optional arguments
|
* @fmt format string
|
||||||
|
* @... optional arguments
|
||||||
*/
|
*/
|
||||||
void efi_st_printf(const char *fmt, ...)
|
void efi_st_printc(int color, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
u16 buf[160];
|
u16 buf[160];
|
||||||
|
@ -146,6 +147,8 @@ void efi_st_printf(const char *fmt, ...)
|
||||||
|
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
|
|
||||||
|
if (color >= 0)
|
||||||
|
con_out->set_attribute(con_out, (unsigned long)color);
|
||||||
c = fmt;
|
c = fmt;
|
||||||
for (; *c; ++c) {
|
for (; *c; ++c) {
|
||||||
switch (*c) {
|
switch (*c) {
|
||||||
|
@ -220,6 +223,8 @@ void efi_st_printf(const char *fmt, ...)
|
||||||
va_end(args);
|
va_end(args);
|
||||||
*pos = 0;
|
*pos = 0;
|
||||||
con_out->output_string(con_out, buf);
|
con_out->output_string(con_out, buf);
|
||||||
|
if (color >= 0)
|
||||||
|
con_out->set_attribute(con_out, EFI_LIGHTGRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue