selftests: futex: print testcase-name and PASS/FAIL/ERROR status
authorNaresh Kamboju <naresh.kamboju@linaro.org>
Mon, 22 May 2017 07:17:43 +0000 (12:47 +0530)
committerShuah Khan <shuahkh@osg.samsung.com>
Wed, 7 Jun 2017 16:07:21 +0000 (10:07 -0600)
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>
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 3da06ad..d24ab74 100644 (file)
@@ -32,6 +32,7 @@
 #include "futextest.h"
 #include "logging.h"
 
+#define TEST_NAME "futex-requeue-pi"
 #define MAX_WAKE_ITERS 1000
 #define THREAD_MAX 10
 #define SIGNAL_PERIOD_US 100
@@ -404,6 +405,6 @@ int main(int argc, char *argv[])
         */
        ret = unit_test(broadcast, locked, owner, timeout_ns);
 
-       print_result(ret);
+       print_result(TEST_NAME, ret);
        return ret;
 }
index d5e4f2c..e0a798a 100644 (file)
@@ -30,6 +30,8 @@
 #include "futextest.h"
 #include "logging.h"
 
+#define TEST_NAME "futex-requeue-pi-mismatched-ops"
+
 futex_t f1 = FUTEX_INITIALIZER;
 futex_t f2 = FUTEX_INITIALIZER;
 int child_ret = 0;
@@ -130,6 +132,6 @@ int main(int argc, char *argv[])
 
  out:
        /* If the kernel crashes, we shouldn't return at all. */
-       print_result(ret);
+       print_result(TEST_NAME, ret);
        return ret;
 }
index 3d7dc6a..982f835 100644 (file)
@@ -32,6 +32,7 @@
 #include "futextest.h"
 #include "logging.h"
 
+#define TEST_NAME "futex-requeue-pi-signal-restart"
 #define DELAY_US 100
 
 futex_t f1 = FUTEX_INITIALIZER;
@@ -218,6 +219,6 @@ int main(int argc, char *argv[])
        if (ret == RET_PASS && waiter_ret)
                ret = waiter_ret;
 
-       print_result(ret);
+       print_result(TEST_NAME, ret);
        return ret;
 }
index 5f687f2..bdc48dc 100644 (file)
@@ -34,6 +34,7 @@
 #include "logging.h"
 #include "futextest.h"
 
+#define TEST_NAME "futex-wait-private-mapped-file"
 #define PAGE_SZ 4096
 
 char pad[PAGE_SZ] = {1};
@@ -60,7 +61,7 @@ void *thr_futex_wait(void *arg)
        ret = futex_wait(&val, 1, &wait_timeout, 0);
        if (ret && errno != EWOULDBLOCK && errno != ETIMEDOUT) {
                error("futex error.\n", errno);
-               print_result(RET_ERROR);
+               print_result(TEST_NAME, RET_ERROR);
                exit(RET_ERROR);
        }
 
@@ -120,6 +121,6 @@ int main(int argc, char **argv)
        pthread_join(thr, NULL);
 
  out:
-       print_result(ret);
+       print_result(TEST_NAME, ret);
        return ret;
 }
index ab428ca..6aadd56 100644 (file)
@@ -27,6 +27,8 @@
 #include "futextest.h"
 #include "logging.h"
 
+#define TEST_NAME "futex-wait-timeout"
+
 static long timeout_ns = 100000;       /* 100us default timeout */
 
 void usage(char *prog)
@@ -81,6 +83,6 @@ int main(int argc, char *argv[])
                ret = RET_FAIL;
        }
 
-       print_result(ret);
+       print_result(TEST_NAME, ret);
        return ret;
 }
index fe7aee9..d237a8b 100644 (file)
@@ -36,6 +36,7 @@
 #include "logging.h"
 #include "futextest.h"
 
+#define TEST_NAME "futex-wait-uninitialized-heap"
 #define WAIT_US 5000000
 
 static int child_blocked = 1;
@@ -119,6 +120,6 @@ int main(int argc, char **argv)
        }
 
  out:
-       print_result(ret);
+       print_result(TEST_NAME, ret);
        return ret;
 }
index b6b0274..9a2c56f 100644 (file)
@@ -28,6 +28,7 @@
 #include "futextest.h"
 #include "logging.h"
 
+#define TEST_NAME "futex-wait-wouldblock"
 #define timeout_ns 100000
 
 void usage(char *prog)
@@ -74,6 +75,6 @@ int main(int argc, char *argv[])
                ret = RET_FAIL;
        }
 
-       print_result(ret);
+       print_result(TEST_NAME, ret);
        return ret;
 }
index e144691..4e79449 100644 (file)
@@ -107,7 +107,7 @@ void log_verbosity(int level)
  *
  * print_result() is primarily intended for functional tests.
  */
-void print_result(int ret)
+void print_result(const char *test_name, int ret)
 {
        const char *result = "Unknown return code";
 
@@ -124,7 +124,7 @@ void print_result(int ret)
                result = FAIL;
                break;
        }
-       printf("Result: %s\n", result);
+       printf("selftests: %s [%s]\n", test_name, result);
 }
 
 /* log level macros */