summaryrefslogtreecommitdiff
path: root/lib/efi_selftest/efi_selftest.c
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2017-10-04 15:31:26 +0200
committerAlexander Graf <agraf@suse.de>2017-10-09 07:00:23 +0200
commite67e7249c8000d72b4c4b985fdeb3e103d65aa9e (patch)
tree6d23111df527f7f508c5423ef97e2d9c253dd055 /lib/efi_selftest/efi_selftest.c
parente190e8972faf4d5b09e2a92fefc54a1832fd67da (diff)
efi_selftest: make tests easier to read
Rename counter to more illustrative names. Update notification function description. Simplify notification function. Add comment for arbitrary non-zero value. Document @return. Use constants for return values of setup, execute, teardown. Reported-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib/efi_selftest/efi_selftest.c')
-rw-r--r--lib/efi_selftest/efi_selftest.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/efi_selftest/efi_selftest.c b/lib/efi_selftest/efi_selftest.c
index ff00254c21..45d8d3d384 100644
--- a/lib/efi_selftest/efi_selftest.c
+++ b/lib/efi_selftest/efi_selftest.c
@@ -66,16 +66,17 @@ void efi_st_exit_boot_services(void)
*
* @test the test to be executed
* @failures counter that will be incremented if a failure occurs
+ * @return EFI_ST_SUCCESS for success
*/
static int setup(struct efi_unit_test *test, unsigned int *failures)
{
int ret;
if (!test->setup)
- return 0;
+ return EFI_ST_SUCCESS;
efi_st_printf("\nSetting up '%s'\n", test->name);
ret = test->setup(handle, systable);
- if (ret) {
+ if (ret != EFI_ST_SUCCESS) {
efi_st_error("Setting up '%s' failed\n", test->name);
++*failures;
} else {
@@ -89,16 +90,17 @@ static int setup(struct efi_unit_test *test, unsigned int *failures)
*
* @test the test to be executed
* @failures counter that will be incremented if a failure occurs
+ * @return EFI_ST_SUCCESS for success
*/
static int execute(struct efi_unit_test *test, unsigned int *failures)
{
int ret;
if (!test->execute)
- return 0;
+ return EFI_ST_SUCCESS;
efi_st_printf("\nExecuting '%s'\n", test->name);
ret = test->execute();
- if (ret) {
+ if (ret != EFI_ST_SUCCESS) {
efi_st_error("Executing '%s' failed\n", test->name);
++*failures;
} else {
@@ -112,16 +114,17 @@ static int execute(struct efi_unit_test *test, unsigned int *failures)
*
* @test the test to be torn down
* @failures counter that will be incremented if a failure occurs
+ * @return EFI_ST_SUCCESS for success
*/
static int teardown(struct efi_unit_test *test, unsigned int *failures)
{
int ret;
if (!test->teardown)
- return 0;
+ return EFI_ST_SUCCESS;
efi_st_printf("\nTearing down '%s'\n", test->name);
ret = test->teardown();
- if (ret) {
+ if (ret != EFI_ST_SUCCESS) {
efi_st_error("Tearing down '%s' failed\n", test->name);
++*failures;
} else {