From 3b27de3715dceb2561db9b4a183700323276ceba Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 25 Jul 2024 03:48:13 -0700 Subject: [PATCH] Output logs to files --- .github/workflows/build.yml | 22 ++++++++++++++++++++-- scripts/avd_test.sh | 24 ++++++++++-------------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d97dbb4b0..03fc2efde 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -114,9 +114,18 @@ jobs: - name: Run AVD test timeout-minutes: 10 env: - AVD_TEST_VERBOSE: 1 + AVD_TEST_LOG: 1 run: scripts/avd_test.sh ${{ matrix.version }} ${{ matrix.type }} + - name: Upload logs on error + if: ${{ failure() }} + uses: actions/upload-artifact@v4 + with: + name: "avd-logs-${{ matrix.version }}" + path: | + kernel.log + logcat.log + avd-test-32: name: Test API ${{ matrix.version }} (x86) runs-on: ubuntu-latest @@ -148,9 +157,18 @@ jobs: timeout-minutes: 10 env: FORCE_32_BIT: 1 - AVD_TEST_VERBOSE: 1 + AVD_TEST_LOG: 1 run: scripts/avd_test.sh ${{ matrix.version }} + - name: Upload logs on error + if: ${{ failure() }} + uses: actions/upload-artifact@v4 + with: + name: "avd32-logs-${{ matrix.version }}" + path: | + kernel.log + logcat.log + cf_test: name: Test ${{ matrix.branch }} (${{ matrix.target }}) runs-on: ubuntu-24.04 diff --git a/scripts/avd_test.sh b/scripts/avd_test.sh index b53d4370e..c1c1e5f2b 100755 --- a/scripts/avd_test.sh +++ b/scripts/avd_test.sh @@ -10,6 +10,7 @@ emu_pid= atd_min_api=30 atd_max_api=34 lsposed_min_api=27 +lsposed_max_api=34 huge_ram_min_api=26 cleanup() { @@ -67,29 +68,24 @@ test_emu() { print_title "* Testing $pkg ($variant)" - if [ -n "$AVD_TEST_VERBOSE" ]; then - "$emu" @test $emu_args & - emu_pid=$! - adb logcat & + if [ -n "$AVD_TEST_LOG" ]; then + "$emu" @test $emu_args > kernel.log 2>&1 & else - "$emu" @test $emu_args 2>/dev/null & - emu_pid=$! + "$emu" @test $emu_args > /dev/null 2>&1 & fi + emu_pid=$! wait_emu wait_for_boot test_setup $variant # Install LSPosed - if [ $api -ge $lsposed_min_api -a $api -le $atd_max_api ]; then + if [ $api -ge $lsposed_min_api -a $api -le $lsposed_max_api ]; then adb push out/lsposed.zip /data/local/tmp/lsposed.zip echo 'PATH=$PATH:/debug_ramdisk magisk --install-module /data/local/tmp/lsposed.zip' | adb shell /system/xbin/su fi adb reboot - if [ -n "$AVD_TEST_VERBOSE" ]; then - adb logcat & - fi wait_emu wait_for_boot test_app @@ -147,9 +143,6 @@ run_test() { fi emu_args="$emu_args_base -memory $memory" - if [ -n "$AVD_TEST_VERBOSE" ]; then - emu_args="$emu_args -show-kernel" - fi # Setup emulator "$sdk" --channel=3 $pkg @@ -157,12 +150,15 @@ run_test() { # Launch stock emulator print_title "* Launching $pkg" - "$emu" @test $emu_args 2>/dev/null & + "$emu" @test $emu_args >/dev/null 2>&1 & emu_pid=$! wait_emu wait_for_bootanim # Update arguments for Magisk runs emu_args="$emu_args -ramdisk magisk_patched.img -feature -SystemAsRoot" + if [ -n "$AVD_TEST_LOG" ]; then + emu_args="$emu_args -show-kernel -logcat '' -logcat-output logcat.log" + fi # Patch and test debug build ./build.py avd_patch -s "$ramdisk" magisk_patched.img