coverage_cli.sh 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. mkdir -p "$work/empty" "$work/broken" "$work/store/preset-a" "$work/store/preset-b" "$work/store/preset-c" "$work/store/preset-d"
  28. echo '{ "file": ' > "$work/broken/project.json"
  29. echo '{ "preset": {}, "dependency": ".." }' > "$work/store/preset-a/project.json"
  30. echo '{ "preset": {}, "dependency": "a/b" }' > "$work/store/preset-b/project.json"
  31. echo '{ "preset": {}, "dependency": "99999999" }' > "$work/store/preset-c/project.json"
  32. echo '{ "preset": {}, "dependency": "" }' > "$work/store/preset-d/project.json"
  33. for target in "$work/does-not-exist" "$work/empty" "$work/broken" "$work/store/preset-a" "$work/store/preset-b" \
  34. "$work/store/preset-c" "$work/store/preset-d"; do
  35. render "bad-$(basename "$target")" "$work/bad.png" "$target"
  36. done
  37. host () {
  38. ulimit -c 0
  39. local label=$1
  40. shift
  41. timeout 60 "$BINARY" --assets-dir "$ASSETS" --web-host "$@" > "$work/$label.log" 2>&1
  42. echo "$label: exit $?"
  43. }
  44. # only the argument check: a --web-host that gets as far as CEF without the display setup of a real host aborts with a
  45. # trap, and the host's core_pattern would send that to the desktop's crash handler
  46. host web-host-frames --web-host-frames bogus --web-host-shm lwe-none "$SCENE"