Skip to content

Commit

Permalink
Output logs to files
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Jul 25, 2024
1 parent 939bfac commit 3b27de3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
24 changes: 10 additions & 14 deletions scripts/avd_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -147,22 +143,22 @@ 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
echo no | "$avd" create avd -f -n test -k $pkg

# 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
Expand Down

0 comments on commit 3b27de3

Please sign in to comment.