@@ -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 ( )
@@ -2389,7 +2414,7 @@ final class SwiftDriverTests: XCTestCase {
2389
2414
let expectedDefaultContents : String
2390
2415
#if os(macOS)
2391
2416
expectedDefaultContents = " -apple-macosx "
2392
- #elseif os(Linux)
2417
+ #elseif os(Linux) || os(Android)
2393
2418
expectedDefaultContents = " -unknown-linux "
2394
2419
#else
2395
2420
expectedDefaultContents = " - "
@@ -2678,7 +2703,7 @@ final class SwiftDriverTests: XCTestCase {
2678
2703
2679
2704
// FIXME: This will fail when run on macOS, because
2680
2705
// swift-autolink-extract is not present
2681
- #if os(Linux)
2706
+ #if os(Linux) || os(Android)
2682
2707
do {
2683
2708
var driver = try Driver ( args: [ " swiftc " , " -profile-generate " , " -target " , " x86_64-unknown-linux-gnu " , " test.swift " ] )
2684
2709
let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
@@ -3322,7 +3347,7 @@ final class SwiftDriverTests: XCTestCase {
3322
3347
serializer. writeDOT ( to: & output)
3323
3348
3324
3349
let dynamicLinker = driver. targetTriple. isDarwin ? " ld " : " clang "
3325
- #if os(Linux)
3350
+ #if os(Linux) || os(Android)
3326
3351
XCTAssertEqual ( output,
3327
3352
"""
3328
3353
digraph Jobs {
0 commit comments