mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-21 10:28:31 +00:00
Update avd_test.sh
This commit is contained in:
parent
e774408782
commit
587b6cfd41
@ -5,6 +5,7 @@ avd="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager"
|
|||||||
sdk="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
|
sdk="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
|
||||||
emu_args='-no-window -gpu swiftshader_indirect -read-only -no-snapshot -noaudio -no-boot-anim -show-kernel'
|
emu_args='-no-window -gpu swiftshader_indirect -read-only -no-snapshot -noaudio -no-boot-anim -show-kernel'
|
||||||
boot_timeout=300
|
boot_timeout=300
|
||||||
|
emu_pid=
|
||||||
|
|
||||||
# Should be either 'google_apis' or 'default'
|
# Should be either 'google_apis' or 'default'
|
||||||
type='google_apis'
|
type='google_apis'
|
||||||
@ -30,12 +31,30 @@ cleanup() {
|
|||||||
"$avd" delete avd -n test
|
"$avd" delete avd -n test
|
||||||
pkill -INT -P $$
|
pkill -INT -P $$
|
||||||
wait
|
wait
|
||||||
|
trap - EXIT
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
wait_for_bootanim() {
|
||||||
|
adb wait-for-device
|
||||||
|
while true; do
|
||||||
|
local result="$(adb exec-out getprop init.svc.bootanim)"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
exit 1
|
||||||
|
elif [ "$result" = "stopped" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_for_boot() {
|
wait_for_boot() {
|
||||||
adb wait-for-device
|
adb wait-for-device
|
||||||
while true; do
|
while true; do
|
||||||
if [ "1" = "$(adb exec-out getprop sys.boot_completed)" ]; then
|
local result="$(adb exec-out getprop sys.boot_completed)"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
exit 1
|
||||||
|
elif [ "$result" = "1" ]; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
sleep 2
|
sleep 2
|
||||||
@ -58,8 +77,20 @@ restore_avd() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_emu() {
|
||||||
|
"$emu" @test $emu_args &
|
||||||
|
emu_pid=$!
|
||||||
|
timeout $boot_timeout bash -c wait_for_boot &
|
||||||
|
local wait_pid=$!
|
||||||
|
|
||||||
|
# Handle the case when emulator dies with error
|
||||||
|
wait -n $emu_pid $wait_pid
|
||||||
|
|
||||||
|
adb shell magisk -v
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
run_test() {
|
run_test() {
|
||||||
local pid
|
|
||||||
local api=$1
|
local api=$1
|
||||||
|
|
||||||
set_api_env $api
|
set_api_env $api
|
||||||
@ -69,43 +100,34 @@ run_test() {
|
|||||||
"$sdk" $pkg
|
"$sdk" $pkg
|
||||||
echo no | "$avd" create avd -f -n test -k $pkg
|
echo no | "$avd" create avd -f -n test -k $pkg
|
||||||
|
|
||||||
# Launch emulator and patch with debug build
|
# Launch stock emulator
|
||||||
restore_avd
|
restore_avd
|
||||||
"$emu" @test $emu_args &
|
"$emu" @test $emu_args &
|
||||||
pid=$!
|
emu_pid=$!
|
||||||
timeout $boot_timeout bash -c wait_for_boot
|
timeout $boot_timeout bash -c wait_for_bootanim
|
||||||
|
|
||||||
|
# Patch and test debug build
|
||||||
./build.py avd_patch -s "$ramdisk"
|
./build.py avd_patch -s "$ramdisk"
|
||||||
kill -INT $pid
|
kill -INT $emu_pid
|
||||||
wait $pid
|
wait $emu_pid
|
||||||
|
test_emu
|
||||||
|
|
||||||
# Test if it boots properly
|
# Re-patch and test release build
|
||||||
"$emu" @test $emu_args &
|
|
||||||
pid=$!
|
|
||||||
timeout $boot_timeout bash -c wait_for_boot
|
|
||||||
|
|
||||||
adb shell magisk -v
|
|
||||||
|
|
||||||
# Re-patch to test release build
|
|
||||||
./build.py -r avd_patch -s "$ramdisk"
|
./build.py -r avd_patch -s "$ramdisk"
|
||||||
kill -INT $pid
|
kill -INT $emu_pid
|
||||||
wait $pid
|
wait $emu_pid
|
||||||
|
test_emu
|
||||||
|
|
||||||
# Test if it also boots properly
|
# Cleanup
|
||||||
"$emu" @test $emu_args &
|
kill -INT $emu_pid
|
||||||
pid=$!
|
wait $emu_pid
|
||||||
timeout $boot_timeout bash -c wait_for_boot
|
|
||||||
|
|
||||||
adb shell magisk -v
|
|
||||||
|
|
||||||
kill -INT $pid
|
|
||||||
wait $pid
|
|
||||||
restore_avd
|
restore_avd
|
||||||
}
|
}
|
||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
export -f wait_for_boot
|
export -f wait_for_boot
|
||||||
|
export -f wait_for_bootanim
|
||||||
|
|
||||||
set -xe
|
set -xe
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user