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 "ppc-lwarx"
20set srcfile ${testfile}.c
21set binfile ${testfile}
22
23if [get_compiler_info $binfile] {
24  return -1
25}
26
27if { [istarget powerpc*-*] } then {
28    verbose "compiling source file now....."
29    if { [ltrace_compile $srcdir/$subdir/$srcfile $objdir/$subdir/$binfile executable {debug} ] != "" } {
30	 send_user "Testcase compile failed, so all tests in this file will automatically fail\n."
31    }
32
33    # set options for ltrace.
34    ltrace_options "-x" "atomic_add" "-e" "!atoi"
35
36    # Run PUT for ltarce.
37    set exec_output [ltrace_runtest $objdir/$subdir $objdir/$subdir/$binfile]
38
39    # Check the output of this program.
40    verbose "ltrace runtest output: $exec_output\n"
41    if [regexp {ELF from incompatible architecture} $exec_output] {
42	    fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
43	    return
44    } elseif [ regexp {Couldn't get .hash data} $exec_output ] {
45	    fail "Couldn't get .hash data!"
46	    return
47    }
48
49    set pattern "atomic_add(.*, 5,.*)"
50    ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1
51    set pattern "atomic_add(.*, 10,.*)"
52    ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1
53    set pattern "atomic_add(.*, 15,.*)"
54    ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 1
55}
56