From fae7094be7d055209f2c1310dd9cbc6f3eaf193f Mon Sep 17 00:00:00 2001 From: Matt Robinson Date: Tue, 26 May 2026 19:54:30 +0100 Subject: [PATCH 1/2] Initial POC script to run test suite under Android --- support/android-run-tests | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 support/android-run-tests diff --git a/support/android-run-tests b/support/android-run-tests new file mode 100755 index 000000000..570c10c92 --- /dev/null +++ b/support/android-run-tests @@ -0,0 +1,53 @@ +#!/bin/sh -e + +# Copyright © 2026 Matt Robinson +# +# SPDX-License-Identifier: GPL-3.0-or-later + +# TODO check that we are configured to build for Android + +if ! adb -e get-state > /dev/null 2>&1; then + echo 'Unable to find a running Android emulator' >&2 + exit 1 +fi + +make tls trimslash t_unsafe t_chmod_secure t_secure_relpath wildtest getgroups getfsdev + +termuxfiles=/data/user/0/com.termux/files +tempdir=$(mktemp -d) +trap 'rm -rf "$tempdir"' EXIT + +# TODO: Wrangle into a single find command? +( + find . -maxdepth 1 -type f -executable -print0 + find ./testsuite -maxdepth 1 -type f -print0 +) | tar -cf "$tempdir/transfer.tar" --null -T - + +adb -e root + +if [ -z "$(adb shell pm list packages com.termux)" ]; then + 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 test -f $termuxfiles/home/.termux/termux.properties; do + sleep 1 + done +fi + +adb shell run-as com.termux sh -c "'cat > $termuxfiles/home/transfer.tar'" < "$tempdir/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] Try running Android tests in emulator --- .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 d48544f81..6355d850a 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: ./support/android-run-tests + env: + GH_TOKEN: ${{ github.token }} + - name: Package shell: bash run: |