Skip to content

Commit b274e75

Browse files
author
Shuah Khan
committed
selftests: futex: convert test to use ksft TAP13 framework
Convert test to use ksft TAP13 framework to print user friendly test output which is consistent across kselftest suite. Acked-by: Darren Hart (VMware) <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 3c1f619 commit b274e75

File tree

8 files changed

+30
-23
lines changed

8 files changed

+30
-23
lines changed

tools/testing/selftests/futex/functional/futex_requeue_pi.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,11 @@ int main(int argc, char *argv[])
394394
}
395395
}
396396

397-
printf("%s: Test requeue functionality\n", basename(argv[0]));
398-
printf("\tArguments: broadcast=%d locked=%d owner=%d timeout=%ldns\n",
399-
broadcast, locked, owner, timeout_ns);
397+
ksft_print_header();
398+
ksft_print_msg("%s: Test requeue functionality\n", basename(argv[0]));
399+
ksft_print_msg(
400+
"\tArguments: broadcast=%d locked=%d owner=%d timeout=%ldns\n",
401+
broadcast, locked, owner, timeout_ns);
400402

401403
/*
402404
* FIXME: unit_test is obsolete now that we parse options and the

tools/testing/selftests/futex/functional/futex_requeue_pi_mismatched_ops.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ int main(int argc, char *argv[])
7878
}
7979
}
8080

81-
printf("%s: Detect mismatched requeue_pi operations\n",
81+
ksft_print_header();
82+
ksft_print_msg("%s: Detect mismatched requeue_pi operations\n",
8283
basename(argv[0]));
8384

8485
if (pthread_create(&child, NULL, blocking_child, NULL)) {

tools/testing/selftests/futex/functional/futex_requeue_pi_signal_restart.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@ int main(int argc, char *argv[])
143143
}
144144
}
145145

146-
printf("%s: Test signal handling during requeue_pi\n",
146+
ksft_print_header();
147+
ksft_print_msg("%s: Test signal handling during requeue_pi\n",
147148
basename(argv[0]));
148-
printf("\tArguments: <none>\n");
149+
ksft_print_msg("\tArguments: <none>\n");
149150

150151
sa.sa_handler = handle_signal;
151152
sigemptyset(&sa.sa_mask);

tools/testing/selftests/futex/functional/futex_wait_private_mapped_file.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ int main(int argc, char **argv)
9797
}
9898
}
9999

100-
printf("%s: Test the futex value of private file mappings in FUTEX_WAIT\n",
101-
basename(argv[0]));
100+
ksft_print_header();
101+
ksft_print_msg(
102+
"%s: Test the futex value of private file mappings in FUTEX_WAIT\n",
103+
basename(argv[0]));
102104

103105
ret = pthread_create(&thr, NULL, thr_futex_wait, NULL);
104106
if (ret < 0) {

tools/testing/selftests/futex/functional/futex_wait_timeout.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ int main(int argc, char *argv[])
6868
}
6969
}
7070

71-
printf("%s: Block on a futex and wait for timeout\n",
71+
ksft_print_header();
72+
ksft_print_msg("%s: Block on a futex and wait for timeout\n",
7273
basename(argv[0]));
73-
printf("\tArguments: timeout=%ldns\n", timeout_ns);
74+
ksft_print_msg("\tArguments: timeout=%ldns\n", timeout_ns);
7475

7576
/* initialize timeout */
7677
to.tv_sec = 0;

tools/testing/selftests/futex/functional/futex_wait_uninitialized_heap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ int main(int argc, char **argv)
9999
exit(1);
100100
}
101101

102-
printf("%s: Test the uninitialized futex value in FUTEX_WAIT\n",
102+
ksft_print_header();
103+
ksft_print_msg("%s: Test the uninitialized futex value in FUTEX_WAIT\n",
103104
basename(argv[0]));
104105

105106

tools/testing/selftests/futex/functional/futex_wait_wouldblock.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ int main(int argc, char *argv[])
6464
}
6565
}
6666

67-
printf("%s: Test the unexpected futex value in FUTEX_WAIT\n",
67+
ksft_print_header();
68+
ksft_print_msg("%s: Test the unexpected futex value in FUTEX_WAIT\n",
6869
basename(argv[0]));
6970

7071
info("Calling futex_wait on f1: %u @ %p with val=%u\n", f1, &f1, f1+1);

tools/testing/selftests/futex/include/logging.h

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,22 +109,20 @@ void log_verbosity(int level)
109109
*/
110110
void print_result(const char *test_name, int ret)
111111
{
112-
const char *result = "Unknown return code";
113-
114112
switch (ret) {
115113
case RET_PASS:
116-
ksft_inc_pass_cnt();
117-
result = PASS;
118-
break;
114+
ksft_test_result_pass("%s\n", test_name);
115+
ksft_print_cnts();
116+
return;
119117
case RET_ERROR:
120-
result = ERROR;
121-
break;
118+
ksft_test_result_error("%s\n", test_name);
119+
ksft_print_cnts();
120+
return;
122121
case RET_FAIL:
123-
ksft_inc_fail_cnt();
124-
result = FAIL;
125-
break;
122+
ksft_test_result_fail("%s\n", test_name);
123+
ksft_print_cnts();
124+
return;
126125
}
127-
printf("selftests: %s [%s]\n", test_name, result);
128126
}
129127

130128
/* log level macros */

0 commit comments

Comments
 (0)