]> git.ipfire.org Git - thirdparty/hostap.git/blame - tests/hwsim/vm/vm-run.sh
tests: Suppress annoying console reset from VMs
[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
5554fbef 54DELAY=0
e0cccf26 55CODECOV_DIR=
006a1c4d
IP
56while [ "$1" != "" ]; do
57 case $1 in
7e694225
JM
58 --timestamp ) shift
59 TIMESTAMP=$1
60 shift
61 ;;
006a1c4d 62 --ext ) shift
7e694225 63 DATE=$TIMESTAMP.$1
006a1c4d
IP
64 shift
65 ;;
66 --codecov ) shift
67 CODECOV=yes
68 ;;
e0cccf26
JM
69 --codecov_dir ) shift
70 CODECOV_DIR=$1
71 shift
72 ;;
006a1c4d
IP
73 --timewrap ) shift
74 TIMEWARP=1
75 ;;
5554fbef
JM
76 --delay ) shift
77 DELAY=$1
78 shift
79 ;;
006a1c4d
IP
80 * )
81 RUN_TEST_ARGS="$RUN_TEST_ARGS$1 "
82 shift
83 ;;
84 esac
85done
86
3f33b3ad 87LOGDIR=$LOGS/$DATE
970d3b09 88mkdir -p $LOGDIR
8bdefe51
JB
89rm -f $LOGS/latest
90ln -s $LOGDIR $LOGS/latest
970d3b09 91
e0cccf26
JM
92if [ -n "$CODECOV_DIR" ]; then
93 cp -a $CODECOV_DIR/alt-wpa_supplicant $LOGDIR
94 cp -a $CODECOV_DIR/alt-hostapd $LOGDIR
95 cp -a $CODECOV_DIR/alt-hostapd-as $LOGDIR
96 cp -a $CODECOV_DIR/alt-hlr_auc_gw $LOGDIR
97elif [ $CODECOV = "yes" ]; then
98 ./build-codecov.sh $LOGDIR || exit 1
3f33b3ad
JM
99else
100 CODECOV=no
101fi
102
5554fbef
JM
103if [ $DELAY -gt 0 ]; then
104 echo "Wait $DELAY seconds before starting VM"
105 sleep $DELAY
106fi
107
3f33b3ad
JM
108echo "Starting test run in a virtual machine"
109
d7273180
DW
110KVM=kvm
111for kvmprog in kvm qemu-kvm; do
112 if $kvmprog --version &> /dev/null; then
113 KVM=$kvmprog
114 break
115 fi
116done
117
23fcfd60
JB
118argsfile=$(mktemp)
119if [ $? -ne 0 ] ; then
120 exit 2
121fi
122function finish {
123 rm -f $argsfile
124}
125trap finish EXIT
126
127echo "$RUN_TEST_ARGS" > $argsfile
128
d7273180 129$KVM \
970d3b09 130 -kernel $KERNEL -smp 4 \
1cd3eae3 131 $KVMARGS -m $MEMORY -nographic \
970d3b09
JB
132 -fsdev local,security_model=none,id=fsdev-root,path=/$ROTAG \
133 -device virtio-9p-pci,id=fs-root,fsdev=fsdev-root,mount_tag=/dev/root \
134 -fsdev local,security_model=none,id=fsdev-logs,path="$LOGDIR",writeout=immediate \
135 -device virtio-9p-pci,id=fs-logs,fsdev=fsdev-logs,mount_tag=logshare \
136 -monitor null -serial stdio -serial file:$LOGDIR/console \
b0797ec9
JB
137 -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 console=$KVMOUT root=/dev/root rootflags=trans=virtio,version=9p2000.u ro rootfstype=9p EPATH=$EPATH ARGS=$argsfile" | \
138 sed -u '0,/VM has started up/d'
f4bfa2d2 139
3f33b3ad 140if [ $CODECOV = "yes" ]; then
f24489d9
JM
141 echo "Preparing code coverage reports"
142 ./process-codecov.sh $LOGDIR "" restore
143 ./combine-codecov.sh $LOGDIR lcov
3f33b3ad 144fi
f4bfa2d2 145
3f33b3ad
JM
146echo
147echo "Test run completed"
8bdefe51 148echo "Logfiles are at $LOGDIR ($LOGS/latest)"
3f33b3ad 149if [ $CODECOV = "yes" ]; then
f24489d9
JM
150 echo "Code coverage report:"
151 echo "file://$LOGDIR/lcov/index.html"
f4bfa2d2 152fi