attach-process.exp revision aee093126654f722523b47848a0c5449e39cf4bb
1# This file was written by Yao Qi <qiyao@cn.ibm.com>.
2
3set testfile "attach-process"
4set srcfile ${testfile}.c
5set binfile ${testfile}
6
7verbose "compiling source file now....."
8# Build the shared libraries this test case needs.
9if  { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.c" "${srcdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
10     send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
11}
12
13# Run the program and get PID of it.
14catch "exec $srcdir/$subdir/$binfile &" output
15
16# get PID from ps output.
17regexp {([0-9]+)} $output match PID
18verbose "PID = $PID"
19
20# Run PUT for ltrace.
21global LTRACE
22catch "exec $LTRACE -S -p $PID -o ${srcdir}/${subdir}/${testfile}.ltrace" exec_output
23
24# Check the output of this program.
25verbose "ltrace runtest output: $exec_output\n"
26if [regexp {ELF from incompatible architecture} $exec_output] {
27	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
28     	return
29} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
30	fail "Couldn't get .hash data!"
31	return
32}
33
34# Verify the output in attach-process.ltrace by checking the number
35# of sleep.
36set pattern "sleep"
37ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
38
39