File tree Expand file tree Collapse file tree 2 files changed +28
-20
lines changed Expand file tree Collapse file tree 2 files changed +28
-20
lines changed Original file line number Diff line number Diff line change 9
9
// don't support TSan.
10
10
// UNSUPPORTED: remote_run
11
11
12
- // rdar://51730684
13
- // REQUIRES: disable
14
-
15
12
// Test ThreadSanitizer execution end-to-end with libdispatch.
16
13
17
14
import Dispatch
18
15
16
+ let q = DispatchQueue ( label: " q " , attributes: . concurrent)
17
+
19
18
let sync1 = DispatchSemaphore ( value: 0 )
20
19
let sync2 = DispatchSemaphore ( value: 0 )
21
20
let finish = DispatchSemaphore ( value: 0 )
22
21
23
- let q = DispatchQueue ( label: " q " , attributes: . concurrent)
24
-
25
- var racy = 1
26
-
27
- q. async {
28
- sync1. wait ( )
29
- sync2. signal ( )
30
- racy = 2
31
- finish. signal ( )
32
- }
33
- q. async {
34
- sync1. signal ( )
35
- sync2. wait ( )
36
- racy = 3
37
- finish. signal ( )
22
+ func wait1_signal2( ) { sync1. wait ( ) ; sync2. signal ( ) }
23
+ func signal1_wait2( ) { sync1. signal ( ) ; sync2. wait ( ) }
24
+
25
+ func race( ) {
26
+ var racy = 1
27
+
28
+ q. async {
29
+ wait1_signal2 ( )
30
+ racy = 2
31
+ wait1_signal2 ( )
32
+ finish. signal ( )
33
+ }
34
+ q. async {
35
+ signal1_wait2 ( )
36
+ racy = 3
37
+ signal1_wait2 ( )
38
+ finish. signal ( )
39
+ }
40
+
41
+ finish. wait ( )
42
+ finish. wait ( )
38
43
}
39
44
40
- finish. wait ( )
41
- finish. wait ( )
45
+ // TSan %deflake as part of the test.
46
+ for _ in 1 ... 10 {
47
+ race ( )
48
+ }
42
49
43
50
print ( " Done! " )
44
51
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ public func call_foobar() {
44
44
var threads : [ pthread_t ] = [ ]
45
45
var racey_x : Int ;
46
46
47
+ // TSan %deflake as part of the test.
47
48
for _ in 1 ... 5 {
48
49
#if os(macOS) || os(iOS)
49
50
var t : pthread_t ?
You can’t perform that action at this time.
0 commit comments