#!/bin/bash # Run every live browser bridge check and compare the bridge with native # Chromium. Needs Xvfb, native Chromium, and a Wine prefix with Electron. # Usage: live_checks.sh BUILD_DIR PREFIX [OUTPUT_DIR] # Exits non-zero if any check fails. set -u if [[ $# -lt 2 ]]; then echo "Usage: $0 BUILD_DIR PREFIX [OUTPUT_DIR]" exit 2 fi buildDir="$1" winePrefix="$2" outputDir="${3:-$(mktemp -d)}" testDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" failures=0 record() { if [[ "$2" -eq 0 ]]; then echo "PASS: $1" else echo "FAIL: $1" failures=$((failures + 1)) fi } "$testDir/live_session.sh" worker "$buildDir" "$outputDir" "$winePrefix" > /dev/null record "worker protocol ($(grep -c '^PASS' "$outputDir/worker.txt" 2> /dev/null) checks passed)" $? grep '^FAIL' "$outputDir/worker.txt" 2> /dev/null "$testDir/live_session.sh" helper "$buildDir" "$outputDir" "$winePrefix" > /dev/null record "helper bridge lifecycle ($(grep -c '^PASS' "$outputDir/helper.txt" 2> /dev/null) checks passed)" $? grep '^FAIL' "$outputDir/helper.txt" 2> /dev/null "$testDir/live_session.sh" native "$buildDir" "$outputDir" > /dev/null record "native Chromium reference session" $? "$testDir/live_session.sh" wine "$buildDir" "$outputDir" "$winePrefix" > /dev/null record "bridge session under Wine" $? python3 -I "$testDir/compare_dumps.py" "$outputDir/native.tree.txt" "$outputDir/wine.tree.txt" \ > "$outputDir/tree.diff" record "live tree and text boundaries match native Chromium" $? python3 -I "$testDir/compare_events.py" "$outputDir/native.events.txt" "$outputDir/wine.events.txt" \ > "$outputDir/events.diff" record "event sequence matches native Chromium" $? ! grep -q -E 'WARNING|CRITICAL' "$outputDir/wine.publisher.log" record "no publisher warnings" $? grep -h 'passwordLeaks' "$outputDir/native.txt" "$outputDir/wine.txt" grep -q 'passwordLeaks=0' "$outputDir/wine.txt" record "no password characters in events" $? grep -h '^reading:' "$outputDir/native.txt" "$outputDir/wine.txt" echo echo "Results in $outputDir" if [[ "$failures" -eq 0 ]]; then echo "All live checks passed" else echo "$failures live check(s) failed" fi [[ "$failures" -eq 0 ]]