Pārlūkot izejas kodu

added few tools and updated the text

UwU 1 mēnesi atpakaļ
vecāks
revīzija
7acfd062d9

+ 9 - 0
tools/linuxvm/RELEASE_TESTING.md

@@ -61,6 +61,15 @@ I start `release_check.sh` in the background and watch it, roughly 10 minutes pe
 A failing VM is reported with its screenshot and log excerpt and the matrix carries on with the next one. I do not fix
 and re-tag on my own: the report goes to the maintainer first. Cleanup after a run: all VMs powered off, overlays gone.
 
+## State (2026-10-19)
+
+Written and used on the five new VMs: `guest_test.sh` (engine per wallpaper: running, no crash text, screenshot, stops on
+SIGTERM, no web helper left), `check_frame.py --baseline` (compares with the desktop without a wallpaper), `sessenv.sh`
+(session variables from a desktop process), `host_shots.sh` (screenshots through the VM's display, for COSMIC). Not written
+yet: the per-VM profiles, golden snapshots with throwaway overlays, and `release_check.sh` that loops over all VMs.
+Per VM notes: KDE VMs need screen lock and sleep disabled plus `kde-inhibit` at login; Bazzite's /home is /var/home;
+Debian's cloud image needs the regular kernel for Wayland; GNOME needs its extension enabled and one relogin.
+
 ## Order of work
 
 1. Finish the first batch of VMs (Debian GNOME, openSUSE Tumbleweed KDE, Manjaro KDE, Pop!_OS COSMIC, Bazzite).

+ 13 - 0
tools/linuxvm/check_frame.py

@@ -1,4 +1,5 @@
 """check_frame.py [--baseline base.png] shot.png [shot.png ...] - did the wallpaper reach the screen?
+check_frame.py --differ a.png b.png - do two frames differ (hotswap)?
 
 Without --baseline a screenshot only fails when it is pure black. With the baseline (the desktop's own screenshot taken
 before the engine started) it must also differ from it along the right edge and the top, where windows, panels and
@@ -36,8 +37,20 @@ def check(path, baseline):
     return True, f"mean {mean:.0f}, stddev {stddev:.0f}"
 
 
+def differ(a, b):
+    """Two frames of the same desktop must differ clearly (a hotswap changed the picture)."""
+    first, second = Image.open(a).convert("RGB"), Image.open(b).convert("RGB").resize(Image.open(a).size)
+    parts = list(zip(strips(first), strips(second)))
+    diff = sum(ImageStat.Stat(ImageChops.difference(x, y).convert("L")).mean[0] for x, y in parts) / len(parts)
+    ok = diff >= 6
+    print(f"{'PASS' if ok else 'FAIL'} {b}: {'differs from' if ok else 'same as'} {a} (difference {diff:.1f})")
+    sys.exit(0 if ok else 1)
+
+
 def main():
     args = sys.argv[1:]
+    if args[:1] == ["--differ"]:
+        differ(args[1], args[2])
     baseline = None
     if args[:1] == ["--baseline"]:
         baseline = Image.open(args[1]).convert("RGB")

+ 30 - 0
tools/linuxvm/fullscreen_window.py

@@ -0,0 +1,30 @@
+"""fullscreen_window.py - a plain fullscreen window for the pause-on-fullscreen check (GTK 3, else GTK 4).
+Runs until it is killed. Exit code 2 when neither GTK is importable."""
+import sys
+
+import gi
+
+try:
+    gi.require_version("Gtk", "3.0")
+    from gi.repository import Gtk
+
+    window = Gtk.Window(title="lwe-fullscreen-test")
+    window.fullscreen()
+    window.connect("destroy", Gtk.main_quit)
+    window.show_all()
+    Gtk.main()
+except (ValueError, ImportError):
+    try:
+        gi.require_version("Gtk", "4.0")
+        from gi.repository import GLib, Gtk
+    except (ValueError, ImportError):
+        sys.exit(2)
+
+    def activate(app):
+        window = Gtk.ApplicationWindow(application=app, title="lwe-fullscreen-test")
+        window.fullscreen()
+        window.present()
+
+    app = Gtk.Application(application_id="test.lwe.Fullscreen")
+    app.connect("activate", activate)
+    app.run([])

+ 66 - 1
tools/linuxvm/guest_test.sh

@@ -13,7 +13,7 @@
 LWE_DIR=$(realpath "${LWE_DIR:-$HOME/lwe}")
 ENGINE=$LWE_DIR/lwe-hints/linux-wallpaperengine
 OUT=${OUT:-/tmp/lwe-test}
-WALLPAPERS=${WALLPAPERS:-"1111948150 1120596121 1078208425 834237690"}
+WALLPAPERS=${WALLPAPERS-"1111948150 1120596121 1078208425 834237690"}
 SETTLE=${SETTLE:-25}
 mkdir -p "$OUT"
 rm -f "$OUT/done"
@@ -66,5 +66,70 @@ for id in $WALLPAPERS; do
     if stop_engine; then pass "$id: engine stopped on SIGTERM"; else fail "$id: engine needed SIGKILL"; fi
     if pgrep -f "[l]inux-wallpaperengine-web-helper" >/dev/null; then fail "$id: web helper left behind"; else pass "$id: no web helper left behind"; fi
 done
+# wait_for_log <file> <text> <seconds> <lines of it seen before>: true once more lines than that contain the text
+wait_for_log() {
+    for _ in $(seq "$3"); do
+        [ "$(grep -c "$2" "$1")" -gt "$4" ] && return 0
+        sleep 1
+    done
+    return 1
+}
+
+# behaviour checks, BEHAVIOR=1: hotswap, pause on fullscreen, SIGKILL leaves no helper
+if [ "${BEHAVIOR:-0}" = 1 ]; then
+    A=${HOTSWAP_FROM:-1120596121}
+    B=${HOTSWAP_TO:-1111948150}
+    ctl=$OUT/control
+    : > "$ctl"
+    # shellcheck disable=SC2086
+    (setsid nohup "$ENGINE" --assets-dir "$LWE_DIR/assets" $LWE_ARGS --control-file "$ctl" "$LWE_DIR/wp-$A" > "$OUT/engine-behavior.log" 2>&1 < /dev/null &)
+    sleep "$SETTLE"
+    pid=$(engine_pids | head -1)
+    if [ -z "$pid" ]; then fail "behavior: engine did not start"; else
+        SHOT_FILE=$OUT/hot-before.png; rm -f "$SHOT_FILE"; take_shot "$SHOT_FILE" "$OUT/hot-before.log"
+        echo "path=$LWE_DIR/wp-$B" > "$ctl"
+        kill -USR1 "$pid"
+        sleep 15
+        if grep -q "Hotswapping wallpaper to" "$OUT/engine-behavior.log"; then pass "hotswap: engine took the new wallpaper"; else fail "hotswap: no hotswap in the log"; fi
+        if kill -0 "$pid" 2>/dev/null; then pass "hotswap: same process still running"; else fail "hotswap: engine exited"; fi
+        SHOT_FILE=$OUT/hot-after.png; rm -f "$SHOT_FILE"; take_shot "$SHOT_FILE" "$OUT/hot-after.log"
+
+        # back to the first wallpaper so the CPU numbers are of a scene with particles
+        echo "path=$LWE_DIR/wp-$A" > "$ctl"; kill -USR1 "$pid"; sleep 12
+        if [ -n "$FULLSCREEN_CMD" ]; then
+            log=$OUT/engine-behavior.log
+            paused_before=$(grep -c "Paused: windows" "$log"); resumed_before=$(grep -c "Resumed" "$log")
+            eval "$FULLSCREEN_CMD" > "$OUT/fullscreen-window.log" 2>&1 &
+            fs_pid=$!
+            if grep -q "Fullscreen detection not supported" "$log"; then
+                echo "SKIP fullscreen pause: the compositor has no fullscreen detection"
+            elif wait_for_log "$log" "Paused: windows" 45 "$paused_before"; then
+                pass "fullscreen pause: engine paused"
+                kill "$fs_pid" 2>/dev/null; pkill -f "lwe-fullscreen-test|fullscreen_window.py" 2>/dev/null
+                if wait_for_log "$log" "Resumed" 45 "$resumed_before"; then pass "fullscreen pause: engine resumed"; else fail "fullscreen pause: no resume after the window closed"; fi
+            else
+                fail "fullscreen pause: no pause within 45s of a fullscreen window"
+            fi
+            kill "$fs_pid" 2>/dev/null; pkill -f "lwe-fullscreen-test|fullscreen_window.py" 2>/dev/null
+        else
+            echo "SKIP fullscreen pause: no FULLSCREEN_CMD for this desktop"
+        fi
+        stop_engine
+    fi
+
+    # SIGKILL: the web host must not outlive the engine
+    # shellcheck disable=SC2086
+    (setsid nohup "$ENGINE" --assets-dir "$LWE_DIR/assets" $LWE_ARGS "$LWE_DIR/wp-1078208425" > "$OUT/engine-kill.log" 2>&1 < /dev/null &)
+    sleep "$SETTLE"
+    pid=$(engine_pids | head -1)
+    helpers_before=$(pgrep -fc "[l]inux-wallpaperengine-web-helper")
+    kill -9 "$pid" 2>/dev/null
+    sleep 8
+    helpers_after=$(pgrep -fc "[l]inux-wallpaperengine-web-helper")
+    if [ "$helpers_before" -gt 0 ] && [ "$helpers_after" -eq 0 ]; then pass "SIGKILL: $helpers_before web host processes ended with the engine"
+    elif [ "$helpers_before" -eq 0 ]; then fail "SIGKILL: no web host was running to begin with"
+    else fail "SIGKILL: $helpers_after of $helpers_before web host processes left behind"; pkill -f "linux-wallpaperengine-web-helper"; fi
+fi
+
 touch "$OUT/done"
 exit $status

+ 17 - 0
tools/linuxvm/run_behavior.sh

@@ -0,0 +1,17 @@
+#!/bin/bash
+# run_behavior.sh <vm> <session screen name> <fullscreen command> - the behaviour phase of guest_test.sh on a running VM
+# (hotswap, pause on fullscreen, SIGKILL cleanup) with host side screenshots, then checks the hotswap pictures differ.
+HERE=$(cd "$(dirname "$0")" && pwd)
+vm=$1 screen=$2 fullscreen=$3
+out=${OUT_DIR:-/tmp/lwe-test}
+"$HERE/linuxvm.sh" scp "$vm" "$HERE/guest_test.sh" lwe/guest_test.sh
+"$HERE/linuxvm.sh" scp "$vm" "$HERE/fullscreen_window.py" lwe/fullscreen_window.py
+"$HERE/linuxvm.sh" ssh "$vm" "rm -rf $out; mkdir -p $out" </dev/null
+"$HERE/host_shots.sh" "$vm" "$out" 500 > /dev/null 2>&1 &
+"$HERE/linuxvm.sh" ssh "$vm" ". ~/sessenv; BEHAVIOR=1 WALLPAPERS= SETTLE=${SETTLE:-25} LWE_ARGS='--screen-root $screen' SHOT_CMD=host FULLSCREEN_CMD='$fullscreen' ~/lwe/guest_test.sh" </dev/null
+wait
+local=$(mktemp -d)
+scp -q -r -i "$HOME/.local/share/linuxvm/id_ed25519" -P "$(cat "$HOME/.local/share/linuxvm/vms/$vm/port")" -o StrictHostKeyChecking=no \
+    -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR "lab@127.0.0.1:$out/*.png" "$local/" 2>/dev/null
+python3 -I "$HERE/check_frame.py" --differ "$local/hot-before.png" "$local/hot-after.png"
+echo "pictures in $local"