]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-barrier: skip the test in virtualized/containerized environments
authorFrantisek Sumsal <frantisek@sumsal.cz>
Sat, 26 Jan 2019 16:03:34 +0000 (17:03 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 28 Jan 2019 11:47:19 +0000 (12:47 +0100)
src/test/test-barrier.c

index 6ae84cd6fcfcf38daebba54fe8f9517fb46b3975..6469129fa4e1f0b0c048abe8f932cb32bfabb1b4 100644 (file)
@@ -17,6 +17,7 @@
 #include "barrier.h"
 #include "util.h"
 #include "tests.h"
+#include "virt.h"
 
 /* 20ms to test deadlocks; All timings use multiples of this constant as
  * alarm/sleep timers. If this timeout is too small for slow machines to perform
@@ -420,11 +421,27 @@ TEST_BARRIER(test_barrier_pending_exit,
         TEST_BARRIER_WAIT_SUCCESS(pid2));
 
 int main(int argc, char *argv[]) {
+        int v;
         test_setup_logging(LOG_INFO);
 
         if (!slow_tests_enabled())
                 return log_tests_skipped("slow tests are disabled");
 
+        /*
+         * 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. Given the recent
+         * issues when running the test in a virtualized environments, limit it
+         * to bare metal machines only, to minimize false-positives in CIs.
+         */
+        v = detect_virtualization();
+        if (IN_SET(v, -EPERM, -EACCES))
+                return log_tests_skipped("Cannot detect virtualization");
+
+        if (v != VIRTUALIZATION_NONE)
+                return log_tests_skipped("This test requires a baremetal machine");
+
         test_barrier_sync();
         test_barrier_wait_next();
         test_barrier_wait_next_twice();