From c2f5e051363c6e5d249a04a85cc05a3c4283b3cb Mon Sep 17 00:00:00 2001 From: Matt Robinson Date: Tue, 26 May 2026 19:54:30 +0100 Subject: [PATCH 1/2] Run tests under Android Emulator if appropriate Adjust the check target so that if we are cross-compiling and targeting Android, instead of calling runtests.py directly we call a new test-android helper script. If Android Emulator is running, test-android: * Downloads and installs the latest version of Termux (if Termux is not already installed), launches it (to trigger the bootstrapping process) * Installs python (if not already installed) * Transfers the necessary files and then runs runtests.py within the emulator. --- Makefile.in | 7 ++++++- configure.ac | 2 ++ test-android | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 test-android diff --git a/Makefile.in b/Makefile.in index bde2c5897..a2aa6f4cf 100644 --- a/Makefile.in +++ b/Makefile.in @@ -353,7 +353,12 @@ COVERAGE_EXCLUDE = -e '(^|/)zlib/' -e '(^|/)popt/' \ .PHONY: check check: all $(CHECK_PROGS) $(CHECK_SYMLINKS) - $(srcdir)/runtests.py --rsync-bin=`pwd`/rsync$(EXEEXT) -j $(CHECK_J) + @case "@cross_compiling@-@host_os@" in \ + yes-*android*) \ + CHECK_J=$(CHECK_J) $(srcdir)/test-android $(CHECK_PROGS) ;; \ + *) \ + $(srcdir)/runtests.py --rsync-bin=`pwd`/rsync$(EXEEXT) -j $(CHECK_J) ;; \ + esac .PHONY: check29 check29: all $(CHECK_PROGS) $(CHECK_SYMLINKS) diff --git a/configure.ac b/configure.ac index 4faab5fcb..2428df641 100644 --- a/configure.ac +++ b/configure.ac @@ -1311,6 +1311,8 @@ AC_SUBST(MAKE_RRSYNC) AC_SUBST(MAKE_RRSYNC_1) AC_SUBST(GEN_RRSYNC) AC_SUBST(MAKE_MAN) +AC_SUBST(cross_compiling) +AC_SUBST(host_os) AC_CHECK_FUNCS(_acl __acl _facl __facl) ################################################# diff --git a/test-android b/test-android new file mode 100755 index 000000000..1c173674a --- /dev/null +++ b/test-android @@ -0,0 +1,46 @@ +#!/bin/sh -e + +# Copyright © 2026 Matt Robinson +# +# SPDX-License-Identifier: GPL-3.0-or-later + +if [ $# -eq 0 ]; then + echo 'A list of helper names was expected' >&2 + exit 1 +fi + +if ! adb -e get-state > /dev/null 2>&1; then + echo 'Unable to find a running Android emulator' >&2 + exit 1 +fi + +if [ -z "$(adb shell pm list packages com.termux)" ]; then + tempdir=$(mktemp -d) + trap 'rm -rf "$tempdir"' EXIT + + gh release download --repo termux/termux-app --dir "$tempdir" \ + --pattern 'termux-app_v*-debug_x86_64.apk' + adb install "$tempdir"/termux-app_*.apk + + # Launch Termux so that it bootstraps the environment + adb shell monkey -p com.termux 1 + + # termux.properties appears to be created at the end of the bootstrapping + until adb shell run-as com.termux \ + test -f files/home/.termux/termux.properties; do + sleep 1 + done +fi + +tar -c testsuite runtests.py "$@" | \ + adb shell run-as com.termux sh -c "'cat > files/home/transfer.tar'" + +adb shell run-as com.termux files/usr/bin/bash -le < Date: Tue, 26 May 2026 20:42:00 +0100 Subject: [PATCH 2/2] Run Android tests as part of CI workflow Add x86_64 to the Android build job matrix and add a couple of steps just for this target arch to run Android within an emulator (using the reactivecircus/android-emulator-runner action) and run the test suite within it. --- .github/workflows/android-static-build.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/android-static-build.yml b/.github/workflows/android-static-build.yml index 57a318829..dcb613a51 100644 --- a/.github/workflows/android-static-build.yml +++ b/.github/workflows/android-static-build.yml @@ -43,6 +43,8 @@ jobs: - abi: armeabi-v7a # older 32-bit phones triple: armv7a-linux-androideabi qemu: qemu-arm-static + - abi: x86_64 + triple: x86_64-linux-android steps: - uses: actions/checkout@v4 with: @@ -89,6 +91,7 @@ jobs: "$STRIP" rsync - name: Verify binary + if: matrix.abi != 'x86_64' shell: bash run: | set -euo pipefail @@ -102,6 +105,24 @@ jobs: ${{ matrix.qemu }} ./rsync --version | head -3 || \ echo "WARNING: qemu smoke test did not run cleanly (check on a real device)" + - name: Enable hardware acceleration for emulator + if: matrix.abi == 'x86_64' + run: 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 trigger --name-match=kvm + + - name: Run Tests + if: matrix.abi == 'x86_64' + uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a + with: + api-level: 30 + arch: x86_64 + script: make check + env: + GH_TOKEN: ${{ github.token }} + - name: Package shell: bash run: |