blob: 7a88434db820505ee4b95f4985b9b8e983793560 [file] [log] [blame]
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08001// RUN: %clang_tsan -O1 %s -o %t && %env_tsan_opts=suppressions='%s.supp' %run %t 2>&1 | FileCheck %s
Stephen Hines86277eb2015-03-23 12:06:32 -07002#include "test.h"
Stephen Hines2d1fdb22014-05-28 23:58:16 -07003
4int Global;
5
6void *Thread1(void *x) {
Stephen Hines86277eb2015-03-23 12:06:32 -07007 barrier_wait(&barrier);
Stephen Hines2d1fdb22014-05-28 23:58:16 -07008 Global = 42;
9 return NULL;
10}
11
12void *Thread2(void *x) {
13 Global = 43;
Stephen Hines86277eb2015-03-23 12:06:32 -070014 barrier_wait(&barrier);
Stephen Hines2d1fdb22014-05-28 23:58:16 -070015 return NULL;
16}
17
18int main() {
Stephen Hines86277eb2015-03-23 12:06:32 -070019 barrier_init(&barrier, 2);
Stephen Hines2d1fdb22014-05-28 23:58:16 -070020 pthread_t t[2];
21 pthread_create(&t[0], NULL, Thread1, NULL);
22 pthread_create(&t[1], NULL, Thread2, NULL);
23 pthread_join(t[0], NULL);
24 pthread_join(t[1], NULL);
25 printf("OK\n");
26 return 0;
27}
28
29// CHECK-NOT: failed to open suppressions file
30// CHECK-NOT: WARNING: ThreadSanitizer: data race
31