Skip to content

Commit bf04475

Browse files
committed
Fix location of libc++_shared.so
1 parent d0d4b4c commit bf04475

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

.github/workflows/scripts/android/android-emulator-tests.sh

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ EMULATOR_NAME="swiftemu"
2626
ANDROID_PROFILE="Nexus 10"
2727
ANDROID_EMULATOR_LAUNCH_TIMEOUT=300
2828

29-
# FIXME: pass this in with an argument
30-
PACKAGE="TestPackage"
31-
3229
install_package() {
3330
# Detect package manager
3431
if command -v apt >/dev/null 2>&1; then
@@ -135,30 +132,37 @@ nohup emulator -no-accel -no-metrics -partition-size 1024 -memory 4096 -avd "${E
135132
log "Waiting for Android emulator startup"
136133
timeout ${ANDROID_EMULATOR_LAUNCH_TIMEOUT} adb wait-for-any-device
137134

135+
log "Find libc++_shared.so"
136+
find / -name 'libc++_shared.so'
137+
138+
log "Prepare Swift test package"
139+
138140
# create a staging folder where we copy the test executable
139141
# and all the dependent libraries to copy over to the emulator
140-
STAGING="android-test-${PACKAGE}"
142+
STAGING="swift-android-test"
141143
rm -rf .build/"${STAGING}"
142144
mkdir .build/"${STAGING}"
143145

144-
# for the common case of tests referencing their own files as hardwired resource paths
146+
# for the common case of tests referencing
147+
# their own files as hardwired resource paths
145148
if [[ -d Tests ]]; then
146149
cp -a Tests .build/"${STAGING}"
147150
fi
148151

149-
find ~/ -name libc++_shared.so
150-
151152
cd .build/
152-
cp -a debug/*.xctest "${STAGING}"
153-
cp -a debug/*.resources "${STAGING}" || true
154-
cp -a "${ANDROID_NDK_HOME}"/toolchains/llvm/prebuilt/*/sysroot/usr/lib/"${ANDROID_EMULATOR_ARCH_TRIPLE}"-linux-android/libc++_shared.so "${STAGING}"
153+
TEST_PACKAGE=$(ls -1 debug/*.xctest | tail -n 1 | xargs basename)
154+
cp -a debug/"${TEST_PACKAGE}" "${STAGING}"
155+
find debug/ -name '*.resources' -exec cp -a {} "${STAGING}" \;
155156
cp -a "${SWIFT_ANDROID_SDK_HOME}"/swift-android/swift-resources/usr/lib/swift-"${ANDROID_EMULATOR_ARCH_TRIPLE}"/android/*.so "${STAGING}"
157+
cp -a "${ANDROID_NDK_HOME}"/toolchains/llvm/prebuilt/*/sysroot/usr/lib/"${ANDROID_EMULATOR_ARCH_TRIPLE}"-linux-android/libc++_shared.so "${STAGING}"
158+
159+
log "Copy Swift test package to emulator"
156160

157161
adb push "${STAGING}" /data/local/tmp/
158162

159163
cd -
160164

161-
TEST_CMD="./${PACKAGE}PackageTests.xctest"
165+
TEST_CMD="./${TEST_PACKAGE}"
162166
TEST_SHELL="cd /data/local/tmp/${STAGING}"
163167
TEST_SHELL="${TEST_SHELL} && ${TEST_CMD}"
164168

@@ -168,6 +172,7 @@ TEST_SHELL="${TEST_SHELL} && ${TEST_CMD}"
168172
# see: https://github.com/swiftlang/swift-package-manager/blob/1b593469e8ad3daf2cc10e798340bd2de68c402d/Sources/Commands/SwiftTestCommand.swift#L1542
169173
TEST_SHELL="${TEST_SHELL} && ${TEST_CMD} --testing-library swift-testing && [ \$? -eq 0 ] || [ \$? -eq 69 ]"
170174

175+
log "Run Swift package tests"
176+
171177
# run the test executable
172178
adb shell "${TEST_SHELL}"
173-

0 commit comments

Comments
 (0)