Merge pull request #251 from dgrove-oss/increase-timeouts-for-CI

Loosen test deadlines to reduce spurious failures in Swift CI
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a6526fc..b137ad6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -74,6 +74,11 @@
 	dispatch_select				\
 	$(ADDITIONAL_TESTS)
 
+# For testing in swift.org CI system; make deadlines lenient by default
+# to reduce probability of test failures due to machine load.
+if HAVE_SWIFT
+CI_CFLAGS=-DLENIENT_DEADLINES=1
+endif
 
 dispatch_c99_CFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CBLOCKS_FLAGS) -std=c99
 dispatch_plusplus_SOURCES=dispatch_plusplus.cpp
@@ -82,7 +87,7 @@
 
 AM_CPPFLAGS=-I$(top_builddir) -I$(top_srcdir)
 
-DISPATCH_TESTS_CFLAGS=-Wall -Wno-deprecated-declarations $(MARCH_FLAGS)
+DISPATCH_TESTS_CFLAGS=-Wall -Wno-deprecated-declarations $(MARCH_FLAGS) $(CI_CFLAGS)
 AM_CFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CBLOCKS_FLAGS) $(BSD_OVERLAY_CFLAGS)
 AM_OBJCFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CBLOCKS_FLAGS)
 AM_CXXFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CXXBLOCKS_FLAGS) $(BSD_OVERLAY_CFLAGS)
diff --git a/tests/dispatch_drift.c b/tests/dispatch_drift.c
index 3e1ef97..22f82ee 100644
--- a/tests/dispatch_drift.c
+++ b/tests/dispatch_drift.c
@@ -32,7 +32,11 @@
 #include <bsdtests.h>
 #include "dispatch_test.h"
 
+#if LENIENT_DEADLINES
+#define ACCEPTABLE_DRIFT 0.1
+#else
 #define ACCEPTABLE_DRIFT 0.001
+#endif
 
 int
 main(int argc __attribute__((unused)), char* argv[] __attribute__((unused)))
diff --git a/tests/dispatch_starfish.c b/tests/dispatch_starfish.c
index e5d3fab..66ebdd0 100644
--- a/tests/dispatch_starfish.c
+++ b/tests/dispatch_starfish.c
@@ -37,7 +37,9 @@
 #define COUNT	1000ul
 #define LAPS	10ul
 
-#if TARGET_OS_EMBEDDED
+#if LENIENT_DEADLINES
+#define ACCEPTABLE_LATENCY 10000
+#elif TARGET_OS_EMBEDDED
 #define ACCEPTABLE_LATENCY 3000
 #else
 #define ACCEPTABLE_LATENCY 1000