aboutsummaryrefslogtreecommitdiff
path: root/testsuite/ltrace.minor/trace-exec.exp
blob: 99145f50f36c54b1f0d10ac0c7178da071de403a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
set testfile "trace-exec"
set srcfile ${testfile}.c
set binfile ${testfile}

verbose "compiling first 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"
}

verbose "compiling second source file now....."
if  { [ ltrace_compile "${srcdir}/${subdir}/${testfile}1.c" "${objdir}/${subdir}/${binfile}1" 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 $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

#check the output of this program.
verbose "ltrace runtest output: $exec_output\n"
if [regexp {ELF from incompatible architecture} $exec_output] {
	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
	return
} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
	fail "Couldn't get .hash data!"
	return
}

ltrace_saveoutput "${exec_output}" ${objdir}/${subdir}/${testfile}.ltrace

# execl from first binary
ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace {"^execl"} 1
# puts from second binary
ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace {"^puts"} 1
# assume glibc and see we really trace both binaries
ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace {"^__libc_start_main"} 2