Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/exec: load_address: conform test to TAP format output

Conform the layout, informational and status messages to TAP. No
functional change is intended other than the layout of output messages.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Link: https://lore.kernel.org/r/20240304155928.1818928-2-usama.anjum@collabora.com
Signed-off-by: Kees Cook <keescook@chromium.org>

authored by

Muhammad Usama Anjum and committed by
Kees Cook
c4095067 99f5819b

+16 -20
+16 -20
tools/testing/selftests/exec/load_address.c
··· 5 5 #include <link.h> 6 6 #include <stdio.h> 7 7 #include <stdlib.h> 8 + #include "../kselftest.h" 8 9 9 10 struct Statistics { 10 11 unsigned long long load_address; ··· 42 41 unsigned long long misalign; 43 42 int ret; 44 43 45 - ret = dl_iterate_phdr(ExtractStatistics, &extracted); 46 - if (ret != 1) { 47 - fprintf(stderr, "FAILED\n"); 48 - return 1; 49 - } 44 + ksft_print_header(); 45 + ksft_set_plan(1); 50 46 51 - if (extracted.alignment == 0) { 52 - fprintf(stderr, "No alignment found\n"); 53 - return 1; 54 - } else if (extracted.alignment & (extracted.alignment - 1)) { 55 - fprintf(stderr, "Alignment is not a power of 2\n"); 56 - return 1; 57 - } 47 + ret = dl_iterate_phdr(ExtractStatistics, &extracted); 48 + if (ret != 1) 49 + ksft_exit_fail_msg("FAILED: dl_iterate_phdr\n"); 50 + 51 + if (extracted.alignment == 0) 52 + ksft_exit_fail_msg("FAILED: No alignment found\n"); 53 + else if (extracted.alignment & (extracted.alignment - 1)) 54 + ksft_exit_fail_msg("FAILED: Alignment is not a power of 2\n"); 58 55 59 56 misalign = extracted.load_address & (extracted.alignment - 1); 60 - if (misalign) { 61 - printf("alignment = %llu, load_address = %llu\n", 62 - extracted.alignment, extracted.load_address); 63 - fprintf(stderr, "FAILED\n"); 64 - return 1; 65 - } 57 + if (misalign) 58 + ksft_exit_fail_msg("FAILED: alignment = %llu, load_address = %llu\n", 59 + extracted.alignment, extracted.load_address); 66 60 67 - fprintf(stderr, "PASS\n"); 68 - return 0; 61 + ksft_test_result_pass("Completed\n"); 62 + ksft_finished(); 69 63 }