runtests: Make path of time binary configurable
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 15 Nov 2012 14:29:42 +0000 (09:29 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 15 Nov 2012 14:29:42 +0000 (09:29 -0500)
I work on a platform that does not come with a time program. This patch
makes it possible to specify the path of the time binary or not use it
if none is available.

If the URCU_TEST_TIME_BIN environment variable exists and is executable,
it is used. Otherwise it tries with /usr/bin/time, the most common
location. If it is not there, the tests are ran without timing info.

[ Edit by Mathieu Desnoyers: use "." instead of "source" (no bash-ism),
  edit commit about check for emptiness vs definition to match the code. ]

Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests/common.sh [new file with mode: 0644]
tests/runtests-batch.sh
tests/runtests.sh

diff --git a/tests/common.sh b/tests/common.sh
new file mode 100644 (file)
index 0000000..9eb03f8
--- /dev/null
@@ -0,0 +1,12 @@
+#
+# This file is meant to be sourced from other tests scripts.
+#
+
+if [ -x "$URCU_TEST_TIME_BIN" ]; then
+       test_time_bin="$URCU_TEST_TIME_BIN"
+elif [ -x "/usr/bin/time" ]; then
+       test_time_bin="/usr/bin/time"
+else
+       test_time_bin=""
+fi
+
index 6c2340d18b2d880df36e87417e134137b5ec5d86..2da1401b15771c91e5e76090161027a91108aeca 100755 (executable)
@@ -1,8 +1,19 @@
 #!/bin/sh
 
+. ./common.sh
+
+log_file="runall.detail.log"
+
+# Check if time bin is non-empty
+if [ -n "$test_time_bin" ]; then
+       time_command="$test_time_bin -a -o $log_file"
+else
+       time_command=""
+fi
+
 #for a in test_urcu_gc test_urcu_gc_mb test_urcu_qsbr_gc; do
 for a in test_urcu_gc; do
-       echo "./${a} $*" | tee -a runall.detail.log
-       /usr/bin/time -a -o runall.detail.log ./${a} $*
+       echo "./${a} $*" | tee -a "$log_file"
+       $time_command ./${a} $*
 done
 
index 79e54df7fcf1558d1aa3526570483267785e30c8..60011744e67699f3eaaa88181257eec008a3d620 100755 (executable)
@@ -1,10 +1,21 @@
 #!/bin/sh
 
+. ./common.sh
+
+log_file="runall.detail.log"
+
+# Check if time bin is non-empty
+if [ -n "$test_time_bin" ]; then
+       time_command="$test_time_bin -a -o $log_file"
+else
+       time_command=""
+fi
+
 for a in test_urcu_gc test_urcu_signal_gc test_urcu_mb_gc test_urcu_qsbr_gc \
        test_urcu_lgc test_urcu_signal_lgc test_urcu_mb_lgc test_urcu_qsbr_lgc \
        test_urcu test_urcu_signal test_urcu_mb test_urcu_qsbr \
        test_rwlock test_perthreadlock test_mutex; do
-       echo "./${a} $*" | tee -a runall.detail.log
-       /usr/bin/time -a -o runall.detail.log ./${a} $*
+       echo "./${a} $*" | tee -a "$log_file"
+       $time_command ./${a} $*
 done
 
This page took 0.026183 seconds and 4 git commands to generate.