Use the various helpers provided by kselftest.h to configure the test and signal/pass failure. Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> --- tools/testing/selftests/x86/sgx/main.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/x86/sgx/main.c b/tools/testing/selftests/x86/sgx/main.c index 140dffe9c765..664a2ed98915 100644 --- a/tools/testing/selftests/x86/sgx/main.c +++ b/tools/testing/selftests/x86/sgx/main.c @@ -17,6 +17,8 @@ #include <sys/types.h> #include <sys/auxv.h> +#include "../../kselftest.h" + #include "defines.h" #include "../../../../../arch/x86/kernel/cpu/sgx/arch.h" #include "../../../../../arch/x86/include/uapi/asm/sgx.h" @@ -336,15 +338,12 @@ static void test_sgx_basic(struct sgx_secs *secs) { uint64_t result = 0; - printf("Input: 0x%lx\n", MAGIC); - sgx_call_eenter((void *)&MAGIC, &result, (void *)secs->base); if (result != MAGIC) { - fprintf(stderr, "0x%lx != 0x%lx\n", result, MAGIC); - exit(1); + ksft_test_result_error("0x%lx != 0x%lx\n", result, MAGIC); + return; } - - printf("Output: 0x%lx\n", result); + ksft_test_result_pass("%s: Passed\n", __func__); } static void test_sgx_vdso(struct sgx_secs *secs) @@ -354,16 +353,13 @@ static void test_sgx_vdso(struct sgx_secs *secs) memset(&exception, 0, sizeof(exception)); - printf("Input: 0x%lx\n", MAGIC); - sgx_call_vdso((void *)&MAGIC, &result, NULL, NULL, NULL, NULL, (void *)secs->base, &exception, NULL); if (result != MAGIC) { - fprintf(stderr, "0x%lx != 0x%lx\n", result, MAGIC); - exit(1); + ksft_test_result_error("0x%lx != 0x%lx\n", result, MAGIC); + return; } - - printf("Output: 0x%lx\n", result); + ksft_test_result_pass("%s: Passed\n", __func__); } int main(int argc, char *argv[], char *envp[]) @@ -373,6 +369,9 @@ int main(int argc, char *argv[], char *envp[]) off_t bin_size; void *bin; + ksft_print_header(); + ksft_set_plan(2); + if (!encl_data_map("encl.bin", &bin, &bin_size)) exit(1); @@ -389,5 +388,5 @@ int main(int argc, char *argv[], char *envp[]) test_sgx_vdso(&secs); - exit(0); + return ksft_exit_pass(); } -- 2.22.0