1# This file is part of ltrace.
2# Copyright (C) 2012 Petr Machata, Red Hat Inc.
3#
4# This program is free software; you can redistribute it and/or
5# modify it under the terms of the GNU General Public License as
6# published by the Free Software Foundation; either version 2 of the
7# License, or (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12# General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17# 02110-1301 USA
18
19set testfile "branch_func"
20set srcfile ${testfile}.c
21set binfile ${testfile}
22
23if [get_compiler_info $binfile] {
24  return -1
25}
26
27verbose "compiling source file now....."
28if { [ltrace_compile $srcdir/$subdir/$srcfile $objdir/$subdir/$binfile executable {debug} ] != "" } {
29     send_user "Testcase compile failed, so all tests in this file will automatically fail\n."
30}
31
32# set options for ltrace.
33ltrace_options "-x" "func1" "-x" "func2" "-x" "func3"
34
35# Run PUT for ltarce.
36set exec_output [ltrace_runtest $objdir/$subdir $objdir/$subdir/$binfile]
37
38# Check the output of this program.
39verbose "ltrace runtest output: $exec_output\n"
40if [regexp {ELF from incompatible architecture} $exec_output] {
41	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
42	return
43} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
44	fail "Couldn't get .hash data!"
45	return
46}
47
48set pattern "func1(.*unfinished"
49ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 100
50set pattern "func2(.*unfinished"
51ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 100
52set pattern "func3(.*)"
53ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 100
54set pattern "func2.resumed"
55ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 100
56set pattern "func1.resumed"
57ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 100
58