]> git.ipfire.org Git - thirdparty/hostap.git/blame - tests/hwsim/vm/vm-run.sh
tests: sigma_dut and TLS server certificate constraints
[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
680ce356
JB
9if [ -n "$HWSIM_TEST_LOG_DIR" ] ; then
10 LOGS="$HWSIM_TEST_LOG_DIR"
11else
12 LOGS=/tmp/hwsim-test-logs
13fi
970d3b09
JB
14
15# increase the memory size if you want to run with valgrind, 512 MB works
255f3846 16MEMORY=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)
21ROTAG=,readonly
22
23# set this to ttyS0 to see kvm messages (if something doesn't work)
24KVMOUT=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
33CHANNELS=1
34
970d3b09 35test -f vm-config && . vm-config
fd77e594 36test -f ~/.wpas-vm-config && . ~/.wpas-vm-config
970d3b09 37
1cd3eae3
JB
38if [ -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
41fi
1cd3eae3
JB
42if [ -z "$KERNEL" ] ; then
43 KERNEL=$KERNELDIR/arch/x86_64/boot/bzImage
44fi
970d3b09
JB
45
46
47CMD=$TESTDIR/vm/inside.sh
006a1c4d
IP
48
49unset RUN_TEST_ARGS
7e694225
JM
50TIMESTAMP=$(date +%s)
51DATE=$TIMESTAMP
006a1c4d
IP
52CODECOV=no
53TIMEWARP=0
e3395110
JB
54TELNET_QEMU=
55TELNET_ARG=0
5554fbef 56DELAY=0
e0cccf26 57CODECOV_DIR=
006a1c4d
IP
58while [ "$1" != "" ]; do
59 case $1 in
7e694225
JM
60 --timestamp ) shift
61 TIMESTAMP=$1
62 shift
63 ;;
006a1c4d 64 --ext ) shift
7e694225 65 DATE=$TIMESTAMP.$1
006a1c4d
IP
66 shift
67 ;;
68 --codecov ) shift
69 CODECOV=yes
70 ;;
e0cccf26
JM
71 --codecov_dir ) shift
72 CODECOV_DIR=$1
73 shift
74 ;;
006a1c4d
IP
75 --timewrap ) shift
76 TIMEWARP=1
77 ;;
e3395110
JB
78 --telnet ) shift
79 TELNET_ARG=1
80 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"
81 shift
82 ;;
5554fbef
JM
83 --delay ) shift
84 DELAY=$1
85 shift
86 ;;
006a1c4d
IP
87 * )
88 RUN_TEST_ARGS="$RUN_TEST_ARGS$1 "
89 shift
90 ;;
91 esac
92done
93
3f33b3ad 94LOGDIR=$LOGS/$DATE
970d3b09 95mkdir -p $LOGDIR
8bdefe51
JB
96rm -f $LOGS/latest
97ln -s $LOGDIR $LOGS/latest
970d3b09 98
e0cccf26
JM
99if [ -n "$CODECOV_DIR" ]; then
100 cp -a $CODECOV_DIR/alt-wpa_supplicant $LOGDIR
101 cp -a $CODECOV_DIR/alt-hostapd $LOGDIR
102 cp -a $CODECOV_DIR/alt-hostapd-as $LOGDIR
103 cp -a $CODECOV_DIR/alt-hlr_auc_gw $LOGDIR
104elif [ $CODECOV = "yes" ]; then
105 ./build-codecov.sh $LOGDIR || exit 1
3f33b3ad
JM
106else
107 CODECOV=no
108fi
109
5554fbef
JM
110if [ $DELAY -gt 0 ]; then
111 echo "Wait $DELAY seconds before starting VM"
112 sleep $DELAY
113fi
114
3f33b3ad
JM
115echo "Starting test run in a virtual machine"
116
d7273180
DW
117KVM=kvm
118for kvmprog in kvm qemu-kvm; do
119 if $kvmprog --version &> /dev/null; then
120 KVM=$kvmprog
121 break
122 fi
123done
124
23fcfd60
JB
125argsfile=$(mktemp)
126if [ $? -ne 0 ] ; then
127 exit 2
128fi
129function finish {
130 rm -f $argsfile
131}
132trap finish EXIT
133
134echo "$RUN_TEST_ARGS" > $argsfile
135
d7273180 136$KVM \
970d3b09 137 -kernel $KERNEL -smp 4 \
1cd3eae3 138 $KVMARGS -m $MEMORY -nographic \
970d3b09
JB
139 -fsdev local,security_model=none,id=fsdev-root,path=/$ROTAG \
140 -device virtio-9p-pci,id=fs-root,fsdev=fsdev-root,mount_tag=/dev/root \
141 -fsdev local,security_model=none,id=fsdev-logs,path="$LOGDIR",writeout=immediate \
142 -device virtio-9p-pci,id=fs-logs,fsdev=fsdev-logs,mount_tag=logshare \
143 -monitor null -serial stdio -serial file:$LOGDIR/console \
e3395110
JB
144 $TELNET_QEMU \
145 -append "mac80211_hwsim.support_p2p_device=0 mac80211_hwsim.channels=$CHANNELS mac80211_hwsim.radios=7 cfg80211.dyndbg=+p mac80211.dyndbg=+p mac80211_hwsim.dyndbg=+p init=$CMD testdir=$TESTDIR timewarp=$TIMEWARP TELNET=$TELNET_ARG console=$KVMOUT root=/dev/root rootflags=trans=virtio,version=9p2000.u ro rootfstype=9p EPATH=$EPATH ARGS=$argsfile" | \
b0797ec9 146 sed -u '0,/VM has started up/d'
f4bfa2d2 147
3f33b3ad 148if [ $CODECOV = "yes" ]; then
f24489d9
JM
149 echo "Preparing code coverage reports"
150 ./process-codecov.sh $LOGDIR "" restore
151 ./combine-codecov.sh $LOGDIR lcov
3f33b3ad 152fi
f4bfa2d2 153
3f33b3ad
JM
154echo
155echo "Test run completed"
8bdefe51 156echo "Logfiles are at $LOGDIR ($LOGS/latest)"
3f33b3ad 157if [ $CODECOV = "yes" ]; then
f24489d9
JM
158 echo "Code coverage report:"
159 echo "file://$LOGDIR/lcov/index.html"
f4bfa2d2 160fi