]>
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 | ||
3f33b3ad | 9 | LOGS=/tmp/hwsim-test-logs |
970d3b09 JB |
10 | |
11 | # increase the memory size if you want to run with valgrind, 512 MB works | |
8412dd52 | 12 | MEMORY=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) | |
17 | ROTAG=,readonly | |
18 | ||
19 | # set this to ttyS0 to see kvm messages (if something doesn't work) | |
20 | KVMOUT=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 |
29 | CHANNELS=1 | |
30 | ||
970d3b09 | 31 | test -f vm-config && . vm-config |
fd77e594 | 32 | test -f ~/.wpas-vm-config && . ~/.wpas-vm-config |
970d3b09 | 33 | |
1cd3eae3 JB |
34 | if [ -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 |
37 | fi | |
1cd3eae3 JB |
38 | if [ -z "$KERNEL" ] ; then |
39 | KERNEL=$KERNELDIR/arch/x86_64/boot/bzImage | |
40 | fi | |
970d3b09 JB |
41 | |
42 | ||
43 | CMD=$TESTDIR/vm/inside.sh | |
006a1c4d IP |
44 | |
45 | unset RUN_TEST_ARGS | |
7e694225 JM |
46 | TIMESTAMP=$(date +%s) |
47 | DATE=$TIMESTAMP | |
006a1c4d IP |
48 | CODECOV=no |
49 | TIMEWARP=0 | |
5554fbef | 50 | DELAY=0 |
e0cccf26 | 51 | CODECOV_DIR= |
006a1c4d IP |
52 | while [ "$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 | |
81 | done | |
82 | ||
3f33b3ad | 83 | LOGDIR=$LOGS/$DATE |
970d3b09 JB |
84 | mkdir -p $LOGDIR |
85 | ||
e0cccf26 JM |
86 | if [ -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 | |
91 | elif [ $CODECOV = "yes" ]; then | |
92 | ./build-codecov.sh $LOGDIR || exit 1 | |
3f33b3ad JM |
93 | else |
94 | CODECOV=no | |
95 | fi | |
96 | ||
5554fbef JM |
97 | if [ $DELAY -gt 0 ]; then |
98 | echo "Wait $DELAY seconds before starting VM" | |
99 | sleep $DELAY | |
100 | fi | |
101 | ||
3f33b3ad JM |
102 | echo "Starting test run in a virtual machine" |
103 | ||
d7273180 DW |
104 | KVM=kvm |
105 | for kvmprog in kvm qemu-kvm; do | |
106 | if $kvmprog --version &> /dev/null; then | |
107 | KVM=$kvmprog | |
108 | break | |
109 | fi | |
110 | done | |
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 | 122 | if [ $CODECOV = "yes" ]; then |
f24489d9 JM |
123 | echo "Preparing code coverage reports" |
124 | ./process-codecov.sh $LOGDIR "" restore | |
125 | ./combine-codecov.sh $LOGDIR lcov | |
3f33b3ad | 126 | fi |
f4bfa2d2 | 127 | |
3f33b3ad JM |
128 | echo |
129 | echo "Test run completed" | |
130 | echo "Logfiles are at $LOGDIR" | |
131 | if [ $CODECOV = "yes" ]; then | |
f24489d9 JM |
132 | echo "Code coverage report:" |
133 | echo "file://$LOGDIR/lcov/index.html" | |
f4bfa2d2 | 134 | fi |