mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-03-28 09:12:16 +00:00
Cleanup test scripts
This commit is contained in:
parent
6707b72260
commit
ce2e33bb20
@ -14,7 +14,7 @@ lsposed_max_api=34
|
||||
huge_ram_min_api=26
|
||||
|
||||
cleanup() {
|
||||
print_error "! An error occurred when testing $pkg"
|
||||
print_error "! An error occurred"
|
||||
|
||||
rm -f magisk_patched.img
|
||||
"$avd" delete avd -n test
|
||||
@ -68,7 +68,7 @@ test_emu() {
|
||||
local variant=$1
|
||||
local api=$2
|
||||
|
||||
print_title "* Testing $pkg ($variant)"
|
||||
print_title "* Testing $avd_pkg ($variant)"
|
||||
|
||||
if [ -n "$AVD_TEST_LOG" ]; then
|
||||
"$emu" @test $emu_args > kernel.log 2>&1 &
|
||||
@ -79,7 +79,7 @@ test_emu() {
|
||||
emu_pid=$!
|
||||
wait_emu wait_for_boot
|
||||
|
||||
test_setup $variant
|
||||
run_setup $variant
|
||||
|
||||
local lsposed
|
||||
if [ $api -ge $lsposed_min_api -a $api -le $lsposed_max_api ]; then
|
||||
@ -97,7 +97,7 @@ test_emu() {
|
||||
adb reboot
|
||||
wait_emu wait_for_boot
|
||||
|
||||
test_app
|
||||
run_tests
|
||||
|
||||
# Try to launch LSPosed
|
||||
if $lsposed; then
|
||||
@ -108,10 +108,11 @@ test_emu() {
|
||||
adb shell uiautomator dump /data/local/tmp/window_dump.xml
|
||||
done
|
||||
adb shell grep -q org.lsposed.manager /data/local/tmp/window_dump.xml
|
||||
adb pull /data/local/tmp/window_dump.xml
|
||||
fi
|
||||
}
|
||||
|
||||
run_test() {
|
||||
test_main() {
|
||||
local ver=$1
|
||||
local type=$2
|
||||
|
||||
@ -140,7 +141,7 @@ run_test() {
|
||||
fi
|
||||
|
||||
# System image variable and paths
|
||||
local pkg="system-images;android-$ver;$type;$arch"
|
||||
local avd_pkg="system-images;android-$ver;$type;$arch"
|
||||
local sys_img_dir="$ANDROID_HOME/system-images/android-$ver/$type/$arch"
|
||||
local ramdisk="$sys_img_dir/ramdisk.img"
|
||||
|
||||
@ -155,11 +156,11 @@ run_test() {
|
||||
emu_args="$emu_args_base -memory $memory"
|
||||
|
||||
# Setup emulator
|
||||
"$sdk" --channel=3 $pkg
|
||||
echo no | "$avd" create avd -f -n test -k $pkg
|
||||
"$sdk" --channel=3 $avd_pkg
|
||||
echo no | "$avd" create avd -f -n test -k $avd_pkg
|
||||
|
||||
# Launch stock emulator
|
||||
print_title "* Launching $pkg"
|
||||
print_title "* Launching $avd_pkg"
|
||||
"$emu" @test $emu_args >/dev/null 2>&1 &
|
||||
emu_pid=$!
|
||||
wait_emu wait_for_bootanim
|
||||
@ -222,15 +223,15 @@ adb kill-server
|
||||
adb start-server
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
run_test $1 $2
|
||||
test_main $1 $2
|
||||
else
|
||||
for api in $(seq 23 35); do
|
||||
run_test $api
|
||||
test_main $api
|
||||
done
|
||||
# Android 16 Beta
|
||||
run_test Baklava google_apis
|
||||
test_main Baklava google_apis
|
||||
# Run 16k page tests
|
||||
run_test Baklava google_apis_ps16k
|
||||
test_main Baklava google_apis_ps16k
|
||||
fi
|
||||
|
||||
"$avd" delete avd -n test
|
||||
|
@ -67,7 +67,7 @@ test_cf() {
|
||||
print_title "* Testing $variant builds"
|
||||
timeout $boot_timeout bash -c "run_cvd_bin launch_cvd $cvd_args $magisk_args -resume=false"
|
||||
adb wait-for-device
|
||||
test_setup $variant
|
||||
run_setup $variant
|
||||
|
||||
adb reboot
|
||||
sleep 5
|
||||
@ -75,10 +75,10 @@ test_cf() {
|
||||
|
||||
timeout $boot_timeout bash -c "run_cvd_bin launch_cvd $cvd_args $magisk_args"
|
||||
adb wait-for-device
|
||||
test_app
|
||||
run_tests
|
||||
}
|
||||
|
||||
run_test() {
|
||||
test_main() {
|
||||
# Launch stock cuttlefish
|
||||
run_cvd_bin launch_cvd $cvd_args -resume=false
|
||||
adb wait-for-device
|
||||
@ -111,7 +111,7 @@ case "$1" in
|
||||
test )
|
||||
trap cleanup EXIT
|
||||
export -f run_cvd_bin
|
||||
run_test
|
||||
test_main
|
||||
trap - EXIT
|
||||
;;
|
||||
* )
|
||||
|
@ -29,9 +29,9 @@ print_error() {
|
||||
|
||||
# $1 = TestClass#method
|
||||
# $2: boolean = isRepackaged
|
||||
run_instrument_test() {
|
||||
am_instrument() {
|
||||
local test_pkg
|
||||
if [ -n "$2" -a $2 ]; then
|
||||
if [ -n "$2" -a "$2" ]; then
|
||||
test_pkg="repackaged.com.topjohnwu.magisk.test"
|
||||
else
|
||||
test_pkg=com.topjohnwu.magisk.test
|
||||
@ -48,7 +48,7 @@ wait_for_pm() {
|
||||
adb shell pm uninstall $1 || true
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
run_setup() {
|
||||
local variant=$1
|
||||
adb shell 'PATH=$PATH:/debug_ramdisk magisk -v'
|
||||
|
||||
@ -59,34 +59,34 @@ test_setup() {
|
||||
adb install -r -g out/test-${variant}.apk
|
||||
|
||||
# Run setup through the test app
|
||||
run_instrument_test 'Environment#setupMagisk'
|
||||
am_instrument 'Environment#setupMagisk'
|
||||
}
|
||||
|
||||
test_app() {
|
||||
run_tests() {
|
||||
# Run app tests
|
||||
run_instrument_test 'MagiskAppTest'
|
||||
am_instrument 'MagiskAppTest'
|
||||
|
||||
# Test shell su request
|
||||
run_instrument_test 'Environment#setupShellGrantTest'
|
||||
am_instrument 'Environment#setupShellGrantTest'
|
||||
adb shell /system/xbin/su 2000 su -c id | tee /dev/fd/2 | grep -q 'uid=0'
|
||||
adb shell am force-stop com.topjohnwu.magisk
|
||||
|
||||
# Test app hiding
|
||||
run_instrument_test 'Environment#setupAppHide'
|
||||
am_instrument 'Environment#setupAppHide'
|
||||
wait_for_pm com.topjohnwu.magisk
|
||||
|
||||
# Make sure it still works
|
||||
run_instrument_test 'MagiskAppTest' true
|
||||
am_instrument 'MagiskAppTest' true
|
||||
|
||||
# Test shell su request
|
||||
run_instrument_test 'Environment#setupShellGrantTest' true
|
||||
am_instrument 'Environment#setupShellGrantTest' true
|
||||
adb shell /system/xbin/su 2000 su -c id | tee /dev/fd/2 | grep -q 'uid=0'
|
||||
adb shell am force-stop repackaged.com.topjohnwu.magisk
|
||||
|
||||
# Test app restore
|
||||
run_instrument_test 'Environment#setupAppRestore' true
|
||||
am_instrument 'Environment#setupAppRestore' true
|
||||
wait_for_pm repackaged.com.topjohnwu.magisk
|
||||
|
||||
# Make sure it still works
|
||||
run_instrument_test 'MagiskAppTest'
|
||||
am_instrument 'MagiskAppTest'
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user