1 # Copyright (C) 2000, 2002, 2003 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 tree dump output, used by gcc-dg.exp and
20 # This is largely borrowed from scanasm.exp.
22 # Utility for scanning compiler result, invoked via dg-final.
23 # Call pass if pattern is present, otherwise fail.
25 # Argument 0 is the regexp to match.
26 # Argument 1 is the suffix for the tree dump file
27 # Argument 2 handles expected failures and the like
28 proc scan-tree-dump { args } {
29 if { [llength $args] < 2 } {
30 error "scan-tree-dump: too few arguments"
33 if { [llength $args] > 3 } {
34 error "scan-tree-dump: too many arguments"
37 if { [llength $args] >= 3 } {
38 switch [dg-process-target [lindex $args 2]] {
41 "F" { setup_xfail "*-*-*" }
46 # This assumes that we are two frames down from dg-test, and that
47 # it still stores the filename of the testcase in a local variable "name".
48 # A cleaner solution would require a new dejagnu release.
51 # This must match the rule in gcc-dg.exp.
52 set src [file tail [lindex $testcase 0]]
53 set output_file "[glob $src.t??.[lindex $args 1]]"
55 set fd [open $output_file r]
59 if [regexp -- [lindex $args 0] $text] {
60 pass "$testcase scan-tree-dump [lindex $args 0]"
62 fail "$testcase scan-tree-dump [lindex $args 0]"
66 # Call pass if pattern is present given number of times, otherwise fail.
67 # Argument 0 is the regexp to match.
68 # Argument 1 is number of times the regexp must be found
69 # Argument 2 is the suffix for the tree dump file
70 # Argument 3 handles expected failures and the like
71 proc scan-tree-dump-times { args } {
72 if { [llength $args] < 3 } {
73 error "scan-tree-dump: too few arguments"
76 if { [llength $args] > 4 } {
77 error "scan-tree-dump: too many arguments"
80 if { [llength $args] >= 4 } {
81 switch [dg-process-target [lindex $args 3]] {
84 "F" { setup_xfail "*-*-*" }
89 # This assumes that we are two frames down from dg-test, and that
90 # it still stores the filename of the testcase in a local variable "name".
91 # A cleaner solution would require a new dejagnu release.
94 # This must match the rule in gcc-dg.exp.
95 set src [file tail [lindex $testcase 0]]
96 set output_file "[glob $src.t??.[lindex $args 2]]"
98 set fd [open $output_file r]
102 if { [llength [regexp -inline -all -- [lindex $args 0] $text]] == [lindex $args 1]} {
103 pass "$testcase scan-tree-dump-times [lindex $args 0] [lindex $args 1]"
105 fail "$testcase scan-tree-dump-times [lindex $args 0] [lindex $args 1]"
109 # Call pass if pattern is not present, otherwise fail.
111 # Argument 0 is the regexp to match.
112 # Argument 1 is the suffix for the tree dump file
113 # Argument 2 handles expected failures and the like
114 proc scan-tree-dump-not { args } {
115 if { [llength $args] < 2 } {
116 error "scan-tree-dump-not: too few arguments"
119 if { [llength $args] > 3 } {
120 error "scan-tree-dump-not: too many arguments"
123 if { [llength $args] >= 3 } {
124 switch [dg-process-target [lindex $args 2]] {
127 "F" { setup_xfail "*-*-*" }
132 upvar 2 name testcase
133 set src [file tail [lindex $testcase 0]]
134 set output_file "[glob $src.t??.[lindex $args 1]]"
136 set fd [open $output_file r]
140 if ![regexp -- [lindex $args 0] $text] {
141 pass "$testcase scan-tree-dump-not [lindex $args 0]"
143 fail "$testcase scan-tree-dump-not [lindex $args 0]"
147 # Utility for scanning demangled compiler result, invoked via dg-final.
148 # Call pass if pattern is present, otherwise fail.
150 # Argument 0 is the regexp to match.
151 # Argument 1 is the suffix for the tree dump file
152 # Argument 2 handles expected failures and the like
153 proc scan-tree-dump-dem { args } {
157 if { [llength $args] < 2 } {
158 error "scan-tree-dump-dem: too few arguments"
161 if { [llength $args] > 3 } {
162 error "scan-tree-dump-dem: too many arguments"
165 if { [llength $args] >= 3 } {
166 switch [dg-process-target [lindex $args 2]] {
169 "F" { setup_xfail "*-*-*" }
174 # Find c++filt like we find g++ in g++.exp.
175 if ![info exists cxxfilt] {
176 set cxxfilt [findfile $base_dir/../../binutils/cxxfilt \
177 $base_dir/../../binutils/cxxfilt \
178 [findfile $base_dir/../c++filt $base_dir/../c++filt \
179 [findfile $base_dir/c++filt $base_dir/c++filt \
180 [transform c++filt]]]]
181 verbose -log "c++filt is $cxxfilt"
184 upvar 2 name testcase
185 set src [file tail [lindex $testcase 0]]
186 set output_file "[glob $src.t??.[lindex $args 1]]"
188 set fd [open "| $cxxfilt < $output_file" r]
192 if [regexp -- [lindex $args 0] $text] {
193 pass "$testcase scan-tree-dump-dem [lindex $args 0]"
195 fail "$testcase scan-tree-dump-dem [lindex $args 0]"
199 # Call pass if demangled pattern is not present, otherwise fail.
201 # Argument 0 is the regexp to match.
202 # Argument 1 is the suffix for the tree dump file
203 # Argument 2 handles expected failures and the like
204 proc scan-tree-dump-dem-not { args } {
208 if { [llength $args] < 2 } {
209 error "scan-tree-dump-dem-not: too few arguments"
212 if { [llength $args] > 3 } {
213 error "scan-tree-dump-dem-not: too many arguments"
216 if { [llength $args] >= 3 } {
217 switch [dg-process-target [lindex $args 2]] {
220 "F" { setup_xfail "*-*-*" }
225 # Find c++filt like we find g++ in g++.exp.
226 if ![info exists cxxfilt] {
227 set cxxfilt [findfile $base_dir/../../binutils/cxxfilt \
228 $base_dir/../../binutils/cxxfilt \
229 [findfile $base_dir/../c++filt $base_dir/../c++filt \
230 [findfile $base_dir/c++filt $base_dir/c++filt \
231 [transform c++filt]]]]
232 verbose -log "c++filt is $cxxfilt"
235 upvar 2 name testcase
236 set src [file tail [lindex $testcase 0]]
237 set output_file "[glob $src.t??.[lindex $args 1]]"
239 set fd [open "| $cxxfilt < $output_file" r]
243 if ![regexp -- [lindex $args 0] $text] {
244 pass "$testcase scan-tree-dump-dem-not [lindex $args 0]"
246 fail "$testcase scan-tree-dump-dem-not [lindex $args 0]"