#!/bin/sh # Boot the built rootfs under QEMU and photograph the desktop. # # scripts/guitest.sh [seconds-before-screenshot] # # Writes qemu/psionlx.png plus the session's process list and error log # next to it. The initramfs runs /guitest.sh in preference to /build.sh, # so the whole thing is driven by a script written into a copy of the # image with debugfs. # # Two things that have cost time here: debugfs's "write" silently does # nothing if the file already exists, so it is removed first; and the # session must have DISPLAY exported before 99psion-session runs, or # every client dies with "failed to open display" and the screen stays # black, which looks exactly like a desktop crash. set -e W=$(cd "$(dirname "$0")/.." && pwd) WAIT=${1:-80} DBG=/opt/homebrew/opt/e2fsprogs/sbin/debugfs cp "$W/card/rootfs.ext2" "$W/qemu/gui.ext2" cat > /tmp/guitest-inner.sh <<'GT' #!/bin/sh exec > /diag.log 2>&1 set -x B=/bin/busybox $B mount -t proc proc /proc 2>/dev/null $B mount -t sysfs sysfs /sys 2>/dev/null for s in /etc/init.d/populate-var.sh /etc/init.d/lxuser.sh; do [ -x "$s" ] && $B sh "$s" start done $B mkdir -p /var/tmp /var/log /tmp; $B chmod 1777 /tmp /var/tmp /usr/bin/Xfbdev -screen 800x600x16 -dpi 100 -br -pn -ac :0 2>/dev/null & $B sleep 8 export DISPLAY=:0 $B sh /etc/X11/Xinit.d/99psion-session & $B sleep 60 $B ps w > /psion-ps.txt 2>&1 $B cp /var/tmp/xsession-errors.lx /psion-xerr.txt 2>/dev/null $B sync $B sleep 600 GT $DBG -w -f /dev/stdin "$W/qemu/gui.ext2" >/dev/null 2>&1 < /dev/null 2>&1 & QP=$! python3 - "$WAIT" <<'PY' import socket, json, sys, time time.sleep(int(sys.argv[1])) s = socket.socket(socket.AF_UNIX); s.connect('/tmp/qmp.sock') f = s.makefile('rw'); f.readline() f.write(json.dumps({"execute": "qmp_capabilities"}) + "\n"); f.flush(); f.readline() f.write(json.dumps({"execute": "screendump", "arguments": {"filename": "/tmp/psionlx.ppm"}}) + "\n") f.flush(); print(f.readline().strip()); s.close() PY python3 -c "from PIL import Image; Image.open('/tmp/psionlx.ppm').convert('RGB').save('$W/qemu/psionlx.png')" kill $QP 2>/dev/null || true sleep 2 for f in psion-ps.txt psion-xerr.txt diag.log; do rm -f "$W/qemu/$f" $DBG -R "dump /$f $W/qemu/$f" gui.ext2 >/dev/null 2>&1 done echo "== $W/qemu/psionlx.png" echo "== session processes:" grep -aE 'matchbox|gpe-|minimix|applet' "$W/qemu/psion-ps.txt" 2>/dev/null | sed 's/^/ /'