51 lines
2.6 KiB
Shell
Executable file
51 lines
2.6 KiB
Shell
Executable file
#!/bin/bash
|
|
# Hidden run of the WebKit Nacre (S045): Xvfb -> nested niri (spikes/webkit-egui/run/nested.sh) -> target/release/nacre
|
|
# with a throwaway home, software GL, and a NACRE_SCRIPT selftest script (see src/selftest.rs).
|
|
#
|
|
# tools/hidden.sh <script> [outdir] [-- driver.sh]
|
|
#
|
|
# outdir (default target/hidden/<name>-<time>) gets nacre.log, selftest.log, the script's shots and status files, and
|
|
# home/. @PAGES@ / @PAGESDIR@ in the script are replaced as in tools/smoke.sh. An optional driver script runs next to
|
|
# Nacre with the nested session's environment and these helpers, for real input and compositor screenshots:
|
|
# click X Y [right] wl-input pointer click (logical px of the nested output) scroll X Y N
|
|
# grab NAME grim screenshot of the nested output to $OUT/NAME.png key ... / type TEXT (wtype)
|
|
# Never connects to Tor or proxies. Exits non-zero if Nacre panicked, crashed or the script didn't finish.
|
|
set -u
|
|
root=$(cd "$(dirname "$0")/.." && pwd)
|
|
script=$1; shift
|
|
name=$(basename "$script" .txt)
|
|
out=${1:-$root/target/hidden/$name-$(date +%Y%m%d-%H%M%S)}; [ $# -gt 0 ] && shift
|
|
driver=""; [ "${1:-}" = "--" ] && driver=$2
|
|
mkdir -p "$out"; out=$(cd "$out" && pwd)
|
|
export SPIKE_RUN=$out/session
|
|
mkdir -p "$SPIKE_RUN"
|
|
sed -e "s|@PAGES@|file://$root/tests/smoke/pages|g" -e "s|@PAGESDIR@|$root/tests/smoke/pages|g" "$script" >"$out/script.txt"
|
|
"$root/spikes/webkit-egui/run/nested.sh" start >"$out/nested.log" 2>&1
|
|
trap '"$root/spikes/webkit-egui/run/nested.sh" stop' EXIT
|
|
source "$SPIKE_RUN/env"
|
|
ln -sfn "$HOME" "$out/home"
|
|
export LIBGL_ALWAYS_SOFTWARE=1 WEBKIT_DMABUF_RENDERER_FORCE_SHM=1 GSK_RENDERER=gl GTK_A11Y=none NO_AT_BRIDGE=1 GDK_DEBUG=no-portals
|
|
export RUST_BACKTRACE=1 NACRE_SCRIPT=$out/script.txt
|
|
dbus-run-session -- "$root/target/release/nacre" >"$out/nacre.log" 2>&1 &
|
|
pid=$!
|
|
if [ -n "$driver" ]; then
|
|
(
|
|
export OUT=$out WL_INPUT_FLIP_Y=1
|
|
W=$root/spikes/webkit-egui/target/release/wl-input
|
|
click() { "$W" winit click "$@"; }
|
|
scroll() { "$W" winit scroll "$@"; }
|
|
grab() { grim "$OUT/$1.png"; }
|
|
key() { wtype "$@"; }
|
|
type() { wtype "$1"; }
|
|
source "$driver"
|
|
) >"$out/driver.log" 2>&1 &
|
|
fi
|
|
timeout "${HIDDEN_TIMEOUT:-300}" tail --pid=$pid -f /dev/null
|
|
status=0
|
|
if kill -0 $pid 2>/dev/null; then echo "timeout"; kill $pid; status=1; fi
|
|
wait $pid 2>/dev/null; code=$?
|
|
grep -q "panicked" "$out/nacre.log" && { echo "panic"; status=1; }
|
|
[ $code -ne 0 ] && [ $status -eq 0 ] && { echo "exit code $code"; status=1; }
|
|
grep -q "ASSERT FAILED" "$out/selftest.log" 2>/dev/null && { echo "assert failed"; status=1; }
|
|
echo "out: $out"
|
|
exit $status
|