]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* c-c++-common/tsan/simple_race.c: Made test less flaky.
authorchefmax <chefmax@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 31 Jan 2014 13:42:10 +0000 (13:42 +0000)
committerchefmax <chefmax@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 31 Jan 2014 13:42:10 +0000 (13:42 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207344 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/tsan/simple_race.c

index 6417c8db217c7fe6eddea5278434ab6f14228794..c81b82d2dc565893dfb50ea7d200f09ec174e8dd 100644 (file)
@@ -1,3 +1,6 @@
+2014-01-31  Maxim Ostapenko  <m.ostapenko@partner.samsung.com>
+       * c-c++-common/tsan/simple_race.c: Made test less flaky.
+
 2014-01-31  Ilya Tocar  <ilya.tocar@intel.com>
 
        * gcc.target/i386/m512-check.h: Use correct rounding values.
index 24b88e8e5ee99977222dc5b606c63c1d77064a7f..4626efd867dcd5d291834d19829116034af0708e 100644 (file)
@@ -1,12 +1,35 @@
 /* { dg-do run } */
+/* { dg-set-target-env-var TSAN_OPTIONS "halt_on_error=1" } */
 /* { dg-shouldfail "tsan" } */
 
 #include <pthread.h>
 #include <stdio.h>
+#include <unistd.h>
+
+#define MAX_ITERATIONS_NUMBER 100
+#define SLEEP_STEP 128000 
+
+unsigned int delay_time = 1000;
+
+static inline void delay () {
+  usleep(delay_time);
+}
+
+extern int main_1();
+
+int main() {
+  int i;
+  for (i = 0; i < MAX_ITERATIONS_NUMBER; i++) {
+    main_1();
+    delay_time += delay_time < 256000 ? delay_time : SLEEP_STEP;
+  }
+  return 0;
+}
 
 int Global;
 
 void *Thread1(void *x) {
+  delay();
   Global = 42;
   return NULL;
 }
@@ -16,7 +39,7 @@ void *Thread2(void *x) {
   return NULL;
 }
 
-int main() {
+int main_1() {
   pthread_t t[2];
   pthread_create(&t[0], NULL, Thread1, NULL);
   pthread_create(&t[1], NULL, Thread2, NULL);