]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
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 3da06ad2399610e1d93b7a1cb0abc8b659ce52d5..d24ab7421e739897e248150f3fd82143eb970f14 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 d5e4f2c4da2a2d22bc8dc7ced47611b965b6b350..e0a798ad0d21267bee7b2fa6e28810cd90cfa3b0 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 3d7dc6afc3f8f9459ca407ee5a16b1b2c9a8119b..982f83577501e2ab70d18dfefe2c1c0901f35941 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 5f687f2474546cee528fa65d953a7140b9fa5b63..bdc48dc047e5575214013aeddaac2f3835728e05 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 ab428ca894de00045e4fcc5552c03505e26680a2..6aadd560366e200e1727b82864d2295dd22f70e4 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 fe7aee96844b81df08441460495b7aab5246ca4d..d237a8b702f0c8bbd21fda343fd9bd04b07054b2 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 b6b02744882534b794db600c82216abc65ece40f..9a2c56fa73056e43630aaee632f3d4661f0d7d2a 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 e14469103f073d071f5e4b43c845440865f72287..4e7944984fbbb541b56226a07c1b5a1e0c5ede7a 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 */