Make avd_test less flaky

This commit is contained in:
topjohnwu 2023-10-24 16:45:24 -07:00
parent 985454afd4
commit d2f2a9e4c8
2 changed files with 18 additions and 14 deletions

View File

@ -22,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest, windows-latest, macos-13]
steps:
- name: Check out
uses: actions/checkout@v3
@ -98,7 +98,7 @@ jobs:
test:
name: Test on ${{ matrix.api }}
runs-on: macos-latest
runs-on: macos-13
needs: build
strategy:
fail-fast: false
@ -111,12 +111,6 @@ jobs:
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
- name: Set up Python 3
uses: actions/setup-python@v4
with:

View File

@ -92,11 +92,24 @@ wait_emu() {
timeout $boot_timeout bash -c $wait_fn &
local wait_pid=$!
# Handle the case when emulator dies earlier than wait
# Handle the case when emulator dies earlier than timeout
wait -p which_pid -n $emu_pid $wait_pid
[ $which_pid -eq $wait_pid ]
}
run_content_cmd() {
while true; do
local out=$(adb shell echo "'content call --uri content://com.topjohnwu.magisk.provider --method $1'" \| /system/xbin/su | tee /dev/fd/2)
if ! grep -q 'Bundle\[' <<< "$out"; then
# The call failed, wait a while and retry later
sleep 30
else
grep -q 'result=true' <<< "$out"
return $?
fi
done
}
test_emu() {
local variant=$1
@ -110,17 +123,14 @@ test_emu() {
# Install the Magisk app
adb install -r -g out/app-${variant}.apk
adb shell appops set com.topjohnwu.magisk REQUEST_INSTALL_PACKAGES allow
# Use the app to run setup and reboot
adb shell echo "'content call --uri content://com.topjohnwu.magisk.provider --method setup'" \| /system/xbin/su \
| tee /dev/fd/2 | grep -q 'result=true'
run_content_cmd setup
adb reboot
wait_emu wait_for_boot
# Run app tests
adb shell echo "'content call --uri content://com.topjohnwu.magisk.provider --method test'" \| /system/xbin/su \
| tee /dev/fd/2 | grep -q 'result=true'
run_content_cmd test
adb shell echo "'su -c id'" \| /system/xbin/su 2000 | tee /dev/fd/2 | grep -q 'uid=0'
}