filters.exp revision 85761852f44864ba3f92be2cfdd67af2e02f093e
1# Copyright (C) 2012 Petr Machata, Red Hat Inc.
2
3set testfile "filt"
4set srcfile0 $srcdir/$subdir/$testfile.c
5set binfile0 $objdir/$subdir/$testfile
6set base1 "filt1"
7set srcfile1 $srcdir/$subdir/$base1.c
8set binfile1 $objdir/$subdir/lib$base1.so
9set base2 "filt2"
10set srcfile2 $srcdir/$subdir/$base2.c
11set binfile2 $objdir/$subdir/lib$base2.so
12
13if [get_compiler_info $binfile0] {
14  return -1
15}
16
17verbose "compiling source file now....."
18if { [ltrace_compile_shlib $srcfile2 $binfile2 debug ] != ""
19  || [ltrace_compile_shlib $srcfile1 $binfile1 debug ] != ""
20  || [ltrace_compile $srcfile0 $binfile0 executable [list debug shlib=$binfile1 shlib=$binfile2] ] != ""} {
21  send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
22}
23
24ltrace_options "-e*"
25set exec_output [ltrace_runtest $objdir/$subdir $binfile0]
26
27# Check the output of this program.
28verbose "ltrace runtest output: $exec_output\n"
29if [regexp {ELF from incompatible architecture} $exec_output] {
30	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
31	return
32} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
33	fail "Couldn't get .hash data!"
34	return
35}
36
37ltrace_verify_output ${binfile0}.ltrace "filt->func1" 1
38ltrace_verify_output ${binfile0}.ltrace "libfilt1.so->func2" 1
39ltrace_verify_output ${binfile0}.ltrace "libfilt2.so->puts" 1
40ltrace_verify_output ${binfile0}.ltrace "func2 resumed" 1
41ltrace_verify_output ${binfile0}.ltrace "func1 resumed" 1
42
43# I simply can't figure out how to pass an empty string to
44# ltrace_options without that getting interpreted as {}, so pass
45# something harmless instead.
46ltrace_options "-b"
47ltrace_runtest $objdir/$subdir $binfile0
48ltrace_verify_output ${binfile0}.ltrace "^func1(.*)" 1
49
50ltrace_options "-e@MAIN"
51ltrace_runtest $objdir/$subdir $binfile0
52ltrace_verify_output ${binfile0}.ltrace "filt->func1(.*)" 1
53
54ltrace_options "-e@libfilt1.so"
55ltrace_runtest $objdir/$subdir $binfile0
56ltrace_verify_output ${binfile0}.ltrace "libfilt1.so->func2(.*)" 1
57
58ltrace_options "-e@libfilt2.so"
59ltrace_runtest $objdir/$subdir $binfile0
60ltrace_verify_output ${binfile0}.ltrace "libfilt2.so->puts(.*)" 1
61
62ltrace_options "-e@libfilt*"
63ltrace_runtest $objdir/$subdir $binfile0
64ltrace_verify_output ${binfile0}.ltrace "libfilt1.so->func2(" 1
65ltrace_verify_output ${binfile0}.ltrace "libfilt2.so->puts(.*)" 1
66ltrace_verify_output ${binfile0}.ltrace "func2 resumed" 1
67
68ltrace_options "-efunc*"
69ltrace_runtest $objdir/$subdir $binfile0
70ltrace_verify_output ${binfile0}.ltrace "filt->func1(" 1
71ltrace_verify_output ${binfile0}.ltrace "libfilt1.so->func2(.*)" 1
72ltrace_verify_output ${binfile0}.ltrace "func1 resumed" 1
73
74# Check that we handle breakpoint on both PLT entry and entry point
75ltrace_options "-efunc1" "-xfunc1"
76ltrace_runtest $objdir/$subdir $binfile0
77ltrace_verify_output ${binfile0}.ltrace "filt->func1(" 1
78ltrace_verify_output ${binfile0}.ltrace "func1@libfilt1.so(.*)" 1
79ltrace_verify_output ${binfile0}.ltrace "func1 resumed" 1
80
81# Check that when given -l, we don't trace symbols from other
82# libraries.
83ltrace_options "-llibfilt1.so"
84ltrace_runtest $objdir/$subdir $binfile0
85ltrace_verify_output ${binfile0}.ltrace "filt->func1(.*)" 1
86
87ltrace_options "-llibfilt1.so" "-llibfilt2.so"
88ltrace_runtest $objdir/$subdir $binfile0
89ltrace_verify_output ${binfile0}.ltrace "filt->func1(" 1
90ltrace_verify_output ${binfile0}.ltrace "libfilt1.so->func2(.*)" 1
91ltrace_verify_output ${binfile0}.ltrace "func1 resumed" 1
92