coverage_flatpak.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. # coverage_flatpak.sh <vm> - the engine of a coverage candidate (~/lwe/lwe-hints in the guest, release_check.sh --candidate)
  3. # run inside the Flatpak sandbox of we_manager, which is what makes the compositor's layer shell invisible on Hyprland and
  4. # the engine fetch its Wayland connection from the host (Desktop/HostWayland). Needs FLATPAK_BUNDLE (a we_manager .flatpak, only
  5. # its sandbox and runtime matter, the engine inside is replaced) and a running session (sessenv). Used as
  6. # COVERAGE_STEP by release_check.sh, the profile data of the sandboxed engine goes to $COLLECT_GCOV/<vm>-flatpak.
  7. # Prints one PASS|FAIL line per step.
  8. HERE=$(cd "$(dirname "$0")" && pwd)
  9. vm=$1
  10. app=io.github.WallpaperEngineLover.we_manager
  11. sshv() { "$HERE/linuxvm.sh" ssh "$vm" "$@" </dev/null; }
  12. [ -f "${FLATPAK_BUNDLE:-}" ] || { echo "FAIL no FLATPAK_BUNDLE"; exit 1; }
  13. sshv 'mkdir -p ~/wem'
  14. "$HERE/linuxvm.sh" scp "$vm" "$FLATPAK_BUNDLE" wem/app.flatpak
  15. sshv "flatpak --user remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo; flatpak --user install -y --noninteractive --reinstall ~/wem/app.flatpak >/tmp/fp-install.log 2>&1" \
  16. && echo "PASS the bundle installs" || { echo "FAIL install: $(sshv 'tail -n 3 /tmp/fp-install.log')"; exit 1; }
  17. files=$(sshv "flatpak --user info -l $app")/files
  18. engine=$files/lib/linux-wallpaperengine-kde
  19. sshv "rm -rf '$engine' && cp -a ~/lwe/lwe-hints '$engine' && sed -i 's|^export GCOV_PREFIX=.*|export GCOV_PREFIX=\"\$HOME/.var/app/$app/gcov\" GCOV_PREFIX_STRIP=0|' '$engine/linux-wallpaperengine'" \
  20. && echo "PASS the coverage engine is inside the Flatpak" || { echo "FAIL could not replace the engine"; exit 1; }
  21. sshv 'rm -rf ~/.var/app/'$app'/gcov; mkdir -p ~/.var/app/'$app'/gcov'
  22. run_engine() {
  23. local label=$1 seconds=$2
  24. shift 2
  25. sshv ". ~/sessenv; (setsid nohup flatpak run --command=/app/lib/linux-wallpaperengine-kde/linux-wallpaperengine $app --assets-dir \$HOME/lwe/assets --screen-root \${SCREEN:-Virtual-1} --silent $* > /tmp/fp-$label.log 2>&1 </dev/null &); sleep $seconds"
  26. local pids
  27. pids=$(sshv 'pgrep -f "/linux-wallpaperengine[.]bin"' | wc -l)
  28. sshv 'pkill -TERM -f "/linux-wallpaperengine[.]bin"; sleep 5; pkill -KILL -f "/linux-wallpaperengine[.]bin"; true'
  29. if [ "$pids" -gt 0 ]; then echo "PASS $label: the sandboxed engine ran"; else echo "FAIL $label: no engine process: $(sshv "tail -n 3 /tmp/fp-$label.log")"; fi
  30. sshv "grep -m1 -i 'helper\|layer shell\|Wayland' /tmp/fp-$label.log | cut -c1-150"
  31. }
  32. run_engine scene 40 '$HOME/lwe/wp-1120596121'
  33. run_engine web 60 '$HOME/lwe/wp-1078208425'
  34. run_engine puppet 30 '$HOME/lwe/wp-3471294034'
  35. if [ -n "${COLLECT_GCOV:-}" ]; then
  36. mkdir -p "$COLLECT_GCOV/$vm-flatpak"
  37. sshv "tar -C ~/.var/app/$app/gcov -cf - . 2>/dev/null" | tar -C "$COLLECT_GCOV/$vm-flatpak" -xf -
  38. fi