aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest41
1 files changed, 25 insertions, 16 deletions
diff --git a/test b/test
index d5bf317..3bb8026 100755
--- a/test
+++ b/test
@@ -3,27 +3,33 @@
#
# ./test unit tests (JVM only, no KVM)
# ./test unit same
-# ./test e2e single-emulator self-mirror E2E (needs /dev/kvm)
+# ./test e2e real two-emulator pairing/mirroring E2E (needs /dev/kvm)
# ./test all unit + e2e
-# ./test record boot emulator, run a Mirror session, inject events,
-# capture screen recording to ./output.mp4 (needs /dev/kvm)
# ./test screenshots
# boot emulator, capture the fastlane store screenshots
# into fastlane/metadata/.../phoneScreenshots (needs /dev/kvm)
# ./test apk build a signed release APK with a throwaway keystore
# (exercises scripts/build-apk end-to-end, no KVM)
+# ./test server build and verify the pinned scrcpy server source
#
# The image is built on first run and cached as $IMG.
-# /dev/kvm must be readable by the invoking user for `./test e2e` and `record`.
+# /dev/kvm must be readable by the invoking user for e2e and screenshots.
set -eu
ROOT="$(cd "$(dirname "$0")" && pwd)"
cmd="${1:-unit}"
+mkdir -p "$ROOT/.tools"
+exec 9>"$ROOT/.tools/test.lock"
+if ! flock -n 9; then
+ echo "test: another repository test is running" >&2
+ exit 3
+fi
+
target=unit
case "$cmd" in
- e2e|all|record|screenshots) target=e2e ;;
+ e2e|all|screenshots) target=e2e ;;
esac
# The image tag is a hash of the rig inputs, so editing the Dockerfile
@@ -33,20 +39,21 @@ IMG="scrcpy-android-test-$target:$(cat "$ROOT/test-rig/Dockerfile" \
| sha256sum | cut -c1-12)"
case "$cmd" in
- unit|e2e|all|record|screenshots|apk) ;;
+ unit|server|e2e|all|screenshots|apk) ;;
-h|--help)
# Usage is the header comment block: print from line 2 down to
# the first non-comment line.
awk 'NR > 1 && /^#/ { sub(/^# ?/, ""); print; next } NR > 1 { exit }' "$0" >&2
exit 0 ;;
*)
- echo "usage: $0 [unit|e2e|all|record|screenshots|apk]" >&2
+ echo "usage: $0 [unit|server|e2e|all|screenshots|apk]" >&2
exit 2 ;;
esac
# Cheap supply-chain check: the gradle wrapper jar is a small binary
# we check into the tree; verify its sha before letting it run.
"$ROOT/scripts/check-wrapper"
+"$ROOT/scripts/check-server"
# Build the image if needed. --network=host so RUN apt/curl can reach
# the outside on hosts where the default docker bridge has no DNS.
@@ -64,11 +71,11 @@ fi
# KVM check for tiers that boot the emulator.
needs_kvm=
+KVM_GID=
case "$cmd" in
- e2e|all|record|screenshots) needs_kvm=1 ;;
+ e2e|all|screenshots) needs_kvm=1 ;;
esac
-kvm_args=
if [ -n "$needs_kvm" ]; then
if [ ! -e /dev/kvm ]; then
echo "test: /dev/kvm not present on this host - e2e cannot run." >&2
@@ -77,27 +84,29 @@ if [ -n "$needs_kvm" ]; then
if [ ! -r /dev/kvm ] || [ ! -w /dev/kvm ]; then
echo "test: /dev/kvm exists but is not rw for uid $(id -u)." >&2
echo " one-time fix:" >&2
- echo " sudo chmod 666 /dev/kvm" >&2
- echo " or add yourself to the kvm group and re-login:" >&2
echo " sudo usermod -aG kvm $(id -un)" >&2
+ echo " then log out and back in" >&2
exit 3
fi
# Pass through /dev/kvm's owning gid (numeric - group names from the
# host don't exist inside the container) so the container user
# (mapped to host uid:gid) can actually open it.
- kvm_args="--device /dev/kvm --group-add $(stat -c %g /dev/kvm)"
+ KVM_GID=$(stat -c %g /dev/kvm)
fi
# Forward Ctrl-C cleanly, run as the host user so files in .tools/ stay
# owned by the invoker (avoids root-owned gradle cache on the host).
# --network=host so the gradle wrapper can fetch the distribution and
# maven deps in environments where the docker bridge DNS misbehaves.
-exec docker run --rm -i \
- --network=host \
- $kvm_args \
+set -- docker run --rm -i --network=host
+if [ -n "$needs_kvm" ]; then
+ set -- "$@" --device /dev/kvm --group-add "$KVM_GID" \
+ --tmpfs /work/.tools/avd:rw,size=10g,mode=1777
+fi
+exec "$@" \
-u "$(id -u):$(id -g)" \
-v "$ROOT":/work \
-w /work \
- -e HOME=/work/.tools/home \
+ -e ANDROID_USER_HOME=/work/.tools/android-home \
"$IMG" \
/work/test-rig/run.sh "$cmd"