From ac5e8631e6a6266f1148bc5d32f4a6acdd3d25c4 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 15 Jan 2014 20:58:39 +0100 Subject: [PATCH] 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 --- tests/hwsim/vm/inside.sh | 9 +++++++++ tests/hwsim/vm/vm-run.sh | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/hwsim/vm/inside.sh b/tests/hwsim/vm/inside.sh index 036197b12..833253d6b 100755 --- a/tests/hwsim/vm/inside.sh +++ b/tests/hwsim/vm/inside.sh @@ -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 diff --git a/tests/hwsim/vm/vm-run.sh b/tests/hwsim/vm/vm-run.sh index 6feaaaa5c..c6edb57b8 100755 --- a/tests/hwsim/vm/vm-run.sh +++ b/tests/hwsim/vm/vm-run.sh @@ -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