Update test scripts

This commit is contained in:
topjohnwu 2024-07-22 03:39:04 -07:00
parent b26db8cee6
commit 6e22476acc
4 changed files with 50 additions and 64 deletions

View File

@ -81,7 +81,7 @@ jobs:
run: ./gradlew --stop run: ./gradlew --stop
avd-test: avd-test:
name: Test x86_64 on API ${{ matrix.version }} name: Test API ${{ matrix.version }} (x86_64)
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: build
strategy: strategy:
@ -99,11 +99,6 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Download build artifacts - name: Download build artifacts
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
@ -116,14 +111,14 @@ jobs:
sudo udevadm control --reload-rules sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm sudo udevadm trigger --name-match=kvm
- name: AVD test - name: Run AVD test
timeout-minutes: 10 timeout-minutes: 10
env: env:
AVD_TEST_VERBOSE: 1 AVD_TEST_VERBOSE: 1
run: scripts/avd_test.sh ${{ matrix.version }} ${{ matrix.type }} run: scripts/avd_test.sh ${{ matrix.version }} ${{ matrix.type }}
avd-test-32: avd-test-32:
name: Test x86 on API ${{ matrix.version }} name: Test API ${{ matrix.version }} (x86)
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: build
strategy: strategy:
@ -137,11 +132,6 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Download build artifacts - name: Download build artifacts
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
@ -154,7 +144,7 @@ jobs:
sudo udevadm control --reload-rules sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm sudo udevadm trigger --name-match=kvm
- name: AVD test - name: Run AVD test
timeout-minutes: 10 timeout-minutes: 10
env: env:
FORCE_32_BIT: 1 FORCE_32_BIT: 1
@ -162,12 +152,17 @@ jobs:
run: scripts/avd_test.sh ${{ matrix.version }} run: scripts/avd_test.sh ${{ matrix.version }}
cf_test: cf_test:
name: Test Cuttlefish on main name: Test ${{ matrix.branch }} (${{ matrix.target }})
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
needs: build
env: env:
CF_HOME: /home/runner/aosp_cf_x86_64_phone CF_HOME: /home/runner/aosp_cf_phone
strategy: strategy:
fail-fast: false fail-fast: false
matrix:
include:
- branch: "aosp-main"
target: "aosp_cf_x86_64_phone-trunk_staging-userdebug"
steps: steps:
- name: Check out - name: Check out
@ -175,26 +170,19 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup Cuttlefish environment
run: |
scripts/cuttlefish.sh setup
scripts/cuttlefish.sh download
- name: Wait for build artifacts
uses: lewagon/wait-on-check-action@v1.3.4
timeout-minutes: 45
with:
ref: ${{ github.ref }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
check-name: "Build Magisk artifacts"
- name: Download build artifacts - name: Download build artifacts
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: ${{ github.sha }} name: ${{ github.sha }}
path: out path: out
- name: Setup Cuttlefish environment
run: |
scripts/cuttlefish.sh setup
scripts/cuttlefish.sh download ${{ matrix.branch }} ${{ matrix.target }}
- name: Run Cuttlefish test - name: Run Cuttlefish test
timeout-minutes: 10
run: su $USER -c 'scripts/cuttlefish.sh test' run: su $USER -c 'scripts/cuttlefish.sh test'
- name: Upload logs on error - name: Upload logs on error
@ -203,5 +191,5 @@ jobs:
with: with:
name: "cvd-logs" name: "cvd-logs"
path: | path: |
/home/runner/aosp_cf_x86_64_phone/cuttlefish/instances/cvd-1/logs /home/runner/aosp_cf_phone/cuttlefish/instances/cvd-1/logs
/home/runner/aosp_cf_x86_64_phone/cuttlefish/instances/cvd-1/cuttlefish_config.json /home/runner/aosp_cf_phone/cuttlefish/instances/cvd-1/cuttlefish_config.json

View File

@ -3,7 +3,7 @@
set -xe set -xe
. scripts/test_common.sh . scripts/test_common.sh
emu_args_base='-no-window -no-audio -no-boot-anim -gpu swiftshader_indirect -read-only -no-snapshot' emu_args_base="-no-window -no-audio -no-boot-anim -gpu swiftshader_indirect -read-only -no-snapshot -cores $core_count"
lsposed_url='https://github.com/LSPosed/LSPosed/releases/download/v1.9.2/LSPosed-v1.9.2-7024-zygisk-release.zip' lsposed_url='https://github.com/LSPosed/LSPosed/releases/download/v1.9.2/LSPosed-v1.9.2-7024-zygisk-release.zip'
emu_pid= emu_pid=

View File

@ -3,7 +3,7 @@
set -xe set -xe
. scripts/test_common.sh . scripts/test_common.sh
cvd_args='-daemon -enable_sandbox=false -memory_mb=8192 -report_anonymous_usage_stats=n' cvd_args="-daemon -enable_sandbox=false -memory_mb=8192 -report_anonymous_usage_stats=n -cpus=$core_count"
magisk_args='-init_boot_image=magisk_patched.img' magisk_args='-init_boot_image=magisk_patched.img'
cleanup() { cleanup() {
@ -18,26 +18,10 @@ run_cvd_bin() {
HOME=$CF_HOME $CF_HOME/bin/$exe "$@" HOME=$CF_HOME $CF_HOME/bin/$exe "$@"
} }
install_bazel() {
sudo apt-get install -y apt-transport-https curl gnupg
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg
sudo mv bazel-archive-keyring.gpg /usr/share/keyrings
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
sudo apt-get update && sudo apt-get install bazel zip unzip
}
build_cf() {
git clone https://github.com/google/android-cuttlefish
cd android-cuttlefish
# We only want to build the base package
sed -i '$ d' tools/buildutils/build_packages.sh
tools/buildutils/build_packages.sh
sudo dpkg -i ./cuttlefish-base_*_*64.deb || sudo apt-get install -f
cd ../
rm -rf android-cuttlefish
}
setup_env() { setup_env() {
curl -LO https://github.com/topjohnwu/magisk-files/releases/download/files/cuttlefish-base_0.9.29_amd64.deb
sudo dpkg -i ./cuttlefish-base_*_*64.deb || sudo apt-get install -f
rm cuttlefish-base_*_*64.deb
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules sudo udevadm control --reload-rules
sudo udevadm trigger sudo udevadm trigger
@ -47,19 +31,30 @@ setup_env() {
} }
download_cf() { download_cf() {
local build_id=$(curl -sL https://ci.android.com/builds/branches/aosp-main/status.json | \ local branch=$1
jq -r '.targets[] | select(.name == "aosp_cf_x86_64_phone-trunk_staging-userdebug") | .last_known_good_build') local target=$2
local sys_img_url="https://ci.android.com/builds/submitted/${build_id}/aosp_cf_x86_64_phone-trunk_staging-userdebug/latest/raw/aosp_cf_x86_64_phone-img-${build_id}.zip"
local host_pkg_url="https://ci.android.com/builds/submitted/${build_id}/aosp_cf_x86_64_phone-trunk_staging-userdebug/latest/raw/cvd-host_package.tar.gz"
print_title "* Download aosp-main ($build_id) system images" if [ -z $branch ]; then
curl -L $sys_img_url -o aosp_cf_x86_64_phone-img.zip branch='aosp-main'
fi
if [ -z $target ]; then
target='aosp_cf_x86_64_phone-trunk_staging-userdebug'
fi
local device=$(echo $target | cut -d '-' -f 1)
local build_id=$(curl -sL https://ci.android.com/builds/branches/${branch}/status.json | \
jq -r ".targets[] | select(.name == \"$target\") | .last_known_good_build")
local sys_img_url="https://ci.android.com/builds/submitted/${build_id}/${target}/latest/raw/${device}-img-${build_id}.zip"
local host_pkg_url="https://ci.android.com/builds/submitted/${build_id}/${target}/latest/raw/cvd-host_package.tar.gz"
print_title "* Download $branch ($build_id) $target images"
curl -L $sys_img_url -o aosp_cf_phone-img.zip
curl -LO $host_pkg_url curl -LO $host_pkg_url
rm -rf $CF_HOME rm -rf $CF_HOME
mkdir -p $CF_HOME mkdir -p $CF_HOME
tar xvf cvd-host_package.tar.gz -C $CF_HOME tar xvf cvd-host_package.tar.gz -C $CF_HOME
unzip aosp_cf_x86_64_phone-img.zip -d $CF_HOME unzip aosp_cf_phone-img.zip -d $CF_HOME
rm -f cvd-host_package.tar.gz aosp_cf_x86_64_phone-img.zip rm -f cvd-host_package.tar.gz aosp_cf_phone-img.zip
} }
test_cf() { test_cf() {
@ -106,12 +101,10 @@ fi
case "$1" in case "$1" in
setup ) setup )
install_bazel
build_cf
setup_env setup_env
;; ;;
download ) download )
download_cf download_cf $2 $3
;; ;;
test ) test )
trap cleanup EXIT trap cleanup EXIT

View File

@ -4,12 +4,17 @@ fi
export PATH="$PATH:$ANDROID_HOME/platform-tools" export PATH="$PATH:$ANDROID_HOME/platform-tools"
sdk="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
emu="$ANDROID_HOME/emulator/emulator" emu="$ANDROID_HOME/emulator/emulator"
sdk="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
avd="$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager" avd="$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager"
boot_timeout=600 boot_timeout=600
core_count=$(nproc)
if [ $core_count -gt 8 ]; then
core_count=8
fi
print_title() { print_title() {
echo -e "\n\033[44;39m${1}\033[0m\n" echo -e "\n\033[44;39m${1}\033[0m\n"
} }