2013-10-31 00:23:57 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
cd "$(dirname $0)"
|
|
|
|
|
|
|
|
if [ -z "$TESTDIR" ] ; then
|
|
|
|
TESTDIR=$(pwd)/../
|
|
|
|
fi
|
|
|
|
|
2015-11-24 17:39:58 +01:00
|
|
|
if [ -n "$HWSIM_TEST_LOG_DIR" ] ; then
|
|
|
|
LOGS="$HWSIM_TEST_LOG_DIR"
|
|
|
|
else
|
|
|
|
LOGS=/tmp/hwsim-test-logs
|
|
|
|
fi
|
2013-10-31 00:23:57 +01:00
|
|
|
|
|
|
|
# increase the memory size if you want to run with valgrind, 512 MB works
|
2019-01-24 08:45:54 +01:00
|
|
|
MEMORY=256
|
2013-10-31 00:23:57 +01:00
|
|
|
|
|
|
|
# Some ubuntu systems (notably 12.04) have issues with this - since the guest
|
|
|
|
# mounts as read-only it should be safe to not specify ,readonly. Override in
|
|
|
|
# vm-config if needed (see below)
|
|
|
|
ROTAG=,readonly
|
|
|
|
|
|
|
|
# set this to ttyS0 to see kvm messages (if something doesn't work)
|
|
|
|
KVMOUT=ttyS1
|
|
|
|
|
|
|
|
# you can set EPATH if you need anything extra in $PATH inside the VM
|
|
|
|
#EPATH=/some/dir
|
|
|
|
|
2013-10-31 14:22:20 +01:00
|
|
|
# extra KVM arguments, e.g., -s for gdbserver
|
|
|
|
#KVMARGS=-s
|
|
|
|
|
2013-11-06 14:11:17 +01:00
|
|
|
# number of channels each hwsim device supports
|
|
|
|
CHANNELS=1
|
|
|
|
|
2013-10-31 00:23:57 +01:00
|
|
|
test -f vm-config && . vm-config
|
2014-01-14 10:38:33 +01:00
|
|
|
test -f ~/.wpas-vm-config && . ~/.wpas-vm-config
|
2013-10-31 00:23:57 +01:00
|
|
|
|
2013-10-31 14:22:20 +01:00
|
|
|
if [ -z "$KERNEL" ] && [ -z "$KERNELDIR" ] ; then
|
|
|
|
echo "You need to set a KERNEL or KERNELDIR (in the environment or vm-config)"
|
2013-10-31 00:23:57 +01:00
|
|
|
exit 2
|
|
|
|
fi
|
2013-10-31 14:22:20 +01:00
|
|
|
if [ -z "$KERNEL" ] ; then
|
2019-05-04 11:42:02 +02:00
|
|
|
if [ -e $KERNELDIR/arch/x86_64/boot/bzImage ]; then
|
|
|
|
KERNEL=$KERNELDIR/arch/x86_64/boot/bzImage
|
|
|
|
elif [ -e $KERNELDIR/linux ]; then
|
|
|
|
KERNEL=$KERNELDIR/linux
|
|
|
|
else
|
|
|
|
echo "No suitable kernel image found from KERNELDIR"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ ! -e $KERNEL ]; then
|
|
|
|
echo "Kernel image not found: $KERNEL"
|
|
|
|
exit 2
|
2013-10-31 14:22:20 +01:00
|
|
|
fi
|
2013-10-31 00:23:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
CMD=$TESTDIR/vm/inside.sh
|
2014-10-27 15:00:57 +01:00
|
|
|
|
|
|
|
unset RUN_TEST_ARGS
|
2014-11-16 21:24:18 +01:00
|
|
|
TIMESTAMP=$(date +%s)
|
|
|
|
DATE=$TIMESTAMP
|
2014-10-27 15:00:57 +01:00
|
|
|
CODECOV=no
|
|
|
|
TIMEWARP=0
|
2019-02-05 12:26:58 +01:00
|
|
|
TELNET_QEMU=
|
|
|
|
TELNET_ARG=0
|
2014-12-19 23:51:55 +01:00
|
|
|
CODECOV_DIR=
|
2014-10-27 15:00:57 +01:00
|
|
|
while [ "$1" != "" ]; do
|
|
|
|
case $1 in
|
2014-11-16 21:24:18 +01:00
|
|
|
--timestamp ) shift
|
|
|
|
TIMESTAMP=$1
|
|
|
|
shift
|
|
|
|
;;
|
2014-10-27 15:00:57 +01:00
|
|
|
--ext ) shift
|
2014-11-16 21:24:18 +01:00
|
|
|
DATE=$TIMESTAMP.$1
|
2014-10-27 15:00:57 +01:00
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--codecov ) shift
|
|
|
|
CODECOV=yes
|
|
|
|
;;
|
2014-12-19 23:51:55 +01:00
|
|
|
--codecov_dir ) shift
|
|
|
|
CODECOV_DIR=$1
|
|
|
|
shift
|
|
|
|
;;
|
2014-10-27 15:00:57 +01:00
|
|
|
--timewrap ) shift
|
|
|
|
TIMEWARP=1
|
|
|
|
;;
|
2019-02-05 12:26:58 +01:00
|
|
|
--telnet ) shift
|
|
|
|
TELNET_ARG=1
|
|
|
|
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"
|
|
|
|
shift
|
|
|
|
;;
|
2014-10-27 15:00:57 +01:00
|
|
|
* )
|
|
|
|
RUN_TEST_ARGS="$RUN_TEST_ARGS$1 "
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2013-12-27 09:16:50 +01:00
|
|
|
LOGDIR=$LOGS/$DATE
|
2013-10-31 00:23:57 +01:00
|
|
|
mkdir -p $LOGDIR
|
2019-02-01 21:04:01 +01:00
|
|
|
rm -f $LOGS/latest
|
|
|
|
ln -s $LOGDIR $LOGS/latest
|
2013-10-31 00:23:57 +01:00
|
|
|
|
2014-12-19 23:51:55 +01:00
|
|
|
if [ -n "$CODECOV_DIR" ]; then
|
|
|
|
cp -a $CODECOV_DIR/alt-wpa_supplicant $LOGDIR
|
|
|
|
cp -a $CODECOV_DIR/alt-hostapd $LOGDIR
|
|
|
|
cp -a $CODECOV_DIR/alt-hostapd-as $LOGDIR
|
|
|
|
cp -a $CODECOV_DIR/alt-hlr_auc_gw $LOGDIR
|
|
|
|
elif [ $CODECOV = "yes" ]; then
|
|
|
|
./build-codecov.sh $LOGDIR || exit 1
|
2013-12-27 09:16:50 +01:00
|
|
|
else
|
|
|
|
CODECOV=no
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Starting test run in a virtual machine"
|
|
|
|
|
2019-05-04 11:42:02 +02:00
|
|
|
if [ -x $KERNEL ]; then
|
|
|
|
unset KVM
|
|
|
|
else
|
|
|
|
KVM=kvm
|
|
|
|
for kvmprog in kvm qemu-kvm; do
|
|
|
|
if $kvmprog --version &> /dev/null; then
|
|
|
|
KVM=$kvmprog
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2015-10-12 22:01:35 +02:00
|
|
|
|
2015-11-30 11:59:09 +01:00
|
|
|
argsfile=$(mktemp)
|
|
|
|
if [ $? -ne 0 ] ; then
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
function finish {
|
|
|
|
rm -f $argsfile
|
|
|
|
}
|
|
|
|
trap finish EXIT
|
|
|
|
|
2020-03-29 13:46:44 +02:00
|
|
|
if [ -z $KVM ]; then
|
|
|
|
RUN_TEST_ARGS="--long $RUN_TEST_ARGS"
|
|
|
|
fi
|
2015-11-30 11:59:09 +01:00
|
|
|
echo "$RUN_TEST_ARGS" > $argsfile
|
|
|
|
|
2019-05-04 11:42:02 +02:00
|
|
|
A="mac80211_hwsim.support_p2p_device=0 "
|
|
|
|
A+="mac80211_hwsim.channels=$CHANNELS "
|
|
|
|
A+="mac80211_hwsim.radios=7 "
|
|
|
|
A+="cfg80211.dyndbg=+p "
|
|
|
|
A+="mac80211.dyndbg=+p "
|
|
|
|
A+="mac80211_hwsim.dyndbg=+p "
|
|
|
|
A+="init=$CMD "
|
|
|
|
A+="testdir=$TESTDIR "
|
|
|
|
A+="timewarp=$TIMEWARP "
|
|
|
|
A+="TELNET=$TELNET_ARG "
|
|
|
|
A+="EPATH=$EPATH "
|
|
|
|
A+="ARGS=$argsfile "
|
|
|
|
A+="console=$KVMOUT "
|
|
|
|
A+="ro"
|
|
|
|
|
|
|
|
if [ -z $KVM ]; then
|
|
|
|
$KERNEL \
|
|
|
|
mem=${MEMORY}M \
|
|
|
|
LOGDIR=$LOGDIR \
|
2019-05-27 21:21:25 +02:00
|
|
|
time-travel=inf-cpu \
|
2019-05-04 11:42:02 +02:00
|
|
|
$A \
|
|
|
|
root=none hostfs=/ rootfstype=hostfs rootflags=/ \
|
|
|
|
ssl0=fd:0,fd:1 \
|
|
|
|
ssl1=fd:100 \
|
2019-05-26 22:16:20 +02:00
|
|
|
ssl-non-raw \
|
2019-05-04 11:42:02 +02:00
|
|
|
100<>$LOGDIR/console 2>&1 | \
|
|
|
|
sed -u '0,/VM has started up/d'
|
|
|
|
else
|
|
|
|
$KVM \
|
|
|
|
-kernel $KERNEL \
|
|
|
|
-smp 4 \
|
|
|
|
$KVMARGS \
|
|
|
|
-m $MEMORY \
|
|
|
|
-nographic \
|
|
|
|
-fsdev local,security_model=none,id=fsdev-root,path=/$ROTAG \
|
|
|
|
-device virtio-9p-pci,id=fs-root,fsdev=fsdev-root,mount_tag=/dev/root \
|
|
|
|
-fsdev local,security_model=none,id=fsdev-logs,path="$LOGDIR",writeout=immediate \
|
|
|
|
-device virtio-9p-pci,id=fs-logs,fsdev=fsdev-logs,mount_tag=logshare \
|
|
|
|
-monitor null \
|
|
|
|
-serial stdio \
|
|
|
|
-serial file:$LOGDIR/console \
|
|
|
|
$TELNET_QEMU \
|
|
|
|
-append "$A root=/dev/root rootflags=trans=virtio,version=9p2000.u rootfstype=9p" | \
|
|
|
|
sed -u '0,/VM has started up/d'
|
|
|
|
fi
|
2013-12-25 16:14:31 +01:00
|
|
|
|
2013-12-27 09:16:50 +01:00
|
|
|
if [ $CODECOV = "yes" ]; then
|
2014-12-21 15:41:59 +01:00
|
|
|
echo "Preparing code coverage reports"
|
|
|
|
./process-codecov.sh $LOGDIR "" restore
|
|
|
|
./combine-codecov.sh $LOGDIR lcov
|
2013-12-27 09:16:50 +01:00
|
|
|
fi
|
2013-12-25 16:14:31 +01:00
|
|
|
|
2013-12-27 09:16:50 +01:00
|
|
|
echo
|
|
|
|
echo "Test run completed"
|
2019-02-01 21:04:01 +01:00
|
|
|
echo "Logfiles are at $LOGDIR ($LOGS/latest)"
|
2013-12-27 09:16:50 +01:00
|
|
|
if [ $CODECOV = "yes" ]; then
|
2014-12-21 15:41:59 +01:00
|
|
|
echo "Code coverage report:"
|
|
|
|
echo "file://$LOGDIR/lcov/index.html"
|
2013-12-25 16:14:31 +01:00
|
|
|
fi
|