Skip to content

Commit 5549a79

Browse files
musamaanjumshuahkh
authored andcommitted
selftests: x86: test_mremap_vdso: 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 <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent d17e752 commit 5549a79

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

tools/testing/selftests/x86/test_mremap_vdso.c

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <sys/auxv.h>
2020
#include <sys/syscall.h>
2121
#include <sys/wait.h>
22+
#include "../kselftest.h"
2223

2324
#define PAGE_SIZE 4096
2425

@@ -29,24 +30,24 @@ static int try_to_remap(void *vdso_addr, unsigned long size)
2930
/* Searching for memory location where to remap */
3031
dest_addr = mmap(0, size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
3132
if (dest_addr == MAP_FAILED) {
32-
printf("[WARN]\tmmap failed (%d): %m\n", errno);
33+
ksft_print_msg("WARN: mmap failed (%d): %m\n", errno);
3334
return 0;
3435
}
3536

36-
printf("[NOTE]\tMoving vDSO: [%p, %#lx] -> [%p, %#lx]\n",
37-
vdso_addr, (unsigned long)vdso_addr + size,
38-
dest_addr, (unsigned long)dest_addr + size);
37+
ksft_print_msg("Moving vDSO: [%p, %#lx] -> [%p, %#lx]\n",
38+
vdso_addr, (unsigned long)vdso_addr + size,
39+
dest_addr, (unsigned long)dest_addr + size);
3940
fflush(stdout);
4041

4142
new_addr = mremap(vdso_addr, size, size,
4243
MREMAP_FIXED|MREMAP_MAYMOVE, dest_addr);
4344
if ((unsigned long)new_addr == (unsigned long)-1) {
4445
munmap(dest_addr, size);
4546
if (errno == EINVAL) {
46-
printf("[NOTE]\tvDSO partial move failed, will try with bigger size\n");
47+
ksft_print_msg("vDSO partial move failed, will try with bigger size\n");
4748
return -1; /* Retry with larger */
4849
}
49-
printf("[FAIL]\tmremap failed (%d): %m\n", errno);
50+
ksft_print_msg("[FAIL]\tmremap failed (%d): %m\n", errno);
5051
return 1;
5152
}
5253

@@ -58,21 +59,22 @@ int main(int argc, char **argv, char **envp)
5859
{
5960
pid_t child;
6061

62+
ksft_print_header();
63+
ksft_set_plan(1);
64+
6165
child = fork();
62-
if (child == -1) {
63-
printf("[WARN]\tfailed to fork (%d): %m\n", errno);
64-
return 1;
65-
}
66+
if (child == -1)
67+
ksft_exit_fail_msg("failed to fork (%d): %m\n", errno);
6668

6769
if (child == 0) {
6870
unsigned long vdso_size = PAGE_SIZE;
6971
unsigned long auxval;
7072
int ret = -1;
7173

7274
auxval = getauxval(AT_SYSINFO_EHDR);
73-
printf("\tAT_SYSINFO_EHDR is %#lx\n", auxval);
75+
ksft_print_msg("AT_SYSINFO_EHDR is %#lx\n", auxval);
7476
if (!auxval || auxval == -ENOENT) {
75-
printf("[WARN]\tgetauxval failed\n");
77+
ksft_print_msg("WARN: getauxval failed\n");
7678
return 0;
7779
}
7880

@@ -92,16 +94,13 @@ int main(int argc, char **argv, char **envp)
9294
int status;
9395

9496
if (waitpid(child, &status, 0) != child ||
95-
!WIFEXITED(status)) {
96-
printf("[FAIL]\tmremap() of the vDSO does not work on this kernel!\n");
97-
return 1;
98-
} else if (WEXITSTATUS(status) != 0) {
99-
printf("[FAIL]\tChild failed with %d\n",
100-
WEXITSTATUS(status));
101-
return 1;
102-
}
103-
printf("[OK]\n");
97+
!WIFEXITED(status))
98+
ksft_test_result_fail("mremap() of the vDSO does not work on this kernel!\n");
99+
else if (WEXITSTATUS(status) != 0)
100+
ksft_test_result_fail("Child failed with %d\n", WEXITSTATUS(status));
101+
else
102+
ksft_test_result_pass("%s\n", __func__);
104103
}
105104

106-
return 0;
105+
ksft_finished();
107106
}

0 commit comments

Comments
 (0)