coverage_cli.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env bash
  2. # Command line paths that no scene render reaches: screenshot formats (and one that cannot be written), wallpapers that do
  3. # not load (missing folder, no project.json, broken JSON, presets with bad or missing dependencies) and the refusals of
  4. # the hidden --web-host mode. Nothing here needs a window beyond the headless driver.
  5. # Usage: tools/analysis/coverage_cli.sh <engine binary> [assets dir] [workshop content dir]
  6. set -uo pipefail
  7. HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
  8. BINARY=$(readlink -f "${1:?engine binary}")
  9. ASSETS=${2:-/workspace/SteamLibrary/steamapps/common/wallpaper_engine/assets}
  10. CONTENT=${3:-/workspace/SteamLibrary/steamapps/workshop/content/431960}
  11. work=$(mktemp -d /tmp/lwe-coverage-cli.XXXXXX)
  12. trap 'rm -rf "$work"' EXIT
  13. export SDL_AUDIODRIVER=disk SDL_DISKAUDIOFILE=/dev/null PULSE_SERVER=unix:/nonexistent PIPEWIRE_REMOTE=/nonexistent
  14. SCENE=$CONTENT/${SCENE_ID:-3509578940}
  15. [ -d "$SCENE" ] || { echo "SKIP: $SCENE missing"; exit 0; }
  16. render () {
  17. local label=$1 output=$2
  18. shift 2
  19. HEADLESS_RENDER_DELAY=20 HEADLESS_RENDER_TIMEOUT=60 HEADLESS_RENDER_SIZE=640x360 \
  20. "$HERE/headless_render.sh" "$BINARY" "$output" --assets-dir "$ASSETS" --silent "$@" > "$work/$label.log" 2>&1
  21. echo "$label: exit $?"
  22. }
  23. for extension in bmp jpg jpeg png tga; do
  24. render "screenshot-$extension" "$work/shot.$extension" "$SCENE"
  25. done
  26. render screenshot-unwritable /proc/lwe-no/shot.png "$SCENE"
  27. AUDIO_SCENE=$CONTENT/2326276755
  28. if [ -d "$AUDIO_SCENE" ]; then
  29. render audio-sensitivity "$work/audio.png" --audio-sensitivity '*=2' --audio-sensitivity 'nothing=3' "$AUDIO_SCENE"
  30. fi
  31. mkdir -p "$work/empty" "$work/broken" "$work/store/preset-a" "$work/store/preset-b" "$work/store/preset-c" "$work/store/preset-d"
  32. echo '{ "file": ' > "$work/broken/project.json"
  33. echo '{ "preset": {}, "dependency": ".." }' > "$work/store/preset-a/project.json"
  34. echo '{ "preset": {}, "dependency": "a/b" }' > "$work/store/preset-b/project.json"
  35. echo '{ "preset": {}, "dependency": "99999999" }' > "$work/store/preset-c/project.json"
  36. echo '{ "preset": {}, "dependency": "" }' > "$work/store/preset-d/project.json"
  37. for target in "$work/does-not-exist" "$work/empty" "$work/broken" "$work/store/preset-a" "$work/store/preset-b" \
  38. "$work/store/preset-c" "$work/store/preset-d"; do
  39. render "bad-$(basename "$target")" "$work/bad.png" "$target"
  40. done
  41. host () {
  42. ulimit -c 0
  43. local label=$1
  44. shift
  45. timeout 60 "$BINARY" --assets-dir "$ASSETS" --web-host "$@" > "$work/$label.log" 2>&1
  46. echo "$label: exit $?"
  47. }
  48. # only the argument check: a --web-host that gets as far as CEF without the display setup of a real host aborts with a
  49. # trap, and the host's core_pattern would send that to the desktop's crash handler
  50. host web-host-frames --web-host-frames bogus --web-host-shm lwe-none "$SCENE"