Skip to content

Commit 8918a09

Browse files
committed
[Tests] Fix RemoteMirror/interop.swift to work with ASAN enabled.
In order to work for an ASAN build, parts of this test need themselves to be built with ASAN turned on. rdar://81274645
1 parent 9a48cf9 commit 8918a09

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

docs/Testing.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ code for the target that is not the build machine:
350350
* ``%target-cc-options``: the clang flags to setup the target with the right
351351
architecture and platform version.
352352

353+
* ``%target-sanitizer-opt``: if sanitizers are enabled for the build, the
354+
corresponding ``-fsanitize=`` option.
355+
353356
* ``%target-triple``: a triple composed of the ``%target-cpu``, the vendor,
354357
the ``%target-os``, and the operating system version number. Possible values
355358
include ``i386-apple-ios7.0`` or ``armv7k-apple-watchos2.0``.

test/RemoteMirror/interop.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// RUN: %empty-directory(%t)
44
// RUN: %target-build-swift %S/Inputs/interop.swift -emit-library -module-name InteropTest -o %t/%target-library-name(InteropTest)
5-
// RUN: %target-clang %S/Inputs/interop.m -framework Foundation -I %S/../../include/swift/SwiftRemoteMirror -I %S/../../include/ -o %t/InteropTest
5+
// RUN: %target-clang %target-sanitizer-opt %S/Inputs/interop.m -framework Foundation -I %S/../../include/swift/SwiftRemoteMirror -I %S/../../include/ -o %t/InteropTest
66
// RUN: %target-codesign %t/%target-library-name(InteropTest)
77
// RUN: %target-codesign %t/InteropTest
88
// RUN: %target-run %t/InteropTest %t/%target-library-name(InteropTest) %platform-module-dir/%target-library-name(swiftRemoteMirror) | %FileCheck %s

test/lit.cfg

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,11 @@ if config.benchmark_o != 'Benchmark_O':
688688
# Add substitutions for the run target triple, CPU, OS, and pointer size.
689689
config.substitutions.append(('%target-triple', config.variant_triple))
690690

691+
# Keep track of which sanitizers need to be enabled (matters for some tests)
692+
config.sanitizers = []
693+
if 'asan' in config.available_features:
694+
config.sanitizers.append('address')
695+
691696
if run_vendor == 'apple':
692697
if run_os == 'maccatalyst':
693698
config.stable_abi_triple = '%s-%s-ios13.0-macabi' % (run_cpu, run_vendor)
@@ -2052,6 +2057,13 @@ if hasattr(config, 'target_cc_options'):
20522057
else:
20532058
config.substitutions.append(('%target-cc-options', ''))
20542059

2060+
# Build an -fsanitize= argument (used by some tests)
2061+
if config.sanitizers:
2062+
config.substitutions.append(('%target-sanitizer-opt',
2063+
'-fsanitize=' + ','.join(config.sanitizers)))
2064+
else:
2065+
config.substitutions.append(('%target-sanitizer-opt', ''))
2066+
20552067
# WORKAROUND(rdar://53507844): On some macOS versions, we see flaky failures in
20562068
# tests which create a hard link to an executable and immediately invoke it.
20572069
# Work around this by always copying on Darwin.

0 commit comments

Comments
 (0)