Skip to contentSkip to conversation

runtests: Make path of time binary configurable

PATCH Mathieu Desnoyers 1 participant 2 messages Nov 15, 2012 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 9 lines · * Simon Marchi ([email protected]) wrote:

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.

I have a problem when running make check from userspace rcu tree root with this patch applied:

Executing batch RCU test
./runtests-batch.sh: 3: ./runtests-batch.sh: source: not found

Thoughts ?

Mathieu

Quoted 90 lines

---

New in v2: removed #!/bin/sh at top of common.sh.

 tests/common.sh         |   12 ++++++++++++
 tests/runtests-batch.sh |   15 +++++++++++++--
 tests/runtests.sh       |   15 +++++++++++++--
 3 files changed, 38 insertions(+), 4 deletions(-)
 create mode 100755 tests/common.sh
tests/common.sh new file +12 -0
new file mode 100755
index 0000000..9eb03f8
@@ -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
+
tests/runtests-batch.sh +13 -2
index 6c2340d..222069c 100755
@@ -1,8 +1,19 @@
 #!/bin/sh
 
+source "./common.sh"
+
+log_file="runall.detail.log"
+
+# Check if time bin is defined
+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
 
tests/runtests.sh +13 -2
index 79e54df..b3d3dc2 100755
@@ -1,10 +1,21 @@
 #!/bin/sh
 
+source "./common.sh"
+
+log_file="runall.detail.log"
+
+# Check if time bin is defined
+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
 
Signature · 7 lines
1.7.1


_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
#2 lore raw
In reply to a message not in the archive
Quoted 9 lines · * Simon Marchi ([email protected]) wrote:

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.

Merged with edit:

commit fce9a534217cc39db50bb546f2521cc4321df197

Author: Simon Marchi <[email protected]>
Date:   Thu Nov 15 09:29:42 2012 -0500

runtests: Make path of time binary configurable

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. ]

Thanks,

Mathieu

Quoted 90 lines

---

New in v2: removed #!/bin/sh at top of common.sh.

 tests/common.sh         |   12 ++++++++++++
 tests/runtests-batch.sh |   15 +++++++++++++--
 tests/runtests.sh       |   15 +++++++++++++--
 3 files changed, 38 insertions(+), 4 deletions(-)
 create mode 100755 tests/common.sh
tests/common.sh new file +12 -0
new file mode 100755
index 0000000..9eb03f8
@@ -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
+
tests/runtests-batch.sh +13 -2
index 6c2340d..222069c 100755
@@ -1,8 +1,19 @@
 #!/bin/sh
 
+source "./common.sh"
+
+log_file="runall.detail.log"
+
+# Check if time bin is defined
+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
 
tests/runtests.sh +13 -2
index 79e54df..b3d3dc2 100755
@@ -1,10 +1,21 @@
 #!/bin/sh
 
+source "./common.sh"
+
+log_file="runall.detail.log"
+
+# Check if time bin is defined
+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
 
Signature · 7 lines
1.7.1


_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com