mirror of
https://github.com/foxhole-team/foxhole-guard.git
synced 2026-10-21 10:45:41 +02:00
Fix device runner preflight ordering
This commit is contained in:
@@ -5,6 +5,13 @@ root="${1:?device APK artifact directory is required}"
|
||||
serial="${ANDROID_SERIAL:-emulator-5554}"
|
||||
mkdir -p build/reports/device
|
||||
trap 'adb -s "$serial" logcat -d -b crash -b system > build/reports/device/emulator-logcat.txt 2>&1 || true' EXIT
|
||||
adb -s "$serial" shell df -k /data > build/reports/device/storage.txt
|
||||
available_kb="$(awk 'END {print $4}' build/reports/device/storage.txt | tr -d '\r')"
|
||||
if [[ ! "$available_kb" =~ ^[0-9]+$ ]] || (( available_kb < 1048576 )); then
|
||||
cat build/reports/device/storage.txt >&2
|
||||
echo "The test emulator needs at least 1 GiB free in /data; configure disk-size: 6G." >&2
|
||||
exit 1
|
||||
fi
|
||||
package_ready=false
|
||||
for ((attempt = 0; attempt < 30; attempt++)); do
|
||||
if adb -s "$serial" shell pm path android 2>/dev/null | grep -q '^package:'; then
|
||||
@@ -14,13 +21,6 @@ for ((attempt = 0; attempt < 30; attempt++)); do
|
||||
sleep 2
|
||||
done
|
||||
[[ "$package_ready" == true ]] || { echo "Emulator Package Manager did not become ready" >&2; exit 1; }
|
||||
adb -s "$serial" shell df -k /data > build/reports/device/storage.txt
|
||||
available_kb="$(awk 'END {print $4}' build/reports/device/storage.txt | tr -d '\r')"
|
||||
if [[ ! "$available_kb" =~ ^[0-9]+$ ]] || (( available_kb < 1048576 )); then
|
||||
cat build/reports/device/storage.txt >&2
|
||||
echo "The test emulator needs at least 1 GiB free in /data; configure disk-size: 6G." >&2
|
||||
exit 1
|
||||
fi
|
||||
apks=()
|
||||
while IFS= read -r apk; do apks+=("$apk"); done < <(find "$root" -type f -name '*.apk' | sort)
|
||||
[[ ${#apks[@]} == 3 ]] || { echo "Expected app and two instrumentation APKs" >&2; exit 1; }
|
||||
|
||||
@@ -16,6 +16,8 @@ with Path("calls").open("a") as calls:
|
||||
if "df" in args:
|
||||
print("Filesystem 1K-blocks Used Available Use% Mounted on")
|
||||
print("/dev/block/data 6291456 1000 " + os.environ.get("FREE_KB", "4000000") + " 1% /data")
|
||||
elif "pm" in args:
|
||||
print("package:/system/framework/framework-res.apk")
|
||||
elif "instrument" in args:
|
||||
runtime = any(a.startswith("com.foxhole.core.runtime.test/") for a in args)
|
||||
fail = runtime and os.environ.get("FAIL_RUNTIME") == "1"
|
||||
|
||||
Reference in New Issue
Block a user