]> git.ipfire.org Git - thirdparty/hostap.git/blame - tests/hwsim/vm/vm-run.sh
tests: Add a simple wmediumd 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
8412dd52 12MEMORY=192
970d3b09
JB
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
7e694225
JM
46TIMESTAMP=$(date +%s)
47DATE=$TIMESTAMP
006a1c4d
IP
48CODECOV=no
49TIMEWARP=0
5554fbef 50DELAY=0
e0cccf26 51CODECOV_DIR=
006a1c4d
IP
52while [ "$1" != "" ]; do
53 case $1 in
7e694225
JM
54 --timestamp ) shift
55 TIMESTAMP=$1
56 shift
57 ;;
006a1c4d 58 --ext ) shift
7e694225 59 DATE=$TIMESTAMP.$1
006a1c4d
IP
60 shift
61 ;;
62 --codecov ) shift
63 CODECOV=yes
64 ;;
e0cccf26
JM
65 --codecov_dir ) shift
66 CODECOV_DIR=$1
67 shift
68 ;;
006a1c4d
IP
69 --timewrap ) shift
70 TIMEWARP=1
71 ;;
5554fbef
JM
72 --delay ) shift
73 DELAY=$1
74 shift
75 ;;
006a1c4d
IP
76 * )
77 RUN_TEST_ARGS="$RUN_TEST_ARGS$1 "
78 shift
79 ;;
80 esac
81done
82
3f33b3ad 83LOGDIR=$LOGS/$DATE
970d3b09
JB
84mkdir -p $LOGDIR
85
e0cccf26
JM
86if [ -n "$CODECOV_DIR" ]; then
87 cp -a $CODECOV_DIR/alt-wpa_supplicant $LOGDIR
88 cp -a $CODECOV_DIR/alt-hostapd $LOGDIR
89 cp -a $CODECOV_DIR/alt-hostapd-as $LOGDIR
90 cp -a $CODECOV_DIR/alt-hlr_auc_gw $LOGDIR
91elif [ $CODECOV = "yes" ]; then
92 ./build-codecov.sh $LOGDIR || exit 1
3f33b3ad
JM
93else
94 CODECOV=no
95fi
96
5554fbef
JM
97if [ $DELAY -gt 0 ]; then
98 echo "Wait $DELAY seconds before starting VM"
99 sleep $DELAY
100fi
101
3f33b3ad
JM
102echo "Starting test run in a virtual machine"
103
d7273180
DW
104KVM=kvm
105for kvmprog in kvm qemu-kvm; do
106 if $kvmprog --version &> /dev/null; then
107 KVM=$kvmprog
108 break
109 fi
110done
111
112$KVM \
970d3b09 113 -kernel $KERNEL -smp 4 \
1cd3eae3 114 $KVMARGS -m $MEMORY -nographic \
970d3b09
JB
115 -fsdev local,security_model=none,id=fsdev-root,path=/$ROTAG \
116 -device virtio-9p-pci,id=fs-root,fsdev=fsdev-root,mount_tag=/dev/root \
117 -fsdev local,security_model=none,id=fsdev-logs,path="$LOGDIR",writeout=immediate \
118 -device virtio-9p-pci,id=fs-logs,fsdev=fsdev-logs,mount_tag=logshare \
119 -monitor null -serial stdio -serial file:$LOGDIR/console \
41a256ec 120 -append "mac80211_hwsim.support_p2p_device=0 mac80211_hwsim.channels=$CHANNELS mac80211_hwsim.radios=7 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 121
3f33b3ad 122if [ $CODECOV = "yes" ]; then
f24489d9
JM
123 echo "Preparing code coverage reports"
124 ./process-codecov.sh $LOGDIR "" restore
125 ./combine-codecov.sh $LOGDIR lcov
3f33b3ad 126fi
f4bfa2d2 127
3f33b3ad
JM
128echo
129echo "Test run completed"
130echo "Logfiles are at $LOGDIR"
131if [ $CODECOV = "yes" ]; then
f24489d9
JM
132 echo "Code coverage report:"
133 echo "file://$LOGDIR/lcov/index.html"
f4bfa2d2 134fi