Skip to content

Commit e56b090

Browse files
committed
Set AVD partition size
1 parent c705e86 commit e56b090

1 file changed

Lines changed: 15 additions & 17 deletions

File tree

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

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ log "Installing Android cmdline-tools"
8080
mkdir ~/android-sdk
8181
pushd ~/android-sdk
8282
export ANDROID_HOME=${PWD}
83-
# TODO: require that this be set by an argument
84-
export ANDROID_NDK_HOME="${ANDROID_NDK_HOME:-${ANDROID_HOME}}"
8583

8684
curl --connect-timeout 30 --retry 3 --retry-delay 2 --retry-max-time 60 -fsSL -o commandlinetools.zip https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip
8785
unzip commandlinetools.zip
8886
rm commandlinetools.zip
87+
# a quirk of the archive is that its root is cmdline-tools,
88+
# but when executed they are expected to be at cmdline-tools/latest
89+
# or else the other relative paths are not identified correctly
8990
mv cmdline-tools latest
9091
mkdir cmdline-tools
9192
mv latest cmdline-tools
@@ -99,18 +100,18 @@ popd
99100
log "Listing installed Android SDKs"
100101
sdkmanager --list_installed
101102

102-
log "Updating Android licenses"
103+
log "Updating Android SDK licenses"
103104
yes | sdkmanager --licenses > /dev/null || true
104105

105106
log "Installing Android emulator"
106-
sdkmanager --install "${EMULATOR_SPEC}" "emulator" "platform-tools" "platforms;android-${ANDROID_API}"
107+
sdkmanager --install "emulator" "platform-tools" "platforms;android-${ANDROID_API}" "${EMULATOR_SPEC}"
107108

108109
log "Creating Android emulator"
109110
avdmanager create avd -n "${EMULATOR_NAME}" -k "${EMULATOR_SPEC}" --device "${ANDROID_PROFILE}"
110-
#ANDROID_AVD_CONFIG="${ANDROID_AVD_HOME}"/"${EMULATOR_NAME}".avd/config.ini
111-
#mkdir -p "$(dirname ${ANDROID_AVD_CONFIG})"
111+
ANDROID_AVD_CONFIG="${ANDROID_AVD_HOME}"/"${EMULATOR_NAME}".avd/config.ini
112+
mkdir -p "$(dirname ${ANDROID_AVD_CONFIG})"
112113
# ~2G partition size
113-
#echo 'disk.dataPartition.size=2000000000' >> "${ANDROID_AVD_CONFIG}"
114+
echo 'disk.dataPartition.size=1024MB' >> "${ANDROID_AVD_CONFIG}"
114115

115116
log "Listing Android emulators"
116117
emulator -list-avds
@@ -130,12 +131,9 @@ df -h
130131

131132
log "Starting Android emulator"
132133

133-
# launch the emulator in the background; we will cat the logs at the end
134-
# TODO: -no-accel disables the need for KVM, but is very slow
135-
nohup emulator -no-accel -no-metrics -partition-size 1024 -memory 4096 -avd "${EMULATOR_NAME}" -wipe-data -no-window -no-snapshot -noaudio -no-boot-anim &
136-
#2>&1 > emulator.log &
137-
138-
#adb logcat 2>&1 > logcat.log &
134+
# launch the emulator in the background
135+
# -no-accel disables the need for KVM, but is very slow
136+
nohup emulator -no-accel -no-metrics -partition-size 1024 -memory 4096 -wipe-data -no-window -no-snapshot -noaudio -no-boot-anim -avd "${EMULATOR_NAME}" &
139137

140138
log "Waiting for Android emulator startup"
141139
timeout ${ANDROID_EMULATOR_LAUNCH_TIMEOUT} adb wait-for-any-device
@@ -154,7 +152,8 @@ if [[ -d Tests ]]; then
154152
cp -a Tests .build/"${STAGING_DIR}"
155153
fi
156154

157-
cd .build/
155+
pushd .build/
156+
158157
TEST_PACKAGE=$(find debug/ -name '*.xctest' | tail -n 1 | xargs basename)
159158
cp -a debug/"${TEST_PACKAGE}" "${STAGING_DIR}"
160159
find debug/ -name '*.resources' -exec cp -a {} "${STAGING_DIR}" \;
@@ -166,7 +165,7 @@ log "Copy Swift test package to emulator"
166165
ANDROID_TMP_FOLDER="/data/local/tmp/${STAGING_DIR}"
167166
adb push "${STAGING_DIR}" "${ANDROID_TMP_FOLDER}"
168167

169-
cd -
168+
popd
170169

171170
TEST_CMD="./${TEST_PACKAGE}"
172171
TEST_SHELL="cd ${ANDROID_TMP_FOLDER}"
@@ -175,11 +174,10 @@ TEST_SHELL="${TEST_SHELL} && ${TEST_CMD}"
175174
# Run test cases a second time with the Swift Testing library
176175
# We additionally need to handle the special exit code EXIT_NO_TESTS_FOUND (69 on Android),
177176
# which can happen when the tests link to Testing, but no tests are executed
178-
# see: https://github.com/swiftlang/swift-package-manager/blob/1b593469e8ad3daf2cc10e798340bd2de68c402d/Sources/Commands/SwiftTestCommand.swift#L1542
177+
# see: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/Commands/SwiftTestCommand.swift#L1571
179178
TEST_SHELL="${TEST_SHELL} && ${TEST_CMD} --testing-library swift-testing && [ \$? -eq 0 ] || [ \$? -eq 69 ]"
180179

181180
log "Run Swift package tests"
182181

183182
# run the test executable
184-
adb shell "ls ${ANDROID_TMP_FOLDER}"
185183
adb shell "${TEST_SHELL}"

0 commit comments

Comments
 (0)