This repository has been archived by the owner on Oct 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
/
run-spread-tests.sh
executable file
·84 lines (77 loc) · 2.33 KB
/
run-spread-tests.sh
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
#!/bin/bash
#
# Copyright (C) 2016 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
image_name=ubuntu-core-16.img
channel=candidate
spread_opts=
force_new_image=0
test_from_channel=0
show_help() {
echo "Usage: run-tests.sh [OPTIONS]"
echo
echo "optional arguments:"
echo " --help Show this help message and exit"
echo " --channel Select another channel to build the base image from (default: $channel)"
echo " --debug Enable verbose debugging output"
echo " --test-from-channel Pull snap from the specified channel instead of building it from source"
echo " --force-new-image Force generating a new image used for testing"
}
while [ -n "$1" ]; do
case "$1" in
--help)
show_help
exit
;;
--channel=*)
channel=${1#*=}
shift
;;
--test-from-channel)
test_from_channel=1
shift
;;
--debug)
spread_opts="$spread_opts -vv -debug"
shift
;;
--force-new-image)
force_new_image=1
shift
;;
*)
echo "Unknown command: $1"
exit 1
;;
esac
done
SPREAD_QEMU_PATH="$HOME/.spread/qemu"
if [ `which spread` = /snap/bin/spread ] ; then
current_version=`readlink /snap/spread/current`
SPREAD_QEMU_PATH="$HOME/snap/spread/$current_version/.spread/qemu/"
fi
# Make sure we have a base image we use for testing
if [ ! -e $SPREAD_QEMU_PATH/$image_name ] || [ $force_new_image -eq 1 ] ; then
echo "INFO: Creating new qemu test image ..."
(cd spread/image ; sudo ./create-image.sh $channel)
mkdir -p $SPREAD_QEMU_PATH
mv -f spread/image/ubuntu-core-16.img $SPREAD_QEMU_PATH/$image_name
fi
# We currently only run spread tests but we could do other things
# here as well like running our snap-lintian tool etc.
if [ $test_from_channel -eq 1 ] ; then
export SNAP_CHANNEL=$channel
fi
spread $spread_opts