hwsim tests: vm: add optional time-warp

To test the code under the influence of time jumps, add the option
(--timewarp) to the VM tests to reset the clock all the time, which
makes the wall clock time jump speed up 20x, causing gettimeofday()
to be unreliable for timeout calculations.

Signed-hostap: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2014-01-15 20:58:39 +01:00 committed by Jouni Malinen
parent 443427e4ed
commit ac5e8631e6
2 changed files with 17 additions and 1 deletions

View file

@ -18,6 +18,7 @@ sysctl kernel.panic=1
# get extra command line variables from /proc/cmdline
TESTDIR=$(sed 's/.*testdir=\([^ ]*\) .*/\1/' /proc/cmdline)
TIMEWARP=$(sed 's/.*timewarp=\([^ ]*\) .*/\1/' /proc/cmdline)
EPATH=$(sed 's/.*EPATH=\([^ ]*\) .*/\1/' /proc/cmdline)
ARGS=$(sed 's/.*ARGS=//' /proc/cmdline)
@ -56,6 +57,14 @@ ip link set lo up
mkdir /tmp/logs
mount -t 9p -o trans=virtio,rw logshare /tmp/logs
if [ "$TIMEWARP" = "1" ] ; then
(
while sleep 1 ; do
date --set "@$(($(date +%s) + 19))"
done
) &
fi
# check if we're rebooting due to a kernel panic ...
if grep -q 'Kernel panic' /tmp/logs/console ; then
echo "KERNEL CRASHED!" >/dev/ttyS0

View file

@ -96,6 +96,13 @@ else
CODECOV=no
fi
if [ "$1" == "--timewarp" ] ; then
TIMEWARP=1
shift
else
TIMEWARP=0
fi
echo "Starting test run in a virtual machine"
kvm \
@ -106,7 +113,7 @@ kvm \
-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.channels=$CHANNELS mac80211_hwsim.radios=6 init=$CMD testdir=$TESTDIR console=$KVMOUT root=/dev/root rootflags=trans=virtio,version=9p2000.u ro rootfstype=9p EPATH=$EPATH ARGS=$*"
-append "mac80211_hwsim.channels=$CHANNELS mac80211_hwsim.radios=6 init=$CMD testdir=$TESTDIR timewarp=$TIMEWARP console=$KVMOUT root=/dev/root rootflags=trans=virtio,version=9p2000.u ro rootfstype=9p EPATH=$EPATH ARGS=$*"
if [ $CODECOV = "yes" ]; then
mv $LOGDIR/alt-wpa_supplicant /tmp/logs