aboutsummaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2012-12-06 18:57:18 +0100
committerPetr Machata <pmachata@redhat.com>2013-03-08 22:55:29 +0100
commite8701b4cc4333dbc5e3c683468fa8fb077977ba6 (patch)
treec1a0fe36d34844dbe3b66ae3c52680fad4c2dbc1 /testsuite
parent4c4e4012db96aee7ef236c0684690842fb6a3e47 (diff)
downloadltrace-e8701b4cc4333dbc5e3c683468fa8fb077977ba6.tar.gz
Move ltraceParamTest from parameters2.exp to ltrace.exp, name ltraceLibTest
Also, change the semantics: ltraceLibTest doesn't do matching anymore, but is a wrapper around several ltraceSource, ltraceCompile and ltraceRun. Matching is done by the callee. This allows us to choose the exact matcher to use.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/lib/ltrace.exp31
-rw-r--r--testsuite/ltrace.main/parameters2.exp37
2 files changed, 41 insertions, 27 deletions
diff --git a/testsuite/lib/ltrace.exp b/testsuite/lib/ltrace.exp
index cbb5602..b62508a 100644
--- a/testsuite/lib/ltrace.exp
+++ b/testsuite/lib/ltrace.exp
@@ -620,6 +620,37 @@ proc ltraceMatch {logfile patterns} {
return
}
+# ltraceLibTest --
+#
+# Generate a binary, a library (liblib.so) and a config file.
+# Run the binary using ltraceRun, passing it -F to load the
+# config file.
+#
+# Arguments:
+# conf Contents of ltrace config file.
+#
+# cdecl Contents of header file.
+#
+# libcode Contents of library implementation file.
+#
+# maincode Contents of function "main".
+#
+# params Additional parameters to pass to ltraceRun.
+#
+# Results:
+#
+# Returns whatever ltraceRun returns.
+
+proc ltraceLibTest {conf cdecl libcode maincode {params ""}} {
+ set conffile [ltraceSource conf $conf]
+ set lib [ltraceCompile liblib.so [ltraceSource c [concat $cdecl $libcode]]]
+ set bin [ltraceCompile {} $lib \
+ [ltraceSource c \
+ [concat $cdecl "int main(void) {" $maincode "}"]]]
+
+ return [eval [concat "ltraceRun -F $conffile " $params "-- $bin"]]
+}
+
#
# ltrace_options OPTIONS_LIST
# Pass ltrace commandline options.
diff --git a/testsuite/ltrace.main/parameters2.exp b/testsuite/ltrace.main/parameters2.exp
index 9e3b30e..c200e36 100644
--- a/testsuite/ltrace.main/parameters2.exp
+++ b/testsuite/ltrace.main/parameters2.exp
@@ -119,20 +119,9 @@ ltraceMatch1 [ltraceRun -F $conf -e ll -A 5 \
}
}]]] {->ll\({ 9, { 8, { 7, { 6, { 5, \.\.\. } } } } }\) *= <void>} == 1
-proc ltraceParamTest {conf cdecl libcode maincode match {params ""}} {
- set conffile [ltraceSource conf $conf]
- set lib [ltraceCompile liblib.so [ltraceSource c [concat $cdecl $libcode]]]
- set bin [ltraceCompile {} $lib \
- [ltraceSource c \
- [concat $cdecl "int main(void) {" $maincode "}"]]]
-
- set command [concat "ltraceRun -F $conffile " $params "-- $bin"]
- return [ltraceMatch [eval $command] $match]
-}
-
# Test using lens in typedef.
-ltraceParamTest {
+ltraceMatch1 [ltraceLibTest {
typedef hexptr = hex(uint*);
void fun(hexptr);
} {
@@ -142,13 +131,11 @@ ltraceParamTest {
} {
unsigned u = 0x123;
fun(&u);
-} {
- {{fun\(0x123\) *= <void>} == 1}
-}
+}] {fun\(0x123\) *= <void>} == 1
# Test support for bitvec lens.
-ltraceParamTest {
+ltraceMatch [ltraceLibTest {
void fun(bitvec(uint));
void fun2(bitvec(array(char, 32)*));
} {
@@ -167,7 +154,7 @@ ltraceParamTest {
bytes[1] = 0xff;
bytes[31] = 0x80;
fun2(bytes);
-} {
+}] {
{{fun\(<>\) *= <void>} == 1}
{{fun\(<0-1,5,8>\) *= <void>} == 1}
{{fun\(~<0>\) *= <void>} == 1}
@@ -177,7 +164,7 @@ ltraceParamTest {
# Test support for hex(float), hex(double).
-ltraceParamTest {
+ltraceMatch [ltraceLibTest {
hex(float) hex_float(hex(float));
hex(double) hex_double(hex(double));
} {
@@ -189,14 +176,14 @@ ltraceParamTest {
} {
hex_float(1.5);
hex_double(1.5);
-} {
+}] {
{{hex_float\(0x1.8p\+0\) *= 0x1.4p\+1} == 1}
{{hex_double\(0x1.8p\+0\) *= 0x1.4p\+1} == 1}
}
# Test that "addr" is recognized.
-ltraceParamTest {
+ltraceMatch1 [ltraceLibTest {
void fun(addr);
} {
#include <stdint.h>
@@ -205,14 +192,12 @@ ltraceParamTest {
void fun(uintptr_t u) {}
} {
fun(0x1234);
-} {
- {{fun\(0x1234\) *= <void>} == 1}
-}
+}] {fun\(0x1234\) *= <void>} == 1
# Test that -x fun can find "fun" prototype even if "fun" is in a
# library.
-ltraceParamTest {
+ltraceMatch1 [ltraceLibTest {
void fun();
} {
void libfun(void);
@@ -222,9 +207,7 @@ ltraceParamTest {
} {
libfun();
} {
- {{fun@.*\(\)} == 1}
-} {
-L -x fun
-}
+}] {fun@.*\(\)} == 1
ltraceDone