|
| 1 | +#!/bin/sh -eu |
| 2 | + |
| 3 | +case "$RUNNER_OS" in |
| 4 | + Linux) |
| 5 | + ug_build=UltraGrid-continuous-x86_64.AppImage |
| 6 | + prepare() { |
| 7 | + chmod +x "$ug_build" |
| 8 | + ./"$ug_build" --appimage-extract |
| 9 | + } |
| 10 | + run=squashfs-root/AppRun |
| 11 | + ;; |
| 12 | + Windows) |
| 13 | + ug_build=UltraGrid-continuous-win64.zip |
| 14 | + prepare() { |
| 15 | + unzip "$ug_build" |
| 16 | + } |
| 17 | + run=UltraGrid-continuous-win64/uv.exe |
| 18 | + ;; |
| 19 | + macOS) |
| 20 | + ug_build=UltraGrid-continuous-arm64.dmg |
| 21 | + prepare() { |
| 22 | + hdiutil mount "$ug_build" |
| 23 | + } |
| 24 | + run=/Volumes/ULTRAGRID/uv-qt.app/Contents/MacOS/uv |
| 25 | +esac |
| 26 | + |
| 27 | +curl -LOf https://github.com/CESNET/UltraGrid/releases/download/continuous/\ |
| 28 | +"$ug_build" |
| 29 | + |
| 30 | +prepare |
| 31 | + |
| 32 | +## used by run_test_data.sh |
| 33 | +## @param $1 args |
| 34 | +## @param $2 timeout (optional, default 5) |
| 35 | +## @param $3 opts (optional) - should_fail |
| 36 | +add_test() { |
| 37 | + eval "test_${test_count}_args=\${1?}" |
| 38 | + eval "test_${test_count}_timeout=\${2:-5}" |
| 39 | + eval "test_${test_count}_opts=\${3-}" |
| 40 | + test_count=$((test_count + 1)) |
| 41 | +} |
| 42 | + |
| 43 | +test_count=0 |
| 44 | +. "$(dirname "$0")"/run_tests_data.sh |
| 45 | + |
| 46 | +set +e |
| 47 | +i=0 |
| 48 | +while [ $i -lt $test_count ]; do |
| 49 | + eval "args=\$test_${i}_args" |
| 50 | + eval "timeout=\$test_${i}_timeout" |
| 51 | + eval "opts=\$test_${i}_opts" |
| 52 | + |
| 53 | + timeout "$timeout" "$run" "$args" |
| 54 | + rc=$? |
| 55 | + |
| 56 | + if [ $rc = 124 ]; then |
| 57 | + printf "UG with arguments %s timeout (limit: %d sec)!\n" \ |
| 58 | + "$args" "$timeout" |
| 59 | + exit 1 |
| 60 | + fi |
| 61 | + |
| 62 | + if expr -- "$opts" : '.*should_fail' >/dev/null; then |
| 63 | + if [ $rc -eq 0 ]; then |
| 64 | + printf "UG with arguments %s should have failed but\ |
| 65 | + returned 0!\n" "$args" |
| 66 | + exit 1 |
| 67 | + fi |
| 68 | + else |
| 69 | + if [ $rc -ne 0 ]; then |
| 70 | + printf "UG with arguments %s returned %d but should have\ |
| 71 | + succeeeded!\n" "$args" "$rc" |
| 72 | + exit 1 |
| 73 | + fi |
| 74 | + |
| 75 | + fi |
| 76 | + |
| 77 | + i=$((i + 1)) |
| 78 | +done |
| 79 | + |
0 commit comments