diff options
author | Paul E. McKenney <paulmck@kernel.org> | 2020-11-22 09:55:34 -0800 |
---|---|---|
committer | Paul E. McKenney <paulmck@kernel.org> | 2021-01-04 14:01:21 -0800 |
commit | 0bcca18348cfde8e59b77cdf6f3e278289a16e67 (patch) | |
tree | cc5cbdd6aef743a52fbff840cbfcee6e157fce23 /tools/testing/selftests/rcutorture/bin/functions.sh | |
parent | 452613719eeea36de8ab13388a704fccb9d572dd (diff) |
torture: Print run duration at end of kvm.sh execution
Yes, you can mentally subtract the timestamps, but this commit makes
the computer do this work.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'tools/testing/selftests/rcutorture/bin/functions.sh')
-rw-r--r-- | tools/testing/selftests/rcutorture/bin/functions.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/testing/selftests/rcutorture/bin/functions.sh b/tools/testing/selftests/rcutorture/bin/functions.sh index fef8b4b55c27..97c3a1764858 100644 --- a/tools/testing/selftests/rcutorture/bin/functions.sh +++ b/tools/testing/selftests/rcutorture/bin/functions.sh @@ -108,6 +108,39 @@ configfrag_hotplug_cpu () { grep -q '^CONFIG_HOTPLUG_CPU=y$' "$1" } +# get_starttime +# +# Returns a cookie identifying the current time. +get_starttime () { + awk 'BEGIN { print systime() }' < /dev/null +} + +# get_starttime_duration starttime +# +# Given the return value from get_starttime, compute a human-readable +# string denoting the time since get_starttime. +get_starttime_duration () { + awk -v starttime=$1 ' + BEGIN { + ts = systime() - starttime; + tm = int(ts / 60); + th = int(ts / 3600); + td = int(ts / 86400); + d = td; + h = th - td * 24; + m = tm - th * 60; + s = ts - tm * 60; + if (d >= 1) + printf "%dd %d:%02d:%02d\n", d, h, m, s + else if (h >= 1) + printf "%d:%02d:%02d\n", h, m, s + else if (m >= 1) + printf "%d:%02d.0\n", m, s + else + print s " seconds" + }' < /dev/null +} + # identify_boot_image qemu-cmd # # Returns the relative path to the kernel build image. This will be |