1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
#!/bin/bash
set -eu
help() {
echo "Usage: $0 [OPTION] [--] [ARGS]"
echo
echo "Options:"
echo " -m, --mode MODE - Use selected mode:"
echo " sru-validation - Ubuntu SRU validation"
echo " native-package - Use native package"
echo " -n, --no-rebuild - Do not rebuild snapd snap"
echo " -- - Delimiter for arguments parsed by this script"
echo " ARGS - Arguments passed to spread"
echo
}
need_rebuild=1
mode=""
no_rebuild=0
while true; do
case "${1-}" in
--help|-h)
help
exit 0
;;
--mode|-m)
shift
maybe_mode="$1"
shift
if [ "$mode" != "" ]; then
echo "already using mode $mode"
exit 1
fi
case "$maybe_mode" in
sru-validation)
mode="sru-validation"
;;
native-package)
mode="native-package"
;;
*)
echo "unsupported mode: $maybe_mode"
exit 1
;;
esac
;;
--no-rebuild|-n)
no_rebuild=1
shift
;;
--)
shift
break
;;
*)
break
;;
esac
done
set -x
shopt -s nullglob
if [ "${NO_REBUILD:-0}" = "1" ]; then
echo "-- $(date) -- requested no snap rebuild"
need_rebuild=0
# check if we have any snaps built at all
built_snaps=(built-snap/snapd_*.snap.keep)
if (( "${#built_snaps[@]}" > 0 )); then
echo "-- $(date) -- found prebuilt snapd snaps:"
for s in "${built_snaps[@]}"; do
echo "-- $s"
done
else
echo "-- $(date) -- no prebuilt snaps found"
if [ "$no_rebuild" = "1" ]; then
# no rebuild explicitly requested
echo "either drop --no-rebuild or use ./tests/build-test-snapd-snap to build the snap"
exit 1
fi
need_rebuild=1
fi
fi
if [ "$need_rebuild" = 1 ]; then
echo "-- $(date) -- rebuilding snapd snap"
./tests/build-test-snapd-snap
echo "-- $(date) -- snapd snap rebuild complete"
fi
if [ -t 1 ]; then
export SPREAD_DEBUG_EACH=0
fi
case "$mode" in
sru-validation)
echo "-- SRU validation mode"
export SPREAD_SNAP_REEXEC=0
export SPREAD_SRU_VALIDATION=1
;;
native-package)
echo "-- native package mode"
export SPREAD_SNAP_REEXEC=0
export SPREAD_SNAPD_DEB_FROM_REPO=false
;;
esac
export SPREAD_USE_PREBUILT_SNAPD_SNAP=true
# check that we are passing a test suite (in the form of
# <backend>:<system>:<test>) to spread, otherwise this would turn into a very
# annoyng spread invocation
maybe_has_ts=0
for arg in "$@"; do
if [ "${arg/://}" != "$arg" ]; then
maybe_has_ts=1
break
fi
done
if [ "$maybe_has_ts" = "0" ]; then
echo "error: attempting to run spread without any arguments, this would launch all test suites"
exit 1
fi
# Run spread
exec spread "$@"
|