@@ -1689,13 +1689,13 @@ final class SwiftDriverTests: XCTestCase {
1689
1689
}
1690
1690
1691
1691
func testSanitizerArgs( ) throws {
1692
- // FIXME: This doesn't work on Linux.
1693
- #if os(macOS)
1694
1692
let commonArgs = [
1695
1693
" swiftc " , " foo.swift " , " bar.swift " ,
1696
1694
" -emit-executable " , " -target " , " x86_64-apple-macosx10.9 " ,
1697
1695
" -module-name " , " Test "
1698
1696
]
1697
+ // FIXME: This doesn't work on Linux.
1698
+ #if os(macOS)
1699
1699
do {
1700
1700
// address sanitizer
1701
1701
var driver = try Driver ( args: commonArgs + [ " -sanitize=address " ] )
@@ -1808,6 +1808,31 @@ final class SwiftDriverTests: XCTestCase {
1808
1808
}
1809
1809
#endif
1810
1810
#endif
1811
+
1812
+ // FIXME: This test will fail when not run on Android, because the driver uses
1813
+ // the existence of the runtime support libraries to determine if
1814
+ // a sanitizer is supported. Until we allow cross-compiling with
1815
+ // sanitizers, this test is disabled outside Android.
1816
+ #if os(Android)
1817
+ do {
1818
+ var driver = try Driver (
1819
+ args: commonArgs + [
1820
+ " -target " , " aarch64-unknown-linux-android " , " -sanitize=address "
1821
+ ]
1822
+ )
1823
+ let plannedJobs = try driver. planBuild ( )
1824
+
1825
+ XCTAssertEqual ( plannedJobs. count, 4 )
1826
+
1827
+ let compileJob = plannedJobs [ 0 ]
1828
+ let compileCmd = compileJob. commandLine
1829
+ XCTAssertTrue ( compileCmd. contains ( . flag( " -sanitize=address " ) ) )
1830
+
1831
+ let linkJob = plannedJobs [ 3 ]
1832
+ let linkCmd = linkJob. commandLine
1833
+ XCTAssertTrue ( linkCmd. contains ( . flag( " -fsanitize=address " ) ) )
1834
+ }
1835
+ #endif
1811
1836
}
1812
1837
1813
1838
func testSanitizerCoverageArgs( ) throws {
@@ -2202,7 +2227,7 @@ final class SwiftDriverTests: XCTestCase {
2202
2227
func testModuleWrapJob( ) throws {
2203
2228
// FIXME: These tests will fail when run on macOS, because
2204
2229
// swift-autolink-extract is not present
2205
- #if os(Linux)
2230
+ #if os(Linux) || os(Android)
2206
2231
do {
2207
2232
var driver = try Driver ( args: [ " swiftc " , " -target " , " x86_64-unknown-linux-gnu " , " -g " , " foo.swift " ] )
2208
2233
let plannedJobs = try driver. planBuild ( )
@@ -2384,7 +2409,7 @@ final class SwiftDriverTests: XCTestCase {
2384
2409
let expectedDefaultContents : String
2385
2410
#if os(macOS)
2386
2411
expectedDefaultContents = " -apple-macosx "
2387
- #elseif os(Linux)
2412
+ #elseif os(Linux) || os(Android)
2388
2413
expectedDefaultContents = " -unknown-linux "
2389
2414
#else
2390
2415
expectedDefaultContents = " - "
@@ -2670,7 +2695,7 @@ final class SwiftDriverTests: XCTestCase {
2670
2695
2671
2696
// FIXME: This will fail when run on macOS, because
2672
2697
// swift-autolink-extract is not present
2673
- #if os(Linux)
2698
+ #if os(Linux) || os(Android)
2674
2699
do {
2675
2700
var driver = try Driver ( args: [ " swiftc " , " -profile-generate " , " -target " , " x86_64-unknown-linux-gnu " , " test.swift " ] )
2676
2701
let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
@@ -3314,7 +3339,7 @@ final class SwiftDriverTests: XCTestCase {
3314
3339
serializer. writeDOT ( to: & output)
3315
3340
3316
3341
let dynamicLinker = driver. targetTriple. isDarwin ? " ld " : " clang "
3317
- #if os(Linux)
3342
+ #if os(Linux) || os(Android)
3318
3343
XCTAssertEqual ( output,
3319
3344
"""
3320
3345
digraph Jobs {
0 commit comments