runtests: Make path of time binary configurable
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 22 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_BINenvironment 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.Signed-off-by Simon Marchi <[email protected]>--- tests/common.sh | 13 +++++++++++++ tests/runtests-batch.sh | 15 +++++++++++++-- tests/runtests.sh | 15 +++++++++++++-- 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100755 tests/common.shtests/common.sh new file +0
-0
tests/common.sh line 1
Quoted 1 line
tests/common.sh new file +1
-0@@ -0,0 +1,13 @@ +#!/bin/sh
If it is meant to be sourced from other files, then the #!/bin/sh header is useless. Mainly because common.sh is useless when not sourced from other scripts (useless indivitually).
tests/common.sh line 7
Quoted 6 lines
tests/common.sh new file +6
-0+# +# 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"
We use capital letters to represent "variables" (which are really environment variables) in bash.
e.g.: test_time_bin -> TEST_TIME_BIN
Same for log_file and time_command.
Thanks,
Mathieu
Quoted 68 lines
tests/common.sh new file +6
-0+elif [ -x "/usr/bin/time" ]; then + test_time_bin="/usr/bin/time" +else + test_time_bin="" +fi +tests/runtests-batch.sh +13
-2@@ -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} $* donetests/runtests.sh +13
-2@@ -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} $* doneSignature · 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
A message that is not in the archive (sent off-list or not yet received): 20121115050017.GA19512@Krystal
Quoted 17 lines · Mathieu Desnoyers
Quoted 16 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_BINenvironment 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.Signed-off-by Simon Marchi <[email protected]>--- tests/common.sh | 13 +++++++++++++ tests/runtests-batch.sh | 15 +++++++++++++-- tests/runtests.sh | 15 +++++++++++++-- 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100755 tests/common.sh
Quoted 11 lines
tests/common.sh line 1
Quoted 7 lines
tests/common.sh new file +1
-0@@ -0,0 +1,13 @@ +#!/bin/shIf it is meant to be sourced from other files, then the #!/bin/sh header is useless. Mainly because
common.shis useless when not sourced from other scripts (useless indivitually).
Right.
Quoted 10 lines
tests/common.sh line 7
Quoted 6 lines
tests/common.sh new file +6
-0+# +# 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"We use capital letters to represent "variables" (which are really environment variables) in bash.
Quoted 3 lines
e.g.:
test_time_bin->TEST_TIME_BINSame for
log_fileandtime_command.
If I understand correctly, it is not an environment variable until you export it (thus make it available to child processes). There is such a thing plain variable, there is just one big scope. I think there is not a single right way to do this, but I tend to agree with the SO answer below. By using capitalized names, you risk interfering with important environment variables. It would be a shame to do PATH="/tmp/something" by accident.
The answer I am referring to:
http://stackoverflow.com/questions/673055/correct-bash-and-shell-script-variable-capitalization.
Quoted 78 lines
Thanks,
Mathieu
Quoted 64 lines
tests/common.sh new file +6
-0+elif [ -x "/usr/bin/time" ]; then + test_time_bin="/usr/bin/time" +else + test_time_bin="" +fi +tests/runtests-batch.sh +13
-2@@ -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} $* donetests/runtests.sh +13
-3@@ -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 --1.7.1
Quoted 4 lines
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
A message that is not in the archive (sent off-list or not yet received): CAFXXi0kt1OWZ6wteNAwL=4k7Lmt7=YtciLxyyUJanC7ok3tB3Q@mail.gmail.com
Quoted 9 lines
If I understand correctly, it is not an environment variable until you export it (thus make it available to child processes). There is such a thing plain variable, there is just one big scope. I think there is not a single right way to do this, but I tend to agree with the SO answer below. By using capitalized names, you risk interfering with important environment variables. It would be a shame to do PATH="/tmp/something" by accident.
Quoted 5 lines
The answer I am referring to:
http://stackoverflow.com/questions/673055/correct-bash-and-shell-script-variable-capitalization
.
I approve what Simon says.
There is no real convention, and it is common to use "_"-separated variables names for non-exported ones, to be able to distinguish which one was/will be exported. In fact, it is also "promoted" by this book :
http://goo.gl/IBFza (read full paragraph, there is a part on the next page)
On the other hand, it is commonly said that if you work on a bash script that already has a convention, you have to be consistent to it.
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Quoted 55 lines · * Simon Marchi ([email protected]) wrote:
Quoted 17 lines · Mathieu Desnoyers
Quoted 16 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_BINenvironment 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.Signed-off-by Simon Marchi <[email protected]>--- tests/common.sh | 13 +++++++++++++ tests/runtests-batch.sh | 15 +++++++++++++-- tests/runtests.sh | 15 +++++++++++++-- 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100755 tests/common.shQuoted 11 lines
tests/common.sh line 1
Quoted 7 lines
tests/common.sh new file +1
-0@@ -0,0 +1,13 @@ +#!/bin/shIf it is meant to be sourced from other files, then the #!/bin/sh header is useless. Mainly because
common.shis useless when not sourced from other scripts (useless indivitually).Right.
Quoted 10 lines
tests/common.sh line 7
Quoted 6 lines
tests/common.sh new file +6
-0+# +# 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"We use capital letters to represent "variables" (which are really environment variables) in bash.
Quoted 3 lines
e.g.:
test_time_bin->TEST_TIME_BINSame for
log_fileandtime_command.If I understand correctly, it is not an environment variable until you export it (thus make it available to child processes). There is such a thing plain variable, there is just one big scope. I think there is not a single right way to do this, but I tend to agree with the SO answer below. By using capitalized names, you risk interfering with important environment variables. It would be a shame to do PATH="/tmp/something" by accident.
Quoted 2 lines
The answer I am referring to:
http://stackoverflow.com/questions/673055/correct-bash-and-shell-script-variable-capitalization.
That's a compelling argument,
I'll gradually adapt my bash coding style then,
Thanks,
Mathieu
Quoted 79 lines
Quoted 79 lines
Thanks,
Mathieu
Quoted 64 lines
tests/common.sh new file +6
-0+elif [ -x "/usr/bin/time" ]; then + test_time_bin="/usr/bin/time" +else + test_time_bin="" +fi +tests/runtests-batch.sh +13
-2@@ -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} $* donetests/runtests.sh +13
-3@@ -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 --1.7.1
Quoted 4 lines
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
Signature · 4 lines
Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com