[PATCH] hwsim tests: vm: add optional time-warp
Johannes Berg
johannes
Tue Jan 14 08:29:49 PST 2014
From: Johannes Berg <johannes.berg at intel.com>
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-off-by: Johannes Berg <johannes.berg at intel.com>
---
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 036197b..833253d 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 6feaaaa..c6edb57 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
--
1.8.5.1
More information about the Hostap
mailing list