test: disable test-barrier by default
authorDavid Herrmann <dh.herrmann@gmail.com>
Thu, 18 Jun 2015 08:18:31 +0000 (10:18 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Thu, 18 Jun 2015 08:25:08 +0000 (10:25 +0200)
The test-barrier binary uses real-time alarms and timeouts to test for
races in the thread-barrier implementation. Hence, if your system is under
high load and your scheduler decides to not run test-barrier for
>BASE_TIME, then the tests are likely to fail.

Two options:
 1) Increase BASE_TIME. This will make the test take significantly longer
    for no real good. Furthermore, it is still not guaranteed that the
    task is scheduled.
 2) Don't rely on real-time timers, but use explicit synchronization. This
    would basically test one barrier implementation with another.. kinda
    ironic.. but maybe something worth looking into.
 3) Disable test-barrier by default.

This patch chooses option 3) and makes sure test-barrier only runs if you
pass any argument.

Side note:
        test-barrier is written in a way that if it fails under load, but
        does not on idle systems, then it is very _unlikely_ that the
        barrier implementation is the culprit. Hence, it makes little
        sense to run it under load, anyway. It will not improve the test
        coverage of barrier.c, but rather the coverage of the test itself.

src/test/test-barrier.c

index 2d109a3..f37cb49 100644 (file)
@@ -438,6 +438,16 @@ TEST_BARRIER(test_barrier_pending_exit,
         TEST_BARRIER_WAIT_SUCCESS(pid2));
 
 int main(int argc, char *argv[]) {
+        /*
+         * This test uses real-time alarms and sleeps to test for CPU races
+         * explicitly. This is highly fragile if your system is under load. We
+         * already increased the BASE_TIME value to make the tests more robust,
+         * but that just makes the test take significantly longer. Hence,
+         * disable the test by default, so it will not break CI.
+         */
+        if (argc < 2)
+                return EXIT_TEST_SKIP;
+
         log_parse_environment();
         log_open();