2013-10-30 19:23:57 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
cd "$(dirname $0)"
|
|
|
|
|
|
|
|
if [ -z "$TESTDIR" ] ; then
|
|
|
|
TESTDIR=$(pwd)/../
|
|
|
|
fi
|
|
|
|
|
2013-12-27 03:16:50 -05:00
|
|
|
LOGS=/tmp/hwsim-test-logs
|
2013-10-30 19:23:57 -04:00
|
|
|
|
|
|
|
# increase the memory size if you want to run with valgrind, 512 MB works
|
2015-02-25 12:02:43 -05:00
|
|
|
MEMORY=192
|
2013-10-30 19:23:57 -04: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 09:22:20 -04:00
|
|
|
# extra KVM arguments, e.g., -s for gdbserver
|
|
|
|
#KVMARGS=-s
|
|
|
|
|
2013-11-06 08:11:17 -05:00
|
|
|
# number of channels each hwsim device supports
|
|
|
|
CHANNELS=1
|
|
|
|
|
2013-10-30 19:23:57 -04:00
|
|
|
test -f vm-config && . vm-config
|
2014-01-14 04:38:33 -05:00
|
|
|
test -f ~/.wpas-vm-config && . ~/.wpas-vm-config
|
2013-10-30 19:23:57 -04:00
|
|
|
|
2013-10-31 09:22:20 -04:00
|
|
|
if [ -z "$KERNEL" ] && [ -z "$KERNELDIR" ] ; then
|
|
|
|
echo "You need to set a KERNEL or KERNELDIR (in the environment or vm-config)"
|
2013-10-30 19:23:57 -04:00
|
|
|
exit 2
|
|
|
|
fi
|
2013-10-31 09:22:20 -04:00
|
|
|
if [ -z "$KERNEL" ] ; then
|
|
|
|
KERNEL=$KERNELDIR/arch/x86_64/boot/bzImage
|
|
|
|
fi
|
2013-10-30 19:23:57 -04:00
|
|
|
|
|
|
|
|
|
|
|
CMD=$TESTDIR/vm/inside.sh
|
2014-10-27 10:00:57 -04:00
|
|
|
|
|
|
|
unset RUN_TEST_ARGS
|
2014-11-16 15:24:18 -05:00
|
|
|
TIMESTAMP=$(date +%s)
|
|
|
|
DATE=$TIMESTAMP
|
2014-10-27 10:00:57 -04:00
|
|
|
CODECOV=no
|
|
|
|
TIMEWARP=0
|
2014-12-21 15:04:54 -05:00
|
|
|
DELAY=0
|
2014-12-19 17:51:55 -05:00
|
|
|
CODECOV_DIR=
|
2014-10-27 10:00:57 -04:00
|
|
|
while [ "$1" != "" ]; do
|
|
|
|
case $1 in
|
2014-11-16 15:24:18 -05:00
|
|
|
--timestamp ) shift
|
|
|
|
TIMESTAMP=$1
|
|
|
|
shift
|
|
|
|
;;
|
2014-10-27 10:00:57 -04:00
|
|
|
--ext ) shift
|
2014-11-16 15:24:18 -05:00
|
|
|
DATE=$TIMESTAMP.$1
|
2014-10-27 10:00:57 -04:00
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--codecov ) shift
|
|
|
|
CODECOV=yes
|
|
|
|
;;
|
2014-12-19 17:51:55 -05:00
|
|
|
--codecov_dir ) shift
|
|
|
|
CODECOV_DIR=$1
|
|
|
|
shift
|
|
|
|
;;
|
2014-10-27 10:00:57 -04:00
|
|
|
--timewrap ) shift
|
|
|
|
TIMEWARP=1
|
|
|
|
;;
|
2014-12-21 15:04:54 -05:00
|
|
|
--delay ) shift
|
|
|
|
DELAY=$1
|
|
|
|
shift
|
|
|
|
;;
|
2014-10-27 10:00:57 -04:00
|
|
|
* )
|
|
|
|
RUN_TEST_ARGS="$RUN_TEST_ARGS$1 "
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2013-12-27 03:16:50 -05:00
|
|
|
LOGDIR=$LOGS/$DATE
|
2013-10-30 19:23:57 -04:00
|
|
|
mkdir -p $LOGDIR
|
|
|
|
|
2014-12-19 17:51:55 -05: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 03:16:50 -05:00
|
|
|
else
|
|
|
|
CODECOV=no
|
|
|
|
fi
|
|
|
|
|
2014-12-21 15:04:54 -05:00
|
|
|
if [ $DELAY -gt 0 ]; then
|
|
|
|
echo "Wait $DELAY seconds before starting VM"
|
|
|
|
sleep $DELAY
|
|
|
|
fi
|
|
|
|
|
2013-12-27 03:16:50 -05:00
|
|
|
echo "Starting test run in a virtual machine"
|
|
|
|
|
2013-12-25 10:14:31 -05:00
|
|
|
kvm \
|
2013-10-30 19:23:57 -04:00
|
|
|
-kernel $KERNEL -smp 4 \
|
2013-10-31 09:22:20 -04:00
|
|
|
$KVMARGS -m $MEMORY -nographic \
|
2013-10-30 19:23:57 -04:00
|
|
|
-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 \
|
2014-08-05 11:25:59 -04:00
|
|
|
-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"
|
2013-12-25 10:14:31 -05:00
|
|
|
|
2013-12-27 03:16:50 -05:00
|
|
|
if [ $CODECOV = "yes" ]; then
|
2014-12-21 09:41:59 -05:00
|
|
|
echo "Preparing code coverage reports"
|
|
|
|
./process-codecov.sh $LOGDIR "" restore
|
|
|
|
./combine-codecov.sh $LOGDIR lcov
|
2013-12-27 03:16:50 -05:00
|
|
|
fi
|
2013-12-25 10:14:31 -05:00
|
|
|
|
2013-12-27 03:16:50 -05:00
|
|
|
echo
|
|
|
|
echo "Test run completed"
|
|
|
|
echo "Logfiles are at $LOGDIR"
|
|
|
|
if [ $CODECOV = "yes" ]; then
|
2014-12-21 09:41:59 -05:00
|
|
|
echo "Code coverage report:"
|
|
|
|
echo "file://$LOGDIR/lcov/index.html"
|
2013-12-25 10:14:31 -05:00
|
|
|
fi
|