[Ltrace-devel] [PATCH] Fix running XDG_CONFIG_DIRS.exp with Valgrind
Роман Донченко
dpb at corrigendum.ru
Sun Apr 12 18:32:11 UTC 2015
And, as an important side effect, make sure that any special characters in
the ltrace command lines are not interpreted by Tcl or the shell.
LTRACE and VALGRIND are now considered to be lists throughout the test
scripts.
---
Notes:
I believe I actually broke this myself in 9ac7f0b, when I changed the
doublequotes to braces, which caused $LTRACE to always be interpreted
as a single argument. I didn't want to change it back to quotes, though,
since that would lead to the command line being parsed twice - once by Tcl
itself, and once by catch. That would make it a lot harder to reason about
what arguments will actually be used, so I wanted to avoid it. Instead, I
used {*} expansion for $LTRACE, and edited the rest of the test suite to
match.
testsuite/lib/ltrace.exp | 12 ++++++------
testsuite/ltrace.main/XDG_CONFIG_DIRS.exp | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/testsuite/lib/ltrace.exp b/testsuite/lib/ltrace.exp
index 24a2b43..95263b9 100644
--- a/testsuite/lib/ltrace.exp
+++ b/testsuite/lib/ltrace.exp
@@ -24,14 +24,14 @@
source $objdir/env.exp
if [info exists TOOL_EXECUTABLE] {
- set LTRACE $TOOL_EXECUTABLE
+ set LTRACE [list $TOOL_EXECUTABLE]
} else {
- set LTRACE $objdir/../ltrace
+ set LTRACE [list $objdir/../ltrace]
}
if {[info exists VALGRIND] && ![string equal $VALGRIND {}]} {
verbose "Running under valgrind command: `$VALGRIND'"
- set LTRACE "$VALGRIND $LTRACE"
+ set LTRACE [concat $VALGRIND $LTRACE]
}
set LTRACE_OPTIONS {}
@@ -574,7 +574,7 @@ proc ltraceRun {args} {
# zero exit status (i.e. ltrace fails, valgrind finds errors,
# etc.).
- set command "exec env LD_LIBRARY_PATH=$LdPath $LTRACE -o $logfile $args"
+ set command [list exec env LD_LIBRARY_PATH=$LdPath {*}$LTRACE -o $logfile {*}$args]
verbose $command
if {[catch {eval $command}] } {
fail "test case execution failed"
@@ -804,8 +804,8 @@ proc ltrace_runtest { args } {
lappend LTRACE_OPTIONS "-o"
lappend LTRACE_OPTIONS "$file"
verbose "LTRACE_OPTIONS = $LTRACE_OPTIONS"
- set command "exec sh -c {export LD_LIBRARY_PATH=$LD_LIBRARY_PATH_; \
- $LTRACE $LTRACE_OPTIONS $BIN $LTRACE_ARGS;exit}"
+ set command {exec env LD_LIBRARY_PATH=$LD_LIBRARY_PATH_ \
+ {*}$LTRACE {*}$LTRACE_OPTIONS $BIN {*}$LTRACE_ARGS}
#ltrace the PUT.
if {[catch $command output]} {
fail "test case execution failed"
diff --git a/testsuite/ltrace.main/XDG_CONFIG_DIRS.exp b/testsuite/ltrace.main/XDG_CONFIG_DIRS.exp
index 7b2786b..a7eb8a4 100644
--- a/testsuite/ltrace.main/XDG_CONFIG_DIRS.exp
+++ b/testsuite/ltrace.main/XDG_CONFIG_DIRS.exp
@@ -24,7 +24,7 @@ setenv XDG_CONFIG_DIRS "blah"
ltraceRun -L -- $bin
unsetenv XDG_CONFIG_DIRS
-if {[catch {exec env LD_LIBRARY_PATH=[ld_library_path] $LTRACE -L -F blah -- $bin} output]} {
+if {[catch {exec env LD_LIBRARY_PATH=[ld_library_path] {*}$LTRACE -L -F blah -- $bin} output]} {
ltraceMatch [ltraceSource ltrace "$output"] {
{blah == 1}
}
--
1.8.5.6
More information about the Ltrace-devel
mailing list