summaryrefslogtreecommitdiff
path: root/testsuite/ltrace.main/parameters2.exp
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/ltrace.main/parameters2.exp')
-rw-r--r--testsuite/ltrace.main/parameters2.exp95
1 files changed, 71 insertions, 24 deletions
diff --git a/testsuite/ltrace.main/parameters2.exp b/testsuite/ltrace.main/parameters2.exp
index 8443fb6..6318fc5 100644
--- a/testsuite/ltrace.main/parameters2.exp
+++ b/testsuite/ltrace.main/parameters2.exp
@@ -1,5 +1,5 @@
# This file is part of ltrace.
-# Copyright (C) 2012 Petr Machata, Red Hat Inc.
+# Copyright (C) 2012, 2013 Petr Machata, Red Hat Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -27,6 +27,11 @@ ltraceMatch1 [ltraceRun -L -F [ltraceSource conf {
}] -- $trivial] "error" == 0
ltraceMatch1 [ltraceRun -L -F [ltraceSource conf {
+ typedef char_blah = char;
+ void blah(char_blah);
+}] -- $trivial] "error" == 0
+
+ltraceMatch1 [ltraceRun -L -F [ltraceSource conf {
typedef aa = int;
typedef aa = int;
}] -- $trivial] "error" != 0
@@ -119,20 +124,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 +136,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 +159,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 +169,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,15 +181,28 @@ 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.
+
+ltraceMatch1 [ltraceLibTest {
+ void fun(addr);
+} {
+ #include <stdint.h>
+ void fun(uintptr_t u);
+} {
+ void fun(uintptr_t u) {}
+} {
+ fun(0x1234);
+}] {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);
@@ -207,9 +212,51 @@ ltraceParamTest {
} {
libfun();
} {
- {{fun@.*\(\)} == 1}
-} {
-L -x fun
-}
+}] {fun@.*\(\)} == 1
+
+
+# Test that %p format specifier does not crash
+
+ltraceMatch1 [ltraceLibTest {
+ void print_ptr(format);
+} {
+ void print_ptr(const char *format, ...);
+} {
+ void print_ptr(const char *format, ...) { }
+} {
+ void *addr = (void *)0x42;
+ print_ptr("%p\n", addr);
+}] {print_ptr\("%p\\n", 0x42\) *= <void>} == 1
+
+
+# Test that zero(EXPR) does not leak memory (needs valgrind)
+
+ltraceMatch1 [ltraceLibTest {
+ typedef String = string(array(char, zero(256)));
+ String *get_string();
+} {
+ char *get_string();
+} {
+ char *get_string() {
+ return "FOO";
+ }
+} {
+ get_string();
+}] {get_string\(\) *= "FOO"} == 1
+
+# Test that void* NULL's are displayed as "nil" as well.
+
+ltraceMatch1 [ltraceLibTest {
+ addr somefunc();
+} {
+ void *somefunc(void);
+} {
+ void *somefunc(void) {
+ return 0;
+ }
+} {
+ somefunc();
+}] {somefunc\(\) *= nil} == 1
ltraceDone