]>
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 JB |
42 | if [ -z "$KERNEL" ] ; then |
43 | KERNEL=$KERNELDIR/arch/x86_64/boot/bzImage | |
44 | fi | |
970d3b09 JB |
45 | |
46 | ||
47 | CMD=$TESTDIR/vm/inside.sh | |
006a1c4d IP |
48 | |
49 | unset RUN_TEST_ARGS | |
7e694225 JM |
50 | TIMESTAMP=$(date +%s) |
51 | DATE=$TIMESTAMP | |
006a1c4d IP |
52 | CODECOV=no |
53 | TIMEWARP=0 | |
5554fbef | 54 | DELAY=0 |
e0cccf26 | 55 | CODECOV_DIR= |
006a1c4d IP |
56 | while [ "$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 | |
85 | done | |
86 | ||
3f33b3ad | 87 | LOGDIR=$LOGS/$DATE |
970d3b09 | 88 | mkdir -p $LOGDIR |
8bdefe51 JB |
89 | rm -f $LOGS/latest |
90 | ln -s $LOGDIR $LOGS/latest | |
970d3b09 | 91 | |
e0cccf26 JM |
92 | if [ -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 | |
97 | elif [ $CODECOV = "yes" ]; then | |
98 | ./build-codecov.sh $LOGDIR || exit 1 | |
3f33b3ad JM |
99 | else |
100 | CODECOV=no | |
101 | fi | |
102 | ||
5554fbef JM |
103 | if [ $DELAY -gt 0 ]; then |
104 | echo "Wait $DELAY seconds before starting VM" | |
105 | sleep $DELAY | |
106 | fi | |
107 | ||
3f33b3ad JM |
108 | echo "Starting test run in a virtual machine" |
109 | ||
d7273180 DW |
110 | KVM=kvm |
111 | for kvmprog in kvm qemu-kvm; do | |
112 | if $kvmprog --version &> /dev/null; then | |
113 | KVM=$kvmprog | |
114 | break | |
115 | fi | |
116 | done | |
117 | ||
23fcfd60 JB |
118 | argsfile=$(mktemp) |
119 | if [ $? -ne 0 ] ; then | |
120 | exit 2 | |
121 | fi | |
122 | function finish { | |
123 | rm -f $argsfile | |
124 | } | |
125 | trap finish EXIT | |
126 | ||
127 | echo "$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 | 140 | if [ $CODECOV = "yes" ]; then |
f24489d9 JM |
141 | echo "Preparing code coverage reports" |
142 | ./process-codecov.sh $LOGDIR "" restore | |
143 | ./combine-codecov.sh $LOGDIR lcov | |
3f33b3ad | 144 | fi |
f4bfa2d2 | 145 | |
3f33b3ad JM |
146 | echo |
147 | echo "Test run completed" | |
8bdefe51 | 148 | echo "Logfiles are at $LOGDIR ($LOGS/latest)" |
3f33b3ad | 149 | if [ $CODECOV = "yes" ]; then |
f24489d9 JM |
150 | echo "Code coverage report:" |
151 | echo "file://$LOGDIR/lcov/index.html" | |
f4bfa2d2 | 152 | fi |