selftests: futex: convert test to use ksft TAP13 framework
authorShuah Khan <shuahkh@osg.samsung.com>
Fri, 4 Aug 2017 23:12:29 +0000 (17:12 -0600)
committerShuah Khan <shuahkh@osg.samsung.com>
Wed, 16 Aug 2017 23:45:00 +0000 (17:45 -0600)
Convert test to use ksft TAP13 framework to print user friendly
test output which is consistent across kselftest suite.

Acked-by: Darren Hart (VMware) <dvhart@infradead.org>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
tools/testing/selftests/futex/functional/futex_requeue_pi.c
tools/testing/selftests/futex/functional/futex_requeue_pi_mismatched_ops.c
tools/testing/selftests/futex/functional/futex_requeue_pi_signal_restart.c
tools/testing/selftests/futex/functional/futex_wait_private_mapped_file.c
tools/testing/selftests/futex/functional/futex_wait_timeout.c
tools/testing/selftests/futex/functional/futex_wait_uninitialized_heap.c
tools/testing/selftests/futex/functional/futex_wait_wouldblock.c
tools/testing/selftests/futex/include/logging.h

index d24ab7421e739897e248150f3fd82143eb970f14..54cd5c414e82c487f3c57094b84f5ab5cf960604 100644 (file)
@@ -394,9 +394,11 @@ int main(int argc, char *argv[])
                }
        }
 
-       printf("%s: Test requeue functionality\n", basename(argv[0]));
-       printf("\tArguments: broadcast=%d locked=%d owner=%d timeout=%ldns\n",
-              broadcast, locked, owner, timeout_ns);
+       ksft_print_header();
+       ksft_print_msg("%s: Test requeue functionality\n", basename(argv[0]));
+       ksft_print_msg(
+               "\tArguments: broadcast=%d locked=%d owner=%d timeout=%ldns\n",
+               broadcast, locked, owner, timeout_ns);
 
        /*
         * FIXME: unit_test is obsolete now that we parse options and the
index e0a798ad0d21267bee7b2fa6e28810cd90cfa3b0..08187a16507ff8afc3dd02c958e22327024fbcf9 100644 (file)
@@ -78,7 +78,8 @@ int main(int argc, char *argv[])
                }
        }
 
-       printf("%s: Detect mismatched requeue_pi operations\n",
+       ksft_print_header();
+       ksft_print_msg("%s: Detect mismatched requeue_pi operations\n",
               basename(argv[0]));
 
        if (pthread_create(&child, NULL, blocking_child, NULL)) {
index 982f83577501e2ab70d18dfefe2c1c0901f35941..f0542a344d95fa9656b325623473b851149f9cd6 100644 (file)
@@ -143,9 +143,10 @@ int main(int argc, char *argv[])
                }
        }
 
-       printf("%s: Test signal handling during requeue_pi\n",
+       ksft_print_header();
+       ksft_print_msg("%s: Test signal handling during requeue_pi\n",
               basename(argv[0]));
-       printf("\tArguments: <none>\n");
+       ksft_print_msg("\tArguments: <none>\n");
 
        sa.sa_handler = handle_signal;
        sigemptyset(&sa.sa_mask);
index bdc48dc047e5575214013aeddaac2f3835728e05..6216de828093a079a3afeafe06ff21d9bd6e15ee 100644 (file)
@@ -97,8 +97,10 @@ int main(int argc, char **argv)
                }
        }
 
-       printf("%s: Test the futex value of private file mappings in FUTEX_WAIT\n",
-              basename(argv[0]));
+       ksft_print_header();
+       ksft_print_msg(
+               "%s: Test the futex value of private file mappings in FUTEX_WAIT\n",
+               basename(argv[0]));
 
        ret = pthread_create(&thr, NULL, thr_futex_wait, NULL);
        if (ret < 0) {
index 6aadd560366e200e1727b82864d2295dd22f70e4..bab3dfe1787f9bd724bd75f02625efd0d08b7d50 100644 (file)
@@ -68,9 +68,10 @@ int main(int argc, char *argv[])
                }
        }
 
-       printf("%s: Block on a futex and wait for timeout\n",
+       ksft_print_header();
+       ksft_print_msg("%s: Block on a futex and wait for timeout\n",
               basename(argv[0]));
-       printf("\tArguments: timeout=%ldns\n", timeout_ns);
+       ksft_print_msg("\tArguments: timeout=%ldns\n", timeout_ns);
 
        /* initialize timeout */
        to.tv_sec = 0;
index d237a8b702f0c8bbd21fda343fd9bd04b07054b2..26975322545b4173083d082311651210501989c2 100644 (file)
@@ -99,7 +99,8 @@ int main(int argc, char **argv)
                exit(1);
        }
 
-       printf("%s: Test the uninitialized futex value in FUTEX_WAIT\n",
+       ksft_print_header();
+       ksft_print_msg("%s: Test the uninitialized futex value in FUTEX_WAIT\n",
               basename(argv[0]));
 
 
index 9a2c56fa73056e43630aaee632f3d4661f0d7d2a..da15a63269b4c7f3059bcac284ca2fdb89602847 100644 (file)
@@ -64,7 +64,8 @@ int main(int argc, char *argv[])
                }
        }
 
-       printf("%s: Test the unexpected futex value in FUTEX_WAIT\n",
+       ksft_print_header();
+       ksft_print_msg("%s: Test the unexpected futex value in FUTEX_WAIT\n",
               basename(argv[0]));
 
        info("Calling futex_wait on f1: %u @ %p with val=%u\n", f1, &f1, f1+1);
index 4e7944984fbbb541b56226a07c1b5a1e0c5ede7a..01989644e50af8252669fcfc0875d93cc28fcbd2 100644 (file)
@@ -109,22 +109,20 @@ void log_verbosity(int level)
  */
 void print_result(const char *test_name, int ret)
 {
-       const char *result = "Unknown return code";
-
        switch (ret) {
        case RET_PASS:
-               ksft_inc_pass_cnt();
-               result = PASS;
-               break;
+               ksft_test_result_pass("%s\n", test_name);
+               ksft_print_cnts();
+               return;
        case RET_ERROR:
-               result = ERROR;
-               break;
+               ksft_test_result_error("%s\n", test_name);
+               ksft_print_cnts();
+               return;
        case RET_FAIL:
-               ksft_inc_fail_cnt();
-               result = FAIL;
-               break;
+               ksft_test_result_fail("%s\n", test_name);
+               ksft_print_cnts();
+               return;
        }
-       printf("selftests: %s [%s]\n", test_name, result);
 }
 
 /* log level macros */