mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
1) Enable tests that use `import Dispatch` on Linux. Add substitution `%import-libdispatch` that needs to be used for all cross-platform tests (i.e., tests that are intended to be run on other platforms than Darwin) that do `import Dispatch` or enable thread sanitizer. 2) Make sure as many existing Dispatch and TSan tests as possible run on Linux. Mark tests that would require substantial work with `UNSUPPORTED: OS=linux-gnu`. 3) Add integration-style Swift test that shows that TSan finds a simple race when using `Dispatch.async` incorrectly. A more complete test suite for TSan's libdispatch support lives on the LLVM/compiler-rt side. rdar://problem/49177535
31 lines
860 B
Swift
31 lines
860 B
Swift
// This test case used to crash when tsan ran before co-routine lowering.
|
|
// RUN: %target-swift-frontend -emit-ir -sanitize=thread %s | %FileCheck %s
|
|
|
|
// TSan is only supported on 64 bit.
|
|
// REQUIRES: PTRSIZE=64
|
|
|
|
public class C { }
|
|
|
|
public struct Foobar {
|
|
var things: [String: C] = [:]
|
|
}
|
|
|
|
extension Foobar {
|
|
public struct Index {
|
|
fileprivate typealias MyIndex = Dictionary<String, C>.Values.Index
|
|
|
|
fileprivate let myIndex: MyIndex
|
|
|
|
fileprivate init(_ index: MyIndex) {
|
|
self.myIndex = index
|
|
}
|
|
}
|
|
|
|
// We used to crash emitting the subscript function.
|
|
// CHECK: define{{( dllexport| protected)?}} swiftcc { i8*, %T15tsan_coroutines1CC* } @"$s15tsan_coroutines6FoobarVyAA1CCAC5IndexVcir"
|
|
@_borrowed
|
|
public subscript(position: Index) -> C {
|
|
return things.values[position.myIndex]
|
|
}
|
|
}
|