1 # Copyright (C) 2000, 2002 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Various utilities for scanning assembler output, used by gcc-dg.exp and
20 # Utility for scanning compiler result, invoked via dg-final.
21 # Call pass if pattern is present, otherwise fail.
22 proc scan-assembler { args } {
23 if { [llength $args] < 1 } {
24 error "scan-assembler: too few arguments"
27 if { [llength $args] > 2 } {
28 error "scan-assembler: too many arguments"
31 if { [llength $args] >= 2 } {
32 switch [dg-process-target [lindex $args 1]] {
35 "F" { setup_xfail "*-*-*" }
40 # This assumes that we are two frames down from dg-test, and that
41 # it still stores the filename of the testcase in a local variable "name".
42 # A cleaner solution would require a new dejagnu release.
45 # This must match the rule in gcc-dg.exp.
46 set output_file "[file rootname [file tail $testcase]].s"
48 set fd [open $output_file r]
52 if [regexp -- [lindex $args 0] $text] {
53 pass "$testcase scan-assembler [lindex $args 0]"
55 fail "$testcase scan-assembler [lindex $args 0]"
59 # Call pass if pattern is present given number of times, otherwise fail.
60 proc scan-assembler-times { args } {
61 if { [llength $args] < 2 } {
62 error "scan-assembler: too few arguments"
65 if { [llength $args] > 3 } {
66 error "scan-assembler: too many arguments"
69 if { [llength $args] >= 3 } {
70 switch [dg-process-target [lindex $args 2]] {
73 "F" { setup_xfail "*-*-*" }
78 # This assumes that we are two frames down from dg-test, and that
79 # it still stores the filename of the testcase in a local variable "name".
80 # A cleaner solution would require a new dejagnu release.
83 # This must match the rule in gcc-dg.exp.
84 set output_file "[file rootname [file tail $testcase]].s"
86 set fd [open $output_file r]
90 if { [llength [regexp -inline -all -- [lindex $args 0] $text]] == [lindex $args 1]} {
91 pass "$testcase scan-assembler-times [lindex $args 0] [lindex $args 1]"
93 fail "$testcase scan-assembler-times [lindex $args 0] [lindex $args 1]"
97 # Call pass if pattern is not present, otherwise fail.
98 proc scan-assembler-not { args } {
99 if { [llength $args] < 1 } {
100 error "scan-assembler-not: too few arguments"
103 if { [llength $args] > 2 } {
104 error "scan-assembler-not: too many arguments"
107 if { [llength $args] >= 2 } {
108 switch [dg-process-target [lindex $args 1]] {
111 "F" { setup_xfail "*-*-*" }
116 upvar 2 name testcase
117 set output_file "[file rootname [file tail $testcase]].s"
119 set fd [open $output_file r]
123 if ![regexp -- [lindex $args 0] $text] {
124 pass "$testcase scan-assembler-not [lindex $args 0]"
126 fail "$testcase scan-assembler-not [lindex $args 0]"
130 # Utility for scanning demangled compiler result, invoked via dg-final.
131 # Call pass if pattern is present, otherwise fail.
132 proc scan-assembler-dem { args } {
136 if { [llength $args] < 1 } {
137 error "scan-assembler-dem: too few arguments"
140 if { [llength $args] > 2 } {
141 error "scan-assembler-dem: too many arguments"
144 if { [llength $args] >= 2 } {
145 switch [dg-process-target [lindex $args 1]] {
148 "F" { setup_xfail "*-*-*" }
153 # Find c++filt like we find g++ in g++.exp.
154 if ![info exists cxxfilt] {
155 set cxxfilt [findfile $base_dir/../../binutils/cxxfilt \
156 $base_dir/../../binutils/cxxfilt \
157 [findfile $base_dir/../c++filt $base_dir/../c++filt \
158 [findfile $base_dir/c++filt $base_dir/c++filt \
159 [transform c++filt]]]]
160 verbose -log "c++filt is $cxxfilt"
163 upvar 2 name testcase
164 set output_file "[file rootname [file tail $testcase]].s"
166 set fd [open "| $cxxfilt < $output_file" r]
170 if [regexp -- [lindex $args 0] $text] {
171 pass "$testcase scan-assembler-dem [lindex $args 0]"
173 fail "$testcase scan-assembler-dem [lindex $args 0]"
177 # Call pass if demangled pattern is not present, otherwise fail.
178 proc scan-assembler-dem-not { args } {
182 if { [llength $args] < 1 } {
183 error "scan-assembler-dem-not: too few arguments"
186 if { [llength $args] > 2 } {
187 error "scan-assembler-dem-not: too many arguments"
190 if { [llength $args] >= 2 } {
191 switch [dg-process-target [lindex $args 1]] {
194 "F" { setup_xfail "*-*-*" }
199 # Find c++filt like we find g++ in g++.exp.
200 if ![info exists cxxfilt] {
201 set cxxfilt [findfile $base_dir/../../binutils/cxxfilt \
202 $base_dir/../../binutils/cxxfilt \
203 [findfile $base_dir/../c++filt $base_dir/../c++filt \
204 [findfile $base_dir/c++filt $base_dir/c++filt \
205 [transform c++filt]]]]
206 verbose -log "c++filt is $cxxfilt"
209 upvar 2 name testcase
210 set output_file "[file rootname [file tail $testcase]].s"
212 set fd [open "| $cxxfilt < $output_file" r]
216 if ![regexp -- [lindex $args 0] $text] {
217 pass "$testcase scan-assembler-dem-not [lindex $args 0]"
219 fail "$testcase scan-assembler-dem-not [lindex $args 0]"