]> git.ipfire.org Git - thirdparty/hostap.git/blame - tests/hwsim/vm/vm-run.sh
tests: Add wpa_supplicant WMM-AC test
[thirdparty/hostap.git] / tests / hwsim / vm / vm-run.sh
CommitLineData
970d3b09
JB
1#!/bin/bash
2
3cd "$(dirname $0)"
4
5if [ -z "$TESTDIR" ] ; then
6 TESTDIR=$(pwd)/../
7fi
8
3f33b3ad 9LOGS=/tmp/hwsim-test-logs
970d3b09
JB
10
11# increase the memory size if you want to run with valgrind, 512 MB works
12MEMORY=128
13
14# Some ubuntu systems (notably 12.04) have issues with this - since the guest
15# mounts as read-only it should be safe to not specify ,readonly. Override in
16# vm-config if needed (see below)
17ROTAG=,readonly
18
19# set this to ttyS0 to see kvm messages (if something doesn't work)
20KVMOUT=ttyS1
21
22# you can set EPATH if you need anything extra in $PATH inside the VM
23#EPATH=/some/dir
24
1cd3eae3
JB
25# extra KVM arguments, e.g., -s for gdbserver
26#KVMARGS=-s
27
4ecf11c5
JB
28# number of channels each hwsim device supports
29CHANNELS=1
30
970d3b09 31test -f vm-config && . vm-config
fd77e594 32test -f ~/.wpas-vm-config && . ~/.wpas-vm-config
970d3b09 33
1cd3eae3
JB
34if [ -z "$KERNEL" ] && [ -z "$KERNELDIR" ] ; then
35 echo "You need to set a KERNEL or KERNELDIR (in the environment or vm-config)"
970d3b09
JB
36 exit 2
37fi
1cd3eae3
JB
38if [ -z "$KERNEL" ] ; then
39 KERNEL=$KERNELDIR/arch/x86_64/boot/bzImage
40fi
970d3b09
JB
41
42
43CMD=$TESTDIR/vm/inside.sh
006a1c4d
IP
44
45unset RUN_TEST_ARGS
46DATE=$(date +%s)
47CODECOV=no
48TIMEWARP=0
49while [ "$1" != "" ]; do
50 case $1 in
51 --ext ) shift
52 DATE=$(date +%s).$1
53 shift
54 ;;
55 --codecov ) shift
56 CODECOV=yes
57 ;;
58 --timewrap ) shift
59 TIMEWARP=1
60 ;;
61 * )
62 RUN_TEST_ARGS="$RUN_TEST_ARGS$1 "
63 shift
64 ;;
65 esac
66done
67
3f33b3ad 68LOGDIR=$LOGS/$DATE
970d3b09
JB
69mkdir -p $LOGDIR
70
006a1c4d 71if [ $CODECOV = "yes" ]; then
3f33b3ad
JM
72 DIR=$PWD
73 if [ -e /tmp/logs ]; then
74 echo "/tmp/logs exists - cannot prepare build trees"
75 exit 1
76 fi
77 mkdir /tmp/logs
78 echo "Preparing separate build trees for hostapd/wpa_supplicant"
79 cd ../../..
80 git archive --format=tar --prefix=hostap/ HEAD > /tmp/logs/hostap.tar
81 cd $DIR
82 cat ../../../wpa_supplicant/.config > /tmp/logs/wpa_supplicant.config
83 echo "CONFIG_CODE_COVERAGE=y" >> /tmp/logs/wpa_supplicant.config
84 cat ../../../hostapd/.config > /tmp/logs/hostapd.config
85 echo "CONFIG_CODE_COVERAGE=y" >> /tmp/logs/hostapd.config
86
87 cd /tmp/logs
88 tar xf hostap.tar
89 mv hostap alt-wpa_supplicant
90 mv wpa_supplicant.config alt-wpa_supplicant/wpa_supplicant/.config
91 tar xf hostap.tar
92 mv hostap alt-hostapd
93 cp hostapd.config alt-hostapd/hostapd/.config
94 tar xf hostap.tar
95 mv hostap alt-hostapd-as
1cfb58d4
JM
96 cp hostapd.config alt-hostapd-as/hostapd/.config
97 tar xf hostap.tar
98 mv hostap alt-hlr_auc_gw
99 mv hostapd.config alt-hlr_auc_gw/hostapd/.config
3f33b3ad
JM
100 rm hostap.tar
101
102 cd /tmp/logs/alt-wpa_supplicant/wpa_supplicant
103 echo "Building wpa_supplicant"
104 make -j8 > /dev/null
105
106 cd /tmp/logs/alt-hostapd/hostapd
107 echo "Building hostapd"
108 make -j8 hostapd > /dev/null
109
110 cd /tmp/logs/alt-hostapd-as/hostapd
1cfb58d4
JM
111 echo "Building hostapd (AS)"
112 make -j8 hostapd > /dev/null
113
114 cd /tmp/logs/alt-hlr_auc_gw/hostapd
115 echo "Building hlr_auc_gw"
116 make -j8 hlr_auc_gw > /dev/null
3f33b3ad
JM
117
118 cd $DIR
119
120 mv /tmp/logs/alt-wpa_supplicant $LOGDIR
121 mv /tmp/logs/alt-hostapd $LOGDIR
122 mv /tmp/logs/alt-hostapd-as $LOGDIR
1cfb58d4 123 mv /tmp/logs/alt-hlr_auc_gw $LOGDIR
3f33b3ad
JM
124else
125 CODECOV=no
126fi
127
128echo "Starting test run in a virtual machine"
129
f4bfa2d2 130kvm \
970d3b09 131 -kernel $KERNEL -smp 4 \
1cd3eae3 132 $KVMARGS -m $MEMORY -nographic \
970d3b09
JB
133 -fsdev local,security_model=none,id=fsdev-root,path=/$ROTAG \
134 -device virtio-9p-pci,id=fs-root,fsdev=fsdev-root,mount_tag=/dev/root \
135 -fsdev local,security_model=none,id=fsdev-logs,path="$LOGDIR",writeout=immediate \
136 -device virtio-9p-pci,id=fs-logs,fsdev=fsdev-logs,mount_tag=logshare \
137 -monitor null -serial stdio -serial file:$LOGDIR/console \
006a1c4d 138 -append "mac80211_hwsim.support_p2p_device=0 mac80211_hwsim.channels=$CHANNELS mac80211_hwsim.radios=6 init=$CMD testdir=$TESTDIR timewarp=$TIMEWARP console=$KVMOUT root=/dev/root rootflags=trans=virtio,version=9p2000.u ro rootfstype=9p EPATH=$EPATH ARGS=$RUN_TEST_ARGS"
f4bfa2d2 139
3f33b3ad
JM
140if [ $CODECOV = "yes" ]; then
141 mv $LOGDIR/alt-wpa_supplicant /tmp/logs
142 mv $LOGDIR/alt-hostapd /tmp/logs
143 mv $LOGDIR/alt-hostapd-as /tmp/logs
1cfb58d4 144 mv $LOGDIR/alt-hlr_auc_gw /tmp/logs
3f33b3ad
JM
145
146 echo "Generating code coverage report for wpa_supplicant"
147 cd /tmp/logs/alt-wpa_supplicant/wpa_supplicant
148 lcov -c -d .. > lcov.info 2> lcov.log
149 genhtml -t "wpa_supplicant hwsim test run $DATE" lcov.info --output-directory $LOGDIR/lcov-wpa_supplicant >> lcov.log 2>&1
150 mv lcov.info lcov.log $LOGDIR/lcov-wpa_supplicant
151
152 echo "Generating code coverage report for hostapd"
153 cd /tmp/logs/alt-hostapd/hostapd
154 lcov -c -d .. > lcov.info 2> lcov.log
155 genhtml -t "hostapd hwsim test run $DATE" lcov.info --output-directory $LOGDIR/lcov-hostapd >> lcov.log 2>&1
156 mv lcov.info lcov.log $LOGDIR/lcov-hostapd
157
1cfb58d4 158 echo "Generating code coverage report for hostapd (AS)"
3f33b3ad
JM
159 cd /tmp/logs/alt-hostapd-as/hostapd
160 lcov -c -d .. > lcov.info 2> lcov.log
1cfb58d4 161 genhtml -t "hostapd (AS) hwsim test run $DATE" lcov.info --output-directory $LOGDIR/lcov-hostapd-as >> lcov.log 2>&1
3f33b3ad
JM
162 mv lcov.info lcov.log $LOGDIR/lcov-hostapd-as
163
1cfb58d4
JM
164 echo "Generating code coverage report for hlr_auc_gw"
165 cd /tmp/logs/alt-hlr_auc_gw/hostapd
166 lcov -c -d .. > lcov.info 2> lcov.log
167 genhtml -t "hlr_auc_gw hwsim test run $DATE" lcov.info --output-directory $LOGDIR/lcov-hlr_auc_gw >> lcov.log 2>&1
168 mv lcov.info lcov.log $LOGDIR/lcov-hlr_auc_gw
169
4472aafb
JM
170 echo "Generating combined code coverage report"
171 mkdir $LOGDIR/lcov-combined
1cfb58d4 172 for i in wpa_supplicant hostapd hostapd-as hlr_auc_gw; do
4472aafb
JM
173 sed s%SF:/tmp/logs/alt-[^/]*/%SF:/tmp/logs/alt-wpa_supplicant/% < $LOGDIR/lcov-$i/lcov.info > $LOGDIR/lcov-combined/$i.info
174 done
175 cd $LOGDIR/lcov-combined
1cfb58d4 176 lcov -a wpa_supplicant.info -a hostapd.info -a hostapd-as.info -a hlr_auc_gw.info -o combined.info > lcov.log 2>&1
4472aafb
JM
177 genhtml -t "wpa_supplicant/hostapd combined for hwsim test run $DATE" combined.info --output-directory . >> lcov.log 2>&1
178
3f33b3ad
JM
179 cd $DIR
180 rm -r /tmp/logs/alt-wpa_supplicant
181 rm -r /tmp/logs/alt-hostapd
182 rm -r /tmp/logs/alt-hostapd-as
1cfb58d4 183 rm -r /tmp/logs/alt-hlr_auc_gw
3f33b3ad
JM
184 rmdir /tmp/logs
185fi
f4bfa2d2 186
3f33b3ad
JM
187echo
188echo "Test run completed"
189echo "Logfiles are at $LOGDIR"
190if [ $CODECOV = "yes" ]; then
191 echo "Code coverage reports:"
192 echo "wpa_supplicant: file://$LOGDIR/lcov-wpa_supplicant/index.html"
193 echo "hostapd: file://$LOGDIR/lcov-hostapd/index.html"
1cfb58d4
JM
194 echo "hostapd (AS): file://$LOGDIR/lcov-hostapd-as/index.html"
195 echo "hlr_auc_gw: file://$LOGDIR/lcov-hlr_auc_gw/index.html"
4472aafb 196 echo "combined: file://$LOGDIR/lcov-combined/index.html"
f4bfa2d2 197fi