desktop_icons_matrix.sh 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/bash
  2. # desktop_icons_matrix.sh [--lanes N] [--log file] [vm[:WxH]]... - desktop_icons_check.sh over VMs, each from its golden state,
  3. # LANES (default 4) at a time, VMs powered off afterwards. Without arguments: every profile, fedora-kde also at 1280x800, 2560x1440
  4. # and 3840x2160. The profile gives what the release gate does to get a session (LOGIN_PASSWORD at a greeter, PREP, a second
  5. # monitor is not used). Per VM log in <log dir>/<vm>-<size>.log, the merged result in the log file.
  6. # VIDEO_APP (we_manager linux-unpacked) adds video_optimize_check.sh after the icons check (once per VM, at 1920x1080); on a profile
  7. # with WEM=deb the check installs and runs VIDEO_DEB instead. SKIP_ICONS=1 leaves out the icons check. WEM_LAUNCH and WEM_FLAGS of the
  8. # profile are passed on.
  9. # CAND is a folder with lwe-hints/ (the engine under test) copied over the guest's ~/lwe/lwe-hints, as release_check.sh does.
  10. # Slots: at most MAXVMS (default 5) VMs run at once over every copy of this script (a flock per slot in /tmp/lwe-vm-slots), the
  11. # queue itself takes LANES of them. A re-run of a VM that failed because of the harness is just another invocation with that VM
  12. # (`desktop_icons_matrix.sh --log x.log vm`): it takes any free slot, the fifth or one the queue left behind when it ran dry.
  13. HERE=$(cd "$(dirname "$0")" && pwd)
  14. lanes=${LANES:-4} log=${XDG_CACHE_HOME:-$HOME/.cache}/lwe-release-prep/desktop-icons/matrix.log
  15. list=()
  16. while [ $# -gt 0 ]; do
  17. case $1 in
  18. --lanes) lanes=$2; shift ;;
  19. --log) log=$2; shift ;;
  20. *) list+=("$1") ;;
  21. esac
  22. shift
  23. done
  24. if [ ${#list[@]} -eq 0 ]; then
  25. for f in "$HERE"/profiles/*.sh; do list+=("$(basename "$f" .sh)"); done
  26. list+=(fedora-kde:1280x800 fedora-kde:2560x1440 fedora-kde:3840x2160)
  27. fi
  28. dir=$(dirname "$log")
  29. mkdir -p "$dir"
  30. . "$HERE/vm_slots.sh"
  31. export HERE dir
  32. export MAXVMS=${MAXVMS:-5} CAND VIDEO_APP VIDEO_DEB SKIP_ICONS WEM_FLAGS WEM_LAUNCH
  33. one() {
  34. local entry=$1 vm size out
  35. take_slot
  36. vm=${entry%%:*}
  37. size=1920x1080
  38. [[ $entry == *:* ]] && size=${entry#*:}
  39. out=$dir/$vm-$size.log
  40. {
  41. echo "=== $vm $size $(date +%T)"
  42. local caller_flags=$WEM_FLAGS caller_launch=$WEM_LAUNCH
  43. unset VM SCREEN LOGIN_PASSWORD PREP BOOT_PREP ICONS WEM WEM_FLAGS WEM_LAUNCH
  44. # shellcheck disable=SC1090
  45. . "$HERE/profiles/$vm.sh" || { echo "FAIL $vm: no profile"; exit 0; }
  46. WEM_FLAGS=${WEM_FLAGS:-$caller_flags} WEM_LAUNCH=${WEM_LAUNCH:-$caller_launch}
  47. export WEM_FLAGS WEM_LAUNCH
  48. [ -n "$BOOT_PREP" ] && { echo "SKIP $vm: the profile switches the session with BOOT_PREP, the release gate runs it"; exit 0; }
  49. # a profile can name another VM (zorin-xorg runs on zorin-gnome's disk), and a disk runs one entry at a time
  50. vm=${VM:-$vm}
  51. exec {DISK_FD}>"/tmp/lwe-vm-slots/disk-$vm.lock"
  52. flock "$DISK_FD"
  53. local run_icons=1 run_video=0
  54. [ -n "$VIDEO_APP" ] && [ "$size" = 1920x1080 ] && run_video=1
  55. if [ "$ICONS" = 0 ]; then
  56. echo "SKIP $vm: ICONS=0 in the profile"
  57. run_icons=0
  58. [ $run_video = 1 ] || exit 0
  59. fi
  60. "$HERE/linuxvm.sh" fresh "$vm" >/dev/null 2>&1
  61. LINUXVM_SIZE=$size "$HERE/linuxvm.sh" start "$vm" >/dev/null 2>&1
  62. local logged_in=0
  63. for _ in $(seq 60); do
  64. if [ -n "$LOGIN_PASSWORD" ] && [ $logged_in = 0 ] && "$HERE/linuxvm.sh" ssh "$vm" true </dev/null 2>/dev/null; then
  65. sleep 25; "$HERE/linuxvm.sh" type "$vm" "$LOGIN_PASSWORD"; "$HERE/linuxvm.sh" keys "$vm" ret; logged_in=1
  66. fi
  67. "$HERE/linuxvm.sh" scp "$vm" "$HERE/sessenv.sh" lwe/sessenv.sh 2>/dev/null \
  68. && "$HERE/linuxvm.sh" ssh "$vm" "bash ~/lwe/sessenv.sh" </dev/null >/dev/null 2>&1 && break
  69. sleep 5
  70. done
  71. [ -n "$PREP" ] && "$HERE/linuxvm.sh" ssh "$vm" ". ~/sessenv; $PREP" </dev/null
  72. if [ -n "$CAND" ]; then
  73. "$HERE/linuxvm.sh" ssh "$vm" "rm -rf ~/lwe/lwe-hints.new" </dev/null
  74. "$HERE/linuxvm.sh" scp "$vm" "$CAND/lwe-hints" lwe/lwe-hints.new \
  75. && "$HERE/linuxvm.sh" ssh "$vm" "rm -rf ~/lwe/lwe-hints && mv ~/lwe/lwe-hints.new ~/lwe/lwe-hints" </dev/null
  76. fi
  77. sleep 20
  78. if [ "$SKIP_ICONS" != 1 ] && [ $run_icons = 1 ]; then
  79. timeout 900 "$HERE/desktop_icons_check.sh" "$vm" "${SCREEN:-Virtual-1}" 2>&1
  80. [ $? = 124 ] && echo "FAIL $vm: the icons check timed out after 900 s"
  81. fi
  82. if [ $run_video = 1 ]; then
  83. echo "--- video optimize"
  84. vapp=$VIDEO_APP
  85. [ "$WEM" = deb ] && [ -n "$VIDEO_DEB" ] && vapp=$VIDEO_DEB
  86. timeout 1500 "$HERE/video_optimize_check.sh" "$vm" "$vapp" "${SCREEN:-Virtual-1}" 2>&1
  87. [ $? = 124 ] && echo "FAIL $vm: the video check timed out after 1500 s"
  88. fi
  89. "$HERE/linuxvm.sh" ssh "$vm" 'sudo systemctl poweroff' </dev/null >/dev/null 2>&1
  90. sleep 15
  91. "$HERE/linuxvm.sh" kill "$vm" >/dev/null 2>&1
  92. } > "$out" 2>&1
  93. }
  94. export -f one take_slot
  95. printf '%s\n' "${list[@]}" | xargs -P "$lanes" -I{} bash -c 'one {}'
  96. : > "$log"
  97. for entry in "${list[@]}"; do
  98. vm=${entry%%:*}; size=1920x1080; [[ $entry == *:* ]] && size=${entry#*:}
  99. grep -hv '^ screenshots' "$dir/$vm-$size.log" >> "$log"
  100. done
  101. echo DONE >> "$log"
  102. grep -c '^FAIL' "$log" | sed 's/^/failed: /'