hostap/tests/hwsim/vm/vm-run.sh
Johannes Berg 970d3b096f hwsim tests: Add scripts to run in a VM
Instead of running on the host, it can be useful to run in a
VM, particularly to test kernel rather than userspace changes,
so add a few scripts that allow doing so easily.

The basic idea is that the VM kernel is the same architecture
as the host kernel, so the host's root filesystem can be used
(in read-only mode) to run everything. Only a log filesystem
is mounted read-write and will get all the test output.

The kernel console output is collected to a special 'console'
file in the logs directory and kernel crashes are detected.

Signed-hostap: Johannes Berg <johannes.berg@intel.com>
2013-10-31 11:08:16 +02:00

46 lines
1.4 KiB
Bash
Executable file

#!/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
test -f vm-config && . vm-config
if [ -z "$KERNELDIR" ] ; then
echo "You need to set a KERNELDIR (in the environment or vm-config)"
exit 2
fi
KERNEL=$KERNELDIR/arch/x86_64/boot/bzImage
CMD=$TESTDIR/vm/inside.sh
LOGDIR=$LOGS/$(date +%s)
mkdir -p $LOGDIR
exec kvm \
-kernel $KERNEL -smp 4 \
-s -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 \
-append "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=$*"