1 # Copyright (C) 2000 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 { pattern args } {
23 # This assumes that we are two frames down from dg-test, and that
24 # it still stores the filename of the testcase in a local variable "name".
25 # A cleaner solution would require a new dejagnu release.
26 set testcase [uplevel 2 { expr { $name } }]
28 # This must match the rule in gcc-dg.exp.
29 set output_file "[file rootname [file tail $testcase]].s"
31 set fd [open $output_file r]
35 set vmessage [concat $args]
36 if { $vmessage == ""} {
40 if [regexp -- $pattern $text] {
41 pass "$testcase scan-assembler $vmessage"
43 fail "$testcase scan-assembler $vmessage"
47 # Call pass if pattern is not present, otherwise fail.
48 proc scan-assembler-not { pattern args } {
49 set testcase [uplevel 2 { expr { $name } }]
50 set output_file "[file rootname [file tail $testcase]].s"
52 set fd [open $output_file r]
56 set vmessage [concat $args]
57 if { $vmessage == ""} {
61 if ![regexp -- $pattern $text] {
62 pass "$testcase scan-assembler-not $vmessage"
64 fail "$testcase scan-assembler-not $vmessage"
68 # Utility for scanning demangled compiler result, invoked via dg-final.
69 # Call pass if pattern is present, otherwise fail.
70 proc scan-assembler-dem { pattern args } {
74 # Find c++filt like we find g++ in g++.exp.
75 if ![info exists cxxfilt] {
76 set cxxfilt [findfile $base_dir/../c++filt $base_dir/../c++filt \
77 [findfile $base_dir/c++filt $base_dir/c++filt \
79 verbose -log "c++filt is $cxxfilt"
82 set testcase [uplevel 2 { expr { $name } }]
83 set output_file "[file rootname [file tail $testcase]].s"
85 set fd [open "| $cxxfilt < $output_file" r]
89 set vmessage [concat $args]
90 if { $vmessage == ""} {
94 if [regexp -- $pattern $text] {
95 pass "$testcase scan-assembler $vmessage"
97 fail "$testcase scan-assembler $vmessage"
101 # Call pass if demangled pattern is not present, otherwise fail.
102 proc scan-assembler-dem-not { pattern args } {
106 # Find c++filt like we find g++ in g++.exp.
107 if ![info exists cxxfilt] {
108 set cxxfilt [findfile $base_dir/../c++filt $base_dir/../c++filt \
109 [findfile $base_dir/c++filt $base_dir/c++filt \
110 [transform c++filt]]]
111 verbose -log "c++filt is $cxxfilt"
114 set testcase [uplevel 2 { expr { $name } }]
115 set output_file "[file rootname [file tail $testcase]].s"
117 set fd [open "| $cxxfilt < $output_file" r]
121 set vmessage [concat $args]
122 if { $vmessage == ""} {
123 set vmessage $pattern
126 if ![regexp -- $pattern $text] {
127 pass "$testcase scan-assembler-not $vmessage"
129 fail "$testcase scan-assembler-not $vmessage"