]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hwsim tests: vm: add optional time-warp
authorJohannes Berg <johannes.berg@intel.com>
Wed, 15 Jan 2014 19:58:39 +0000 (20:58 +0100)
committerJouni Malinen <j@w1.fi>
Fri, 17 Jan 2014 10:00:20 +0000 (12:00 +0200)
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>

tests/hwsim/vm/inside.sh
tests/hwsim/vm/vm-run.sh

index 036197b125e99e3ee2c613794156db9f912071b0..833253d6baec2038d12b8caacbb95e0e308cc353 100755 (executable)
@@ -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
index 6feaaaa5cbeebfd44490f1b4a917dbe4cade015b..c6edb57b891df1493b56433e6010adb9e266c27e 100755 (executable)
@@ -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