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

selftests: futex: print testcase-name and PASS/FAIL/ERROR status

Most of the tests under selftests follow a pattern for their results,
which can then be parsed easily by other external tools easily. Though
futex tests do print the test results very well, it doesn't really
follow the general selftests pattern.

This patch makes necessary changes to fix that.

Output before this patch:
futex_requeue_pi: Test requeue functionality
Arguments: broadcast=0 locked=0 owner=0 timeout=0ns
Result: PASS

Output after this patch:
futex_requeue_pi: Test requeue functionality
Arguments: broadcast=0 locked=0 owner=0 timeout=0ns
selftests: futex-requeue-pi [PASS]

Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>

authored by

Naresh Kamboju and committed by
Shuah Khan
1f666e52 3c2993b8

+19 -10
+2 -1
tools/testing/selftests/futex/functional/futex_requeue_pi.c
··· 32 32 #include "futextest.h" 33 33 #include "logging.h" 34 34 35 + #define TEST_NAME "futex-requeue-pi" 35 36 #define MAX_WAKE_ITERS 1000 36 37 #define THREAD_MAX 10 37 38 #define SIGNAL_PERIOD_US 100 ··· 405 404 */ 406 405 ret = unit_test(broadcast, locked, owner, timeout_ns); 407 406 408 - print_result(ret); 407 + print_result(TEST_NAME, ret); 409 408 return ret; 410 409 }
+3 -1
tools/testing/selftests/futex/functional/futex_requeue_pi_mismatched_ops.c
··· 30 30 #include "futextest.h" 31 31 #include "logging.h" 32 32 33 + #define TEST_NAME "futex-requeue-pi-mismatched-ops" 34 + 33 35 futex_t f1 = FUTEX_INITIALIZER; 34 36 futex_t f2 = FUTEX_INITIALIZER; 35 37 int child_ret = 0; ··· 132 130 133 131 out: 134 132 /* If the kernel crashes, we shouldn't return at all. */ 135 - print_result(ret); 133 + print_result(TEST_NAME, ret); 136 134 return ret; 137 135 }
+2 -1
tools/testing/selftests/futex/functional/futex_requeue_pi_signal_restart.c
··· 32 32 #include "futextest.h" 33 33 #include "logging.h" 34 34 35 + #define TEST_NAME "futex-requeue-pi-signal-restart" 35 36 #define DELAY_US 100 36 37 37 38 futex_t f1 = FUTEX_INITIALIZER; ··· 219 218 if (ret == RET_PASS && waiter_ret) 220 219 ret = waiter_ret; 221 220 222 - print_result(ret); 221 + print_result(TEST_NAME, ret); 223 222 return ret; 224 223 }
+3 -2
tools/testing/selftests/futex/functional/futex_wait_private_mapped_file.c
··· 34 34 #include "logging.h" 35 35 #include "futextest.h" 36 36 37 + #define TEST_NAME "futex-wait-private-mapped-file" 37 38 #define PAGE_SZ 4096 38 39 39 40 char pad[PAGE_SZ] = {1}; ··· 61 60 ret = futex_wait(&val, 1, &wait_timeout, 0); 62 61 if (ret && errno != EWOULDBLOCK && errno != ETIMEDOUT) { 63 62 error("futex error.\n", errno); 64 - print_result(RET_ERROR); 63 + print_result(TEST_NAME, RET_ERROR); 65 64 exit(RET_ERROR); 66 65 } 67 66 ··· 121 120 pthread_join(thr, NULL); 122 121 123 122 out: 124 - print_result(ret); 123 + print_result(TEST_NAME, ret); 125 124 return ret; 126 125 }
+3 -1
tools/testing/selftests/futex/functional/futex_wait_timeout.c
··· 27 27 #include "futextest.h" 28 28 #include "logging.h" 29 29 30 + #define TEST_NAME "futex-wait-timeout" 31 + 30 32 static long timeout_ns = 100000; /* 100us default timeout */ 31 33 32 34 void usage(char *prog) ··· 83 81 ret = RET_FAIL; 84 82 } 85 83 86 - print_result(ret); 84 + print_result(TEST_NAME, ret); 87 85 return ret; 88 86 }
+2 -1
tools/testing/selftests/futex/functional/futex_wait_uninitialized_heap.c
··· 36 36 #include "logging.h" 37 37 #include "futextest.h" 38 38 39 + #define TEST_NAME "futex-wait-uninitialized-heap" 39 40 #define WAIT_US 5000000 40 41 41 42 static int child_blocked = 1; ··· 120 119 } 121 120 122 121 out: 123 - print_result(ret); 122 + print_result(TEST_NAME, ret); 124 123 return ret; 125 124 }
+2 -1
tools/testing/selftests/futex/functional/futex_wait_wouldblock.c
··· 28 28 #include "futextest.h" 29 29 #include "logging.h" 30 30 31 + #define TEST_NAME "futex-wait-wouldblock" 31 32 #define timeout_ns 100000 32 33 33 34 void usage(char *prog) ··· 75 74 ret = RET_FAIL; 76 75 } 77 76 78 - print_result(ret); 77 + print_result(TEST_NAME, ret); 79 78 return ret; 80 79 }
+2 -2
tools/testing/selftests/futex/include/logging.h
··· 107 107 * 108 108 * print_result() is primarily intended for functional tests. 109 109 */ 110 - void print_result(int ret) 110 + void print_result(const char *test_name, int ret) 111 111 { 112 112 const char *result = "Unknown return code"; 113 113 ··· 124 124 result = FAIL; 125 125 break; 126 126 } 127 - printf("Result: %s\n", result); 127 + printf("selftests: %s [%s]\n", test_name, result); 128 128 } 129 129 130 130 /* log level macros */