coverage_scripts.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env bash
  2. # Renders the scenes of make_script_scenes.py: script API argument checks, script errors, a runaway update and a heap
  3. # hog (the last two with the script limits switched on, they are off by default). Audio goes nowhere.
  4. # Usage: tools/analysis/coverage_scripts.sh <engine binary> [assets dir]
  5. set -uo pipefail
  6. HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
  7. BINARY=${1:?engine binary}
  8. ASSETS=${2:-/workspace/SteamLibrary/steamapps/common/wallpaper_engine/assets}
  9. work=$(mktemp -d /tmp/lwe-coverage-scripts.XXXXXX)
  10. trap 'rm -rf "$work"' EXIT
  11. export SDL_AUDIODRIVER=disk SDL_DISKAUDIOFILE=/dev/null PULSE_SERVER=unix:/nonexistent PIPEWIRE_REMOTE=/nonexistent
  12. python3 -I "$HERE/analysis/make_script_scenes.py" "$work/scenes" "$ASSETS" > /dev/null || exit 1
  13. render () {
  14. local name=$1 delay=$2
  15. shift 2
  16. env "$@" HEADLESS_RENDER_DELAY="$delay" HEADLESS_RENDER_TIMEOUT=120 HEADLESS_RENDER_SIZE=800x450 \
  17. "$HERE/headless_render.sh" "$BINARY" "$work/$name.png" --assets-dir "$ASSETS" "$work/scenes/$name" \
  18. > "$work/$name.log" 2>&1
  19. echo "$name: exit $?, $(grep -c -i 'error' "$work/$name.log") error lines"
  20. }
  21. render fuzz 120
  22. render errors 60
  23. render runaway 90 LWE_SCRIPT_TIMEOUT_MS=200
  24. render heap 90 LWE_SCRIPT_HEAP_MB=64 LWE_SCRIPT_BUFFER_MB=16
  25. render sounds 80
  26. path=$(python3 -I - <<'PY'
  27. steps = []
  28. for i in range(60):
  29. x = (100 + (2 + i) * 20) / 1920
  30. steps.append("%.2f:%.4f,0.7222%s" % (0.2 + i * 0.1, x, ",d" if i % 4 == 1 else ""))
  31. print(";".join(steps))
  32. PY
  33. )
  34. render errors 200 LWE_HEADLESS_CURSOR_PATH="$path" LWE_FIXED_TIMESTEP=0.05
  35. # a library puppet with a script on its layer: animation layer and bone calls, effect and blend mode changes
  36. item=${LWE_WORKSHOP_DIR:-/workspace/SteamLibrary/steamapps/workshop/content/431960}/2997511253
  37. if [ -f "$item/scene.pkg" ]; then
  38. python3 -I "$HERE/analysis/make_puppet_script_scene.py" "$item" 81 "$work/scenes/puppet" > /dev/null \
  39. && python3 -I "$HERE/analysis/make_puppet_script_scene.py" "${item%/*}/3435733083" 28 "$work/scenes/puppet-extras" 420,3214,3295 > /dev/null \
  40. && render puppet-extras 200 \
  41. && render puppet 150 \
  42. && render puppet 260 LWE_FIXED_TIMESTEP=0.05 LWE_HEADLESS_CURSOR_PATH="$(python3 -I -c '
  43. steps = []
  44. for i in range(60):
  45. steps.append("%.2f:%.3f,%.3f%s" % (0.3 + i * 0.2, 0.1 + 0.8 * (i % 10) / 9, 0.15 + 0.7 * (i // 10) / 5, ",d" if i % 3 == 1 else ""))
  46. print(";".join(steps))')"
  47. fi
  48. # a video file as an image layer's texture, a script calls the video texture API (mpeg4: this sandbox has no H.264)
  49. if command -v ffmpeg > /dev/null; then
  50. ffmpeg -loglevel error -y -f lavfi -i "testsrc=s=320x180:r=30" -t 1 -c:v mpeg4 "$work/clip.mp4" \
  51. && python3 -I "$HERE/analysis/make_video_texture_scene.py" "$work/scenes/videotexture" "$work/clip.mp4" > /dev/null \
  52. && render videotexture 150 \
  53. && python3 -I "$HERE/analysis/make_video_texture_scene.py" "$work/scenes/videotexture-runaway" "$work/clip.mp4" runaway > /dev/null \
  54. && render videotexture-runaway 400 LWE_SCRIPT_TIMEOUT_MS=200 LWE_FIXED_TIMESTEP=0.05
  55. fi