-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun_android_tests
More file actions
executable file
·66 lines (57 loc) · 2.4 KB
/
Copy pathrun_android_tests
File metadata and controls
executable file
·66 lines (57 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Runs ReCpp unit tests on an emulated Android (aarch64) environment using QEMU user-mode.
# Uses a pre-built sysroot with bionic linker64/libc from API 29 and a custom liblog.so
# that redirects __android_log_write to stderr.
#
# Usage:
# ./run_android_tests # run tests (requires prior mama android build)
# ./run_android_tests --build # build first, then run tests
# ./run_android_tests --build -vv # build + verbose test output
# ./run_android_tests test_concurrent_queue # run specific test suite
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="$SCRIPT_DIR/packages/ReCpp/android"
TEST_BIN="$BUILD_DIR/RppTests"
# pre-built sysroot with bionic API 29 (jemalloc, compatible with QEMU user-mode)
QEMU_SYSROOT="$SCRIPT_DIR/.circleci/android-qemu-sysroot-api29"
# parse args
DO_BUILD=false
TEST_ARGS=()
while [[ $# -gt 0 ]]; do
case "$1" in
--build) DO_BUILD=true; shift ;;
*) TEST_ARGS+=("$1"); shift ;;
esac
done
# ensure qemu-user is installed
if ! command -v qemu-aarch64 &>/dev/null; then
echo "Installing qemu-user for aarch64 emulation..."
sudo apt-get update -qq && sudo apt-get install -y -qq qemu-user
fi
# verify sysroot exists
if [ ! -f "$QEMU_SYSROOT/system/bin/linker64" ]; then
echo "ERROR: QEMU sysroot not found at $QEMU_SYSROOT" >&2
echo " This should be checked into the repository." >&2
exit 1
fi
# optionally build
if [[ "$DO_BUILD" == true ]]; then
echo "Building ReCpp tests for Android..."
CXX20=1 mama android build with_tests
fi
if [ ! -f "$TEST_BIN" ]; then
echo "ERROR: $TEST_BIN not found. Run with --build or 'CXX20=1 mama android build with_tests' first." >&2
exit 1
fi
# copy libc++_shared.so from NDK into the sysroot if not already present
NDK_HOME="${ANDROID_NDK_HOME:-${ANDROID_NDK_ROOT:-}}"
if [[ -n "$NDK_HOME" ]]; then
NDK_LIBCXX="$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so"
if [ -f "$NDK_LIBCXX" ]; then
cp "$NDK_LIBCXX" "$QEMU_SYSROOT/system/lib64/libc++_shared.so"
fi
fi
echo "Running RppTests on Android (QEMU aarch64 user-mode)..."
# filter out linker warnings (harmless DT entry warnings from NDK stub libs)
qemu-aarch64 -L "$QEMU_SYSROOT" "$TEST_BIN" "${TEST_ARGS[@]+"${TEST_ARGS[@]}"}" 2>&1 \
| grep -v "^linker: Warning:\|^WARNING: linker:"