Skip to content

Commit 46c9a58

Browse files
committed
[android][test] Enable several C++ Interop and other tests
Also, fix lit.cfg for running the test suite natively in Android and mark one SILOptimizer executable_test as such.
1 parent 19f59ce commit 46c9a58

22 files changed

+18
-41
lines changed

test/Concurrency/Runtime/actor_assert_precondition_executor_checkIsolated_dispatch_dispatchMain_swift_6_mode.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import Darwin
2222
import Glibc
2323
#elseif canImport(Musl)
2424
import Musl
25+
#elseif canImport(Android)
26+
import Android
2527
#endif
2628

2729
@main struct Main {

test/Interop/Cxx/class/custom-new-operator-irgen.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-swiftxx-frontend -I %S/Inputs %s -emit-ir | %FileCheck %s
22

3-
// XFAIL: OS=linux-android, OS=linux-androideabi
4-
53
import CustomNewOperator
64

75
var x = callsCustomNew()

test/Interop/Cxx/class/memory-layout-silgen.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// RUN: %target-swiftxx-frontend -I %S/Inputs -emit-ir -o - %s | %FileCheck %s
22

3-
// XFAIL: OS=linux-android
4-
// XFAIL: OS=linux-androideabi
5-
63
import MemoryLayout
74

85
var v = PrivateMemberLayout()

test/Interop/Cxx/foreign-reference/move-only-irgen.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// RUN: %target-swift-emit-ir %s -I %S/Inputs -enable-experimental-cxx-interop -validate-tbd-against-ir=none -disable-llvm-verify -Xcc -fignore-exceptions -disable-availability-checking | %FileCheck %s
2-
//
3-
// XFAIL: OS=linux-android, OS=linux-androideabi
42

53
import MoveOnly
64

test/Interop/Cxx/foreign-reference/move-only-module-interface.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// RUN: %target-swift-ide-test -print-module -module-to-print=MoveOnly -I %S/Inputs -source-filename=x -enable-experimental-cxx-interop | %FileCheck %s
2-
//
3-
// XFAIL: OS=linux-android, OS=linux-androideabi
42

53
// CHECK: class MoveOnly {
64
// CHECK-NOT: init

test/Interop/Cxx/foreign-reference/move-only-silgen.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// RUN: %target-swift-emit-silgen %s -I %S/Inputs -enable-experimental-cxx-interop -disable-availability-checking | %FileCheck %s
2-
//
3-
// XFAIL: OS=linux-android, OS=linux-androideabi
42

53
import MoveOnly
64

test/Interop/Cxx/foreign-reference/nullable-module-interface.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// RUN: %target-swift-ide-test -print-module -module-to-print=Nullable -I %S/Inputs -source-filename=x -enable-experimental-cxx-interop | %FileCheck %s
2-
//
3-
// XFAIL: OS=linux-android, OS=linux-androideabi
42

53
// CHECK: class Empty {
64
// CHECK: func test() -> Int32

test/Interop/Cxx/foreign-reference/pod-irgen.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// RUN: %target-swift-emit-ir %s -I %S/Inputs -enable-experimental-cxx-interop -validate-tbd-against-ir=none -disable-llvm-verify -Xcc -fignore-exceptions -disable-availability-checking | %FileCheck %s
2-
//
3-
// XFAIL: OS=linux-android, OS=linux-androideabi
42

53
import POD
64

test/Interop/Cxx/foreign-reference/pod-module-interface.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// RUN: %target-swift-ide-test -print-module -module-to-print=POD -I %S/Inputs -source-filename=x -enable-experimental-cxx-interop | %FileCheck %s
2-
//
3-
// XFAIL: OS=linux-android, OS=linux-androideabi
42

53
// CHECK: class Empty {
64
// CHECK-NOT: init

test/Interop/Cxx/foreign-reference/pod-silgen.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// RUN: %target-swift-emit-silgen %s -I %S/Inputs -enable-experimental-cxx-interop -disable-availability-checking | %FileCheck %s
2-
//
3-
// XFAIL: OS=linux-android, OS=linux-androideabi
42

53
import POD
64

test/Interop/Cxx/foreign-reference/reference-counted-irgen.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %target-swift-emit-irgen %s -I %S/Inputs -cxx-interoperability-mode=default -Xcc -fignore-exceptions -disable-availability-checking | %FileCheck %s
2-
// XFAIL: OS=linux-android, OS=linux-androideabi
32
// XFAIL: OS=windows-msvc
43

54
import ReferenceCounted

test/Interop/Cxx/foreign-reference/reference-counted-silgen.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// RUN: %target-swift-emit-silgen %s -I %S/Inputs -enable-experimental-cxx-interop -disable-availability-checking | %FileCheck %s
2-
//
3-
// XFAIL: OS=linux-android, OS=linux-androideabi
42

53
import POD
64
import ReferenceCounted

test/Interop/Cxx/foreign-reference/singleton-irgen.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// RUN: %target-swift-emit-ir %s -I %S/Inputs -enable-experimental-cxx-interop -validate-tbd-against-ir=none -disable-llvm-verify -Xcc -fignore-exceptions -disable-availability-checking | %FileCheck %s
2-
//
3-
// XFAIL: OS=linux-android, OS=linux-androideabi
42

53
import Singleton
64

test/Interop/Cxx/foreign-reference/singleton-module-interface.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// RUN: %target-swift-ide-test -print-module -module-to-print=Singleton -I %S/Inputs -source-filename=x -enable-experimental-cxx-interop | %FileCheck %s
2-
//
3-
// XFAIL: OS=linux-android, OS=linux-androideabi
42

53
// CHECK: class DeletedDtor {
64
// CHECK-NOT: init

test/Interop/Cxx/foreign-reference/singleton-silgen.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// RUN: %target-swift-emit-silgen %s -I %S/Inputs -enable-experimental-cxx-interop -disable-availability-checking | %FileCheck %s
2-
//
3-
// XFAIL: OS=linux-android, OS=linux-androideabi
42

53
import Singleton
64

test/Interop/SwiftToCxx/core/unsigned-return-type-no-zext.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// RUN: %FileCheck %s < %t/ir.ll
55

66
// UNSUPPORTED: OS=windows-msvc
7-
// XFAIL: OS=linux-android, OS=linux-androideabi
87

98
unsigned char getEnumTagi8(void *p);
109
unsigned getEnumTagi32(void *p);

test/Interop/SwiftToCxx/stdlib/stdlib-in-cxx-no-diagnostics-generated-header.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
// RUN: %target-interop-build-clangxx -std=gnu++20 -fsyntax-only -c %t/test-stdlib.cpp -I %t -Wall -Werror -Werror=ignored-attributes -Wno-error=unused-command-line-argument
99

10-
// XFAIL: OS=linux-android, OS=linux-androideabi
11-
1210
//--- print-string.swift
1311

1412
public func printString(_ s: String) {

test/Interop/SwiftToCxxToSwift/hide-swift-module-namespace-in-swift.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
// RUN: %target-swift-ide-test -print-module -module-to-print=SwiftToCxxTest -I %t -source-filename=x -enable-experimental-cxx-interop -Xcc -DSWIFT_CXX_INTEROP_HIDE_SWIFT_ERROR | %FileCheck --check-prefix=INTERFACE %s
1313

14-
// XFAIL: OS=linux-android, OS=linux-androideabi
15-
1614
//--- header.h
1715
#ifndef FIRSTPASS
1816
#include "swiftMod.h"

test/Interop/SwiftToCxxToSwift/import-swift-class-back-to-swift.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
// RUN: %target-swift-frontend -typecheck %t/swiftMod.swift -typecheck -module-name SwiftMod -I %t -enable-experimental-cxx-interop -Xcc -DSWIFT_CXX_INTEROP_HIDE_SWIFT_ERROR -DSECOND_PASS -emit-sil -o - | %FileCheck --check-prefix=SIL %s
1111

1212
// UNSUPPORTED: OS=windows-msvc
13-
// XFAIL: OS=linux-android, OS=linux-androideabi
1413

1514
//--- header.h
1615
#ifndef FIRSTPASS

test/Interpreter/llvm_link_time_opt.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// UNSUPPORTED: OS=windows-msvc
22
// static library is not well supported yet on Windows
33

4-
// XFAIL: OS=linux-android, OS=linux-androideabi
5-
64
// UNSUPPORTED: OS=xros
75

86
// For LTO, the linker dlopen()'s the libLTO library, which is a scenario that

test/SILOptimizer/stack-promotion-crash.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// RUN: %target-codesign %t/a.out
77
// RUN: %target-run %t/a.out | %FileCheck %s
88

9+
// REQUIRES: executable_test
10+
911
//--- module.modulemap
1012

1113
module CModule {

test/lit.cfg

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ if platform.system() == 'Darwin':
177177
# NOTE: this mirrors the kIsWindows from lit.lit.TestRunner in LLVM
178178
kIsWindows = platform.system() == 'Windows'
179179

180+
# The global environment in Android sets ANDROID_DATA, so if that variable is
181+
# set, we are probably running in Android.
182+
kIsAndroid = 'ANDROID_DATA' in os.environ
183+
180184
# testFormat: The test format to use to interpret tests.
181185

182186
# Choose between lit's internal shell pipeline runner and a real shell. If
@@ -417,6 +421,11 @@ if run_os.startswith('wasi'):
417421
# Parse the host triple
418422
(host_cpu, host_vendor, host_os, host_vers) = re.match('([^-]+)-([^-]+)-([^0-9-]+)(.*)', config.host_triple).groups()
419423

424+
# Manually set the host OS on Android, because the host OS from the triple says
425+
# `linux`.
426+
if kIsAndroid:
427+
host_os = 'android'
428+
420429
if f"{host_cpu}-{host_vendor}-{host_os}" == f"{run_cpu}-{run_vendor}-{run_os}":
421430
# Ignore the version on purpose, to account for scenario
422431
# in which the compiler has a different deployment target
@@ -1118,10 +1127,6 @@ elif platform.system() == 'Linux':
11181127
if swift_test_mode != 'only_non_executable':
11191128
config.available_features.add('swift_interpreter')
11201129

1121-
# The global environment in Android sets ANDROID_DATA, so if that variable is
1122-
# set, we are probably running in Android.
1123-
kIsAndroid = 'ANDROID_DATA' in os.environ
1124-
11251130
# swift-remoteast-test requires the ability to compile and run code
11261131
# for the system we compiled the swift-remoteast-test executable on.
11271132
# This is potentially a stronger constraint than just "can we interpret",
@@ -2428,8 +2433,12 @@ elif not kIsWindows and not run_os == 'wasi':
24282433
lit_config.note('Testing with the just-built libraries')
24292434

24302435
lit_config.note('Library load path: {0}'.format(os.path.pathsep.join(target_stdlib_path)))
2436+
env_path = "/usr/bin/env "
2437+
# Android doesn't have /usr/bin/
2438+
if kIsAndroid:
2439+
env_path = "/bin/env "
24312440
config.target_run = (
2432-
"/usr/bin/env " +
2441+
env_path +
24332442
construct_library_path_env(target_stdlib_path) +
24342443
config.target_run)
24352444

0 commit comments

Comments
 (0)