From a1e3f0f38b43e68ff9ea33ab1935aed4edf6ed7f Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 26 Jan 2019 17:03:34 +0100 Subject: [PATCH] test-barrier: skip the test in virtualized/containerized environments --- src/test/test-barrier.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/test/test-barrier.c b/src/test/test-barrier.c index 6ae84cd6fc..6469129fa4 100644 --- a/src/test/test-barrier.c +++ b/src/test/test-barrier.c @@ -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();