tests: Support UML kernel as a replacement for KVM
This allows UML builds to be used in running user mode without having to run the full x86 kernel in virtual machine. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
6980542556
commit
1cefd89b37
2 changed files with 72 additions and 20 deletions
|
@ -31,6 +31,7 @@ TIMEWARP=$(sed 's/.*timewarp=\([^ ]*\) .*/\1/' /proc/cmdline)
|
||||||
EPATH=$(sed 's/.*EPATH=\([^ ]*\) .*/\1/' /proc/cmdline)
|
EPATH=$(sed 's/.*EPATH=\([^ ]*\) .*/\1/' /proc/cmdline)
|
||||||
TELNET=$(sed 's/.*TELNET=\([^ ]*\) .*/\1/' /proc/cmdline)
|
TELNET=$(sed 's/.*TELNET=\([^ ]*\) .*/\1/' /proc/cmdline)
|
||||||
ARGS=$(sed 's/.*ARGS=\([^ ]*\)\( \|$\).*/\1/' /proc/cmdline)
|
ARGS=$(sed 's/.*ARGS=\([^ ]*\)\( \|$\).*/\1/' /proc/cmdline)
|
||||||
|
LOGDIR=$(sed 's/.*LOGDIR=\([^ ]*\)\( \|$\).*/\1/' /proc/cmdline)
|
||||||
|
|
||||||
# create /dev entries we need
|
# create /dev entries we need
|
||||||
mknod -m 660 /dev/ttyS0 c 4 64
|
mknod -m 660 /dev/ttyS0 c 4 64
|
||||||
|
@ -90,7 +91,11 @@ ip link set lo up
|
||||||
|
|
||||||
# create logs mountpoint and mount the logshare
|
# create logs mountpoint and mount the logshare
|
||||||
mkdir /tmp/logs
|
mkdir /tmp/logs
|
||||||
mount -t 9p -o trans=virtio,rw logshare /tmp/logs
|
if grep -q rootfstype=hostfs /proc/cmdline; then
|
||||||
|
mount -t hostfs none /tmp/logs -o $LOGDIR
|
||||||
|
else
|
||||||
|
mount -t 9p -o trans=virtio,rw logshare /tmp/logs
|
||||||
|
fi
|
||||||
|
|
||||||
# allow access to any outside directory (e.g. /tmp) we also have
|
# allow access to any outside directory (e.g. /tmp) we also have
|
||||||
mkdir /tmp/host
|
mkdir /tmp/host
|
||||||
|
|
|
@ -40,7 +40,18 @@ if [ -z "$KERNEL" ] && [ -z "$KERNELDIR" ] ; then
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
if [ -z "$KERNEL" ] ; then
|
if [ -z "$KERNEL" ] ; then
|
||||||
KERNEL=$KERNELDIR/arch/x86_64/boot/bzImage
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,13 +125,17 @@ fi
|
||||||
|
|
||||||
echo "Starting test run in a virtual machine"
|
echo "Starting test run in a virtual machine"
|
||||||
|
|
||||||
KVM=kvm
|
if [ -x $KERNEL ]; then
|
||||||
for kvmprog in kvm qemu-kvm; do
|
unset KVM
|
||||||
if $kvmprog --version &> /dev/null; then
|
else
|
||||||
KVM=$kvmprog
|
KVM=kvm
|
||||||
break
|
for kvmprog in kvm qemu-kvm; do
|
||||||
fi
|
if $kvmprog --version &> /dev/null; then
|
||||||
done
|
KVM=$kvmprog
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
argsfile=$(mktemp)
|
argsfile=$(mktemp)
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
|
@ -133,17 +148,49 @@ trap finish EXIT
|
||||||
|
|
||||||
echo "$RUN_TEST_ARGS" > $argsfile
|
echo "$RUN_TEST_ARGS" > $argsfile
|
||||||
|
|
||||||
$KVM \
|
A="mac80211_hwsim.support_p2p_device=0 "
|
||||||
-kernel $KERNEL -smp 4 \
|
A+="mac80211_hwsim.channels=$CHANNELS "
|
||||||
$KVMARGS -m $MEMORY -nographic \
|
A+="mac80211_hwsim.radios=7 "
|
||||||
-fsdev local,security_model=none,id=fsdev-root,path=/$ROTAG \
|
A+="cfg80211.dyndbg=+p "
|
||||||
-device virtio-9p-pci,id=fs-root,fsdev=fsdev-root,mount_tag=/dev/root \
|
A+="mac80211.dyndbg=+p "
|
||||||
-fsdev local,security_model=none,id=fsdev-logs,path="$LOGDIR",writeout=immediate \
|
A+="mac80211_hwsim.dyndbg=+p "
|
||||||
-device virtio-9p-pci,id=fs-logs,fsdev=fsdev-logs,mount_tag=logshare \
|
A+="init=$CMD "
|
||||||
-monitor null -serial stdio -serial file:$LOGDIR/console \
|
A+="testdir=$TESTDIR "
|
||||||
$TELNET_QEMU \
|
A+="timewarp=$TIMEWARP "
|
||||||
-append "mac80211_hwsim.support_p2p_device=0 mac80211_hwsim.channels=$CHANNELS mac80211_hwsim.radios=7 cfg80211.dyndbg=+p mac80211.dyndbg=+p mac80211_hwsim.dyndbg=+p init=$CMD testdir=$TESTDIR timewarp=$TIMEWARP TELNET=$TELNET_ARG console=$KVMOUT root=/dev/root rootflags=trans=virtio,version=9p2000.u ro rootfstype=9p EPATH=$EPATH ARGS=$argsfile" | \
|
A+="TELNET=$TELNET_ARG "
|
||||||
sed -u '0,/VM has started up/d'
|
A+="EPATH=$EPATH "
|
||||||
|
A+="ARGS=$argsfile "
|
||||||
|
A+="console=$KVMOUT "
|
||||||
|
A+="ro"
|
||||||
|
|
||||||
|
if [ -z $KVM ]; then
|
||||||
|
$KERNEL \
|
||||||
|
mem=${MEMORY}M \
|
||||||
|
LOGDIR=$LOGDIR \
|
||||||
|
$A \
|
||||||
|
root=none hostfs=/ rootfstype=hostfs rootflags=/ \
|
||||||
|
ssl0=fd:0,fd:1 \
|
||||||
|
ssl1=fd:100 \
|
||||||
|
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
|
||||||
|
|
||||||
if [ $CODECOV = "yes" ]; then
|
if [ $CODECOV = "yes" ]; then
|
||||||
echo "Preparing code coverage reports"
|
echo "Preparing code coverage reports"
|
||||||
|
|
Loading…
Reference in a new issue