check_dump_structure.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env bash
  2. # Smoke check of --dump-structure (Data/Dumpers/StringPrinter): dumps a few feature-rich scenes and one video wallpaper
  3. # headlessly and requires the dump to name every object the scene has (the "Objects count: N" header against the number
  4. # of "Object <id>" lines) and the video's file name. A printer that crashes on a model, material, effect or sound shows
  5. # up as a failed render.
  6. # Usage: tools/check_dump_structure.sh <engine binary> [assets dir] [workshop content dir]
  7. # Set SCENE_IDS (space separated) and VIDEO_ID to use other wallpapers. Missing ones are skipped.
  8. set -euo pipefail
  9. HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  10. BINARY=${1:?engine binary}
  11. ASSETS=${2:-/workspace/SteamLibrary/steamapps/common/wallpaper_engine/assets}
  12. CONTENT=${3:-/workspace/SteamLibrary/steamapps/workshop/content/431960}
  13. SCENE_IDS=${SCENE_IDS:-"3662790108 3509578940 3354366708 3521337568 3287715210 3409595232 3758232320 1251404246 2719499501"}
  14. VIDEO_ID=${VIDEO_ID:-1367456719}
  15. work=$(mktemp -d /tmp/lwe-dump-structure.XXXXXX)
  16. trap 'rm -rf "$work"' EXIT
  17. failed=0
  18. checked=0
  19. dump () {
  20. HEADLESS_RENDER_SIZE=800x450 "$HERE/headless_render.sh" "$BINARY" "$work/shot.png" --dump-structure \
  21. --assets-dir "$ASSETS" --fps 30 --silent "$CONTENT/$1" > "$work/$1.log" 2>&1
  22. }
  23. for id in $SCENE_IDS; do
  24. [ -d "$CONTENT/$id" ] || { echo "SKIP: $id not in $CONTENT"; continue; }
  25. checked=$((checked + 1))
  26. if ! dump "$id"; then
  27. echo "FAIL: $id did not render with --dump-structure"
  28. tail -5 "$work/$id.log"
  29. failed=1
  30. continue
  31. fi
  32. declared=$(sed -n 's/^[[:space:]]*Objects count: \([0-9]*\).*/\1/p' "$work/$id.log" | head -1)
  33. printed=$(grep -c '^[[:space:]]*Object [0-9-]* ' "$work/$id.log" || true)
  34. if [ -z "$declared" ] || [ "$declared" -eq 0 ] || [ "$declared" -ne "$printed" ]; then
  35. echo "FAIL: $id declares ${declared:-no} objects and prints $printed"
  36. failed=1
  37. else
  38. echo "PASS: $id prints its $printed objects"
  39. fi
  40. done
  41. if [ -d "$CONTENT/$VIDEO_ID" ]; then
  42. checked=$((checked + 1))
  43. if dump "$VIDEO_ID" && grep -q '^Video wallpaper: ' "$work/$VIDEO_ID.log"; then
  44. echo "PASS: $VIDEO_ID is dumped as a video wallpaper"
  45. else
  46. echo "FAIL: $VIDEO_ID has no \"Video wallpaper:\" line"
  47. failed=1
  48. fi
  49. fi
  50. [ "$checked" -gt 0 ] || { echo "SKIP: none of the wallpapers is installed"; exit 0; }
  51. exit $failed