]>
Commit | Line | Data |
---|---|---|
970d3b09 JB |
1 | #!/bin/bash |
2 | ||
3 | cd "$(dirname $0)" | |
4 | ||
5 | if [ -z "$TESTDIR" ] ; then | |
6 | TESTDIR=$(pwd)/../ | |
7 | fi | |
8 | ||
680ce356 JB |
9 | if [ -n "$HWSIM_TEST_LOG_DIR" ] ; then |
10 | LOGS="$HWSIM_TEST_LOG_DIR" | |
11 | else | |
12 | LOGS=/tmp/hwsim-test-logs | |
13 | fi | |
970d3b09 JB |
14 | |
15 | # increase the memory size if you want to run with valgrind, 512 MB works | |
255f3846 | 16 | MEMORY=256 |
970d3b09 JB |
17 | |
18 | # Some ubuntu systems (notably 12.04) have issues with this - since the guest | |
19 | # mounts as read-only it should be safe to not specify ,readonly. Override in | |
20 | # vm-config if needed (see below) | |
21 | ROTAG=,readonly | |
22 | ||
23 | # set this to ttyS0 to see kvm messages (if something doesn't work) | |
24 | KVMOUT=ttyS1 | |
25 | ||
26 | # you can set EPATH if you need anything extra in $PATH inside the VM | |
27 | #EPATH=/some/dir | |
28 | ||
1cd3eae3 JB |
29 | # extra KVM arguments, e.g., -s for gdbserver |
30 | #KVMARGS=-s | |
31 | ||
4ecf11c5 JB |
32 | # number of channels each hwsim device supports |
33 | CHANNELS=1 | |
34 | ||
970d3b09 | 35 | test -f vm-config && . vm-config |
fd77e594 | 36 | test -f ~/.wpas-vm-config && . ~/.wpas-vm-config |
970d3b09 | 37 | |
1cd3eae3 JB |
38 | if [ -z "$KERNEL" ] && [ -z "$KERNELDIR" ] ; then |
39 | echo "You need to set a KERNEL or KERNELDIR (in the environment or vm-config)" | |
970d3b09 JB |
40 | exit 2 |
41 | fi | |
1cd3eae3 | 42 | if [ -z "$KERNEL" ] ; then |
1cefd89b JM |
43 | if [ -e $KERNELDIR/arch/x86_64/boot/bzImage ]; then |
44 | KERNEL=$KERNELDIR/arch/x86_64/boot/bzImage | |
45 | elif [ -e $KERNELDIR/linux ]; then | |
46 | KERNEL=$KERNELDIR/linux | |
47 | else | |
48 | echo "No suitable kernel image found from KERNELDIR" | |
49 | exit 2 | |
50 | fi | |
51 | fi | |
52 | if [ ! -e $KERNEL ]; then | |
53 | echo "Kernel image not found: $KERNEL" | |
54 | exit 2 | |
1cd3eae3 | 55 | fi |
970d3b09 JB |
56 | |
57 | ||
58 | CMD=$TESTDIR/vm/inside.sh | |
006a1c4d IP |
59 | |
60 | unset RUN_TEST_ARGS | |
7e694225 JM |
61 | TIMESTAMP=$(date +%s) |
62 | DATE=$TIMESTAMP | |
006a1c4d IP |
63 | CODECOV=no |
64 | TIMEWARP=0 | |
e3395110 JB |
65 | TELNET_QEMU= |
66 | TELNET_ARG=0 | |
5554fbef | 67 | DELAY=0 |
e0cccf26 | 68 | CODECOV_DIR= |
006a1c4d IP |
69 | while [ "$1" != "" ]; do |
70 | case $1 in | |
7e694225 JM |
71 | --timestamp ) shift |
72 | TIMESTAMP=$1 | |
73 | shift | |
74 | ;; | |
006a1c4d | 75 | --ext ) shift |
7e694225 | 76 | DATE=$TIMESTAMP.$1 |
006a1c4d IP |
77 | shift |
78 | ;; | |
79 | --codecov ) shift | |
80 | CODECOV=yes | |
81 | ;; | |
e0cccf26 JM |
82 | --codecov_dir ) shift |
83 | CODECOV_DIR=$1 | |
84 | shift | |
85 | ;; | |
006a1c4d IP |
86 | --timewrap ) shift |
87 | TIMEWARP=1 | |
88 | ;; | |
e3395110 JB |
89 | --telnet ) shift |
90 | TELNET_ARG=1 | |
91 | TELNET_QEMU="-net nic,model=virtio -net user,id=telnet,restrict=on,net=172.16.0.0/24,hostfwd=tcp:127.0.0.1:$1-:23" | |
92 | shift | |
93 | ;; | |
5554fbef JM |
94 | --delay ) shift |
95 | DELAY=$1 | |
96 | shift | |
97 | ;; | |
006a1c4d IP |
98 | * ) |
99 | RUN_TEST_ARGS="$RUN_TEST_ARGS$1 " | |
100 | shift | |
101 | ;; | |
102 | esac | |
103 | done | |
104 | ||
3f33b3ad | 105 | LOGDIR=$LOGS/$DATE |
970d3b09 | 106 | mkdir -p $LOGDIR |
8bdefe51 JB |
107 | rm -f $LOGS/latest |
108 | ln -s $LOGDIR $LOGS/latest | |
970d3b09 | 109 | |
e0cccf26 JM |
110 | if [ -n "$CODECOV_DIR" ]; then |
111 | cp -a $CODECOV_DIR/alt-wpa_supplicant $LOGDIR | |
112 | cp -a $CODECOV_DIR/alt-hostapd $LOGDIR | |
113 | cp -a $CODECOV_DIR/alt-hostapd-as $LOGDIR | |
114 | cp -a $CODECOV_DIR/alt-hlr_auc_gw $LOGDIR | |
115 | elif [ $CODECOV = "yes" ]; then | |
116 | ./build-codecov.sh $LOGDIR || exit 1 | |
3f33b3ad JM |
117 | else |
118 | CODECOV=no | |
119 | fi | |
120 | ||
5554fbef JM |
121 | if [ $DELAY -gt 0 ]; then |
122 | echo "Wait $DELAY seconds before starting VM" | |
123 | sleep $DELAY | |
124 | fi | |
125 | ||
3f33b3ad JM |
126 | echo "Starting test run in a virtual machine" |
127 | ||
1cefd89b JM |
128 | if [ -x $KERNEL ]; then |
129 | unset KVM | |
130 | else | |
131 | KVM=kvm | |
132 | for kvmprog in kvm qemu-kvm; do | |
133 | if $kvmprog --version &> /dev/null; then | |
134 | KVM=$kvmprog | |
135 | break | |
136 | fi | |
137 | done | |
138 | fi | |
d7273180 | 139 | |
23fcfd60 JB |
140 | argsfile=$(mktemp) |
141 | if [ $? -ne 0 ] ; then | |
142 | exit 2 | |
143 | fi | |
144 | function finish { | |
145 | rm -f $argsfile | |
146 | } | |
147 | trap finish EXIT | |
148 | ||
149 | echo "$RUN_TEST_ARGS" > $argsfile | |
150 | ||
1cefd89b JM |
151 | A="mac80211_hwsim.support_p2p_device=0 " |
152 | A+="mac80211_hwsim.channels=$CHANNELS " | |
153 | A+="mac80211_hwsim.radios=7 " | |
154 | A+="cfg80211.dyndbg=+p " | |
155 | A+="mac80211.dyndbg=+p " | |
156 | A+="mac80211_hwsim.dyndbg=+p " | |
157 | A+="init=$CMD " | |
158 | A+="testdir=$TESTDIR " | |
159 | A+="timewarp=$TIMEWARP " | |
160 | A+="TELNET=$TELNET_ARG " | |
161 | A+="EPATH=$EPATH " | |
162 | A+="ARGS=$argsfile " | |
163 | A+="console=$KVMOUT " | |
164 | A+="ro" | |
165 | ||
166 | if [ -z $KVM ]; then | |
167 | $KERNEL \ | |
168 | mem=${MEMORY}M \ | |
169 | LOGDIR=$LOGDIR \ | |
d55035c9 | 170 | time-travel=inf-cpu \ |
1cefd89b JM |
171 | $A \ |
172 | root=none hostfs=/ rootfstype=hostfs rootflags=/ \ | |
173 | ssl0=fd:0,fd:1 \ | |
174 | ssl1=fd:100 \ | |
2080f4c7 | 175 | ssl-non-raw \ |
1cefd89b JM |
176 | 100<>$LOGDIR/console 2>&1 | \ |
177 | sed -u '0,/VM has started up/d' | |
178 | else | |
179 | $KVM \ | |
180 | -kernel $KERNEL \ | |
181 | -smp 4 \ | |
182 | $KVMARGS \ | |
183 | -m $MEMORY \ | |
184 | -nographic \ | |
185 | -fsdev local,security_model=none,id=fsdev-root,path=/$ROTAG \ | |
186 | -device virtio-9p-pci,id=fs-root,fsdev=fsdev-root,mount_tag=/dev/root \ | |
187 | -fsdev local,security_model=none,id=fsdev-logs,path="$LOGDIR",writeout=immediate \ | |
188 | -device virtio-9p-pci,id=fs-logs,fsdev=fsdev-logs,mount_tag=logshare \ | |
189 | -monitor null \ | |
190 | -serial stdio \ | |
191 | -serial file:$LOGDIR/console \ | |
192 | $TELNET_QEMU \ | |
193 | -append "$A root=/dev/root rootflags=trans=virtio,version=9p2000.u rootfstype=9p" | \ | |
194 | sed -u '0,/VM has started up/d' | |
195 | fi | |
f4bfa2d2 | 196 | |
3f33b3ad | 197 | if [ $CODECOV = "yes" ]; then |
f24489d9 JM |
198 | echo "Preparing code coverage reports" |
199 | ./process-codecov.sh $LOGDIR "" restore | |
200 | ./combine-codecov.sh $LOGDIR lcov | |
3f33b3ad | 201 | fi |
f4bfa2d2 | 202 | |
3f33b3ad JM |
203 | echo |
204 | echo "Test run completed" | |
8bdefe51 | 205 | echo "Logfiles are at $LOGDIR ($LOGS/latest)" |
3f33b3ad | 206 | if [ $CODECOV = "yes" ]; then |
f24489d9 JM |
207 | echo "Code coverage report:" |
208 | echo "file://$LOGDIR/lcov/index.html" | |
f4bfa2d2 | 209 | fi |