2013-10-31 00:23:57 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
cd "$(dirname $0)"
|
|
|
|
|
|
|
|
if [ -z "$TESTDIR" ] ; then
|
|
|
|
TESTDIR=$(pwd)/../
|
|
|
|
fi
|
|
|
|
|
|
|
|
LOGS=/tmp/hwsim-test-logs/
|
|
|
|
|
|
|
|
# increase the memory size if you want to run with valgrind, 512 MB works
|
|
|
|
MEMORY=128
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
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
|
|
|
|
KERNEL=$KERNELDIR/arch/x86_64/boot/bzImage
|
|
|
|
fi
|
2013-10-31 00:23:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
CMD=$TESTDIR/vm/inside.sh
|
|
|
|
LOGDIR=$LOGS/$(date +%s)
|
|
|
|
mkdir -p $LOGDIR
|
|
|
|
|
2013-12-25 16:14:31 +01:00
|
|
|
kvm \
|
2013-10-31 00:23:57 +01:00
|
|
|
-kernel $KERNEL -smp 4 \
|
2013-10-31 14:22:20 +01:00
|
|
|
$KVMARGS -m $MEMORY -nographic \
|
2013-10-31 00:23:57 +01: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 \
|
2013-11-06 14:11:17 +01:00
|
|
|
-append "mac80211_hwsim.channels=$CHANNELS mac80211_hwsim.radios=5 init=$CMD testdir=$TESTDIR console=$KVMOUT root=/dev/root rootflags=trans=virtio,version=9p2000.u ro rootfstype=9p EPATH=$EPATH ARGS=$*"
|
2013-12-25 16:14:31 +01:00
|
|
|
|
|
|
|
echo LOGDIR=$LOGDIR
|
|
|
|
|
|
|
|
if [ -d $LOGDIR/gcov ]; then
|
|
|
|
echo "Move gcov data files from vm logdir to build directories"
|
|
|
|
for i in $LOGDIR/gcov/*.gcda; do
|
|
|
|
file=`basename $i | sed "s/.gcda$//"`
|
|
|
|
find ../../.. -name $file.gcno | sed s/.gcno/.gcda/ | xargs mv $i
|
|
|
|
done
|
|
|
|
fi
|