aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac4
-rw-r--r--testsuite/Makefile.am9
-rw-r--r--testsuite/lib/ltrace.exp39
-rw-r--r--testsuite/ltrace.minor/trace-clone.exp14
-rw-r--r--testsuite/ltrace.minor/trace-exec.exp25
-rw-r--r--testsuite/ltrace.minor/trace-fork.exp25
6 files changed, 66 insertions, 50 deletions
diff --git a/configure.ac b/configure.ac
index 172de11..e8eeda6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,6 +45,7 @@ AC_ARG_WITH([libelf],
(*)
AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include"
AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib"
+ libelf_LD_LIBRARY_PATH="${withval}/lib"
;;
esac],[])
@@ -89,6 +90,7 @@ AC_ARG_WITH(libunwind,
(*) enable_libunwind=yes
AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include"
AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib"
+ libunwind_LD_LIBRARY_PATH="${withval}/lib"
;;
esac],[enable_libunwind=maybe])
@@ -245,6 +247,8 @@ fi
AC_SUBST(AM_CPPFLAGS)
AC_SUBST(AM_CFLAGS)
AC_SUBST(AM_LDFLAGS)
+AC_SUBST(libelf_LD_LIBRARY_PATH)
+AC_SUBST(libunwind_LD_LIBRARY_PATH)
AC_CONFIG_FILES([
Makefile
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 4802ed9..a4c7cfa 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -29,6 +29,13 @@ EXTRA_DIST = \
lib/ltrace.exp \
run-my-tests.sh
-CLEANFILES = *.o *.so *.log *.sum *.ltrace site.bak setval.tmp site.exp
+BUILT_SOURCES = env.exp
+
+env.exp: Makefile
+ rm -f env.exp
+ echo set libelf_LD_LIBRARY_PATH '"$(libelf_LD_LIBRARY_PATH)"' >> $@
+ echo set libunwind_LD_LIBRARY_PATH '"$(libunwind_LD_LIBRARY_PATH)"' >> $@
+
+CLEANFILES = *.o *.so *.log *.sum *.ltrace site.bak setval.tmp site.exp env.exp
MAINTAINERCLEANFILES = Makefile.in
diff --git a/testsuite/lib/ltrace.exp b/testsuite/lib/ltrace.exp
index eb7c960..db602ff 100644
--- a/testsuite/lib/ltrace.exp
+++ b/testsuite/lib/ltrace.exp
@@ -4,6 +4,7 @@
# need to be modified for any target, it can be done with a variable
# or by passing arguments.
+source $objdir/env.exp
global LTRACE
if [info exists TOOL_EXECUTABLE] {
@@ -14,6 +15,8 @@ if [info exists TOOL_EXECUTABLE] {
global LTRACE_OPTIONS
set LTRACE_OPTIONS "";
+global LTRACE_ARGS
+set LTRACE_ARGS "";
# ltrace_compile SOURCE DEST TYPE OPTIONS
#
@@ -196,6 +199,37 @@ proc ltrace_options { args } {
}
#
+# ltrace_args ARGS_LIST
+# Pass ltrace'd program its own commandline options.
+#
+proc ltrace_args { args } {
+
+ global LTRACE_ARGS
+ set LTRACE_ARGS $args
+}
+
+#
+# handle run-time library paths
+#
+proc ld_library_path { args } {
+
+ set ALL_LIBRARY_PATHS { }
+ if [info exists LD_LIBRARY_PATH] {
+ lappend ALL_LIBRARY_PATHS $LD_LIBRARY_PATH
+ }
+ global libelf_LD_LIBRARY_PATH
+ if {[string length $libelf_LD_LIBRARY_PATH] > 0} {
+ lappend ALL_LIBRARY_PATHS $libelf_LD_LIBRARY_PATH
+ }
+ global libunwind_LD_LIBRARY_PATH
+ if {[string length $libunwind_LD_LIBRARY_PATH] > 0} {
+ lappend ALL_LIBRARY_PATHS $libunwind_LD_LIBRARY_PATH
+ }
+ lappend ALL_LIBRARY_PATHS $args
+ join $ALL_LIBRARY_PATHS ":"
+}
+
+#
# ltrace_runtest LD_LIBRARY_PATH BIN FILE
# Trace the execution of BIN and return result.
#
@@ -208,10 +242,11 @@ proc ltrace_runtest { args } {
global LTRACE
global LTRACE_OPTIONS
+ global LTRACE_ARGS
verbose "LTRACE = $LTRACE"
- set LD_LIBRARY_PATH_ [lindex $args 0]
+ set LD_LIBRARY_PATH_ [ld_library_path [lindex $args 0]]
set BIN [lindex $args 1]
# specify the output file, the default one is $BIN.ltrace
@@ -225,7 +260,7 @@ proc ltrace_runtest { args } {
lappend LTRACE_OPTIONS "$file"
verbose "LTRACE_OPTIONS = $LTRACE_OPTIONS"
#ltrace the PUT.
- catch "exec sh -c {export LD_LIBRARY_PATH=$LD_LIBRARY_PATH_; $LTRACE $LTRACE_OPTIONS $BIN;exit}" output
+ catch "exec sh -c {export LD_LIBRARY_PATH=$LD_LIBRARY_PATH_; $LTRACE $LTRACE_OPTIONS $BIN $LTRACE_ARGS;exit}" output
# return output from ltrace.
return $output
diff --git a/testsuite/ltrace.minor/trace-clone.exp b/testsuite/ltrace.minor/trace-clone.exp
index 749cc49..3d0c8fe 100644
--- a/testsuite/ltrace.minor/trace-clone.exp
+++ b/testsuite/ltrace.minor/trace-clone.exp
@@ -10,19 +10,9 @@ verbose "compiling source file now....."
if { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.c" "${objdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
}
-global LTRACE
-#Run PUT for ltrace.
-spawn $LTRACE -f $objdir/$subdir/$binfile
-set timeout 4
-expect timeout {
- fail "Time out! Maybe caused by ltrace segment fault or improper timeout value here!"
- return
-}
-
-catch "exec $LTRACE -f $objdir/$subdir/$binfile" exec_output
-# Save the output
-ltrace_saveoutput "${exec_output}" ${objdir}/${subdir}/${testfile}.ltrace
+ltrace_options "-f"
+set exec_output [ltrace_runtest $objdir/$subdir $objdir/$subdir/$binfile]
#check the output of this program.
verbose "ltrace runtest output: $exec_output\n"
diff --git a/testsuite/ltrace.minor/trace-exec.exp b/testsuite/ltrace.minor/trace-exec.exp
index 99145f5..9751c58 100644
--- a/testsuite/ltrace.minor/trace-exec.exp
+++ b/testsuite/ltrace.minor/trace-exec.exp
@@ -12,18 +12,8 @@ if { [ ltrace_compile "${srcdir}/${subdir}/${testfile}1.c" "${objdir}/${subdir}
send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
}
-global LTRACE
-set exec_output ""
-
-#Run PUT for ltrace.
-spawn $LTRACE $objdir/$subdir/$testfile $objdir/$subdir/${testfile}1
-set timeout 4
-expect timeout {
- fail "Time out! Maybe caused by ltrace segment fault or improper timeout value here!"
- return
-}
-
-catch "exec $LTRACE $objdir/$subdir/$testfile $objdir/$subdir/${testfile}1" exec_output
+ltrace_args "$objdir/$subdir/${testfile}1"
+set exec_output [ltrace_runtest $objdir/$subdir $objdir/$subdir/$testfile]
#check the output of this program.
verbose "ltrace runtest output: $exec_output\n"
@@ -35,11 +25,12 @@ if [regexp {ELF from incompatible architecture} $exec_output] {
return
}
-ltrace_saveoutput "${exec_output}" ${objdir}/${subdir}/${testfile}.ltrace
-
# execl from first binary
-ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace {"^execl"} 1
+set pattern {^[0-9]* execl}
+ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1
# puts from second binary
-ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace {"^puts"} 1
+set pattern {^[0-9]* puts}
+ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1
# assume glibc and see we really trace both binaries
-ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace {"^__libc_start_main"} 2
+set pattern {^[0-9]* __libc_start_main}
+ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 2
diff --git a/testsuite/ltrace.minor/trace-fork.exp b/testsuite/ltrace.minor/trace-fork.exp
index 29a7cff..70815f5 100644
--- a/testsuite/ltrace.minor/trace-fork.exp
+++ b/testsuite/ltrace.minor/trace-fork.exp
@@ -10,18 +10,9 @@ verbose "compiling source file now....."
if { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.c" "${objdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
}
-global LTRACE
-set exec_output ""
-
-#Run PUT for ltrace.
-spawn $LTRACE -f $objdir/$subdir/$binfile
-set timeout 4
-expect timeout {
- fail "Time out! Maybe caused by ltrace segment fault or improper timeout value here!"
- return
-}
-catch "exec $LTRACE -f $objdir/$subdir/$binfile" exec_output
+ltrace_options "-f"
+set exec_output [ltrace_runtest $objdir/$subdir $objdir/$subdir/$binfile]
#check the output of this program.
verbose "ltrace runtest output: $exec_output\n"
@@ -33,24 +24,22 @@ if [regexp {ELF from incompatible architecture} $exec_output] {
return
}
-ltrace_saveoutput "${exec_output}" ${objdir}/${subdir}/${testfile}.ltrace
-
if [ regexp {Cannot attach} $exec_output ] {
fail "Couldn't attach to forked process!"
return
}
-set pattern {^\[pid [0-9]*\] fork}
+set pattern {^[0-9]* fork}
ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1
-set pattern {^\[pid [0-9]*\] printf}
+set pattern {^[0-9]* printf}
ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1
-set pattern {^\[pid [0-9]*\] puts}
+set pattern {^[0-9]* puts}
ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1
-set pattern {^\[pid [0-9]*\] wait}
+set pattern {^[0-9]* wait}
ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1
-set pattern {^\[pid [0-9]*\] sleep}
+set pattern {^[0-9]* sleep}
ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1