]> gcc.gnu.org Git - gcc.git/blob - gcc/testsuite/lib/scanasm.exp
e1e1fadaeb953e0a24158f703676985312cefa29
[gcc.git] / gcc / testsuite / lib / scanasm.exp
1 # Copyright (C) 2000 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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.
16
17 # Various utilities for scanning assembler output, used by gcc-dg.exp and
18 # g++-dg.exp.
19
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 } }]
27
28 # This must match the rule in gcc-dg.exp.
29 set output_file "[file rootname [file tail $testcase]].s"
30
31 set fd [open $output_file r]
32 set text [read $fd]
33 close $fd
34
35 set vmessage [concat $args]
36 if { $vmessage == ""} {
37 set vmessage $pattern
38 }
39
40 if [regexp -- $pattern $text] {
41 pass "$testcase scan-assembler $vmessage"
42 } else {
43 fail "$testcase scan-assembler $vmessage"
44 }
45 }
46
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"
51
52 set fd [open $output_file r]
53 set text [read $fd]
54 close $fd
55
56 set vmessage [concat $args]
57 if { $vmessage == ""} {
58 set vmessage $pattern
59 }
60
61 if ![regexp -- $pattern $text] {
62 pass "$testcase scan-assembler-not $vmessage"
63 } else {
64 fail "$testcase scan-assembler-not $vmessage"
65 }
66 }
67
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 } {
71 global cxxfilt
72 global base_dir
73
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 \
78 [transform c++filt]]]
79 verbose -log "c++filt is $cxxfilt"
80 }
81
82 set testcase [uplevel 2 { expr { $name } }]
83 set output_file "[file rootname [file tail $testcase]].s"
84
85 set fd [open "| $cxxfilt < $output_file" r]
86 set text [read $fd]
87 close $fd
88
89 set vmessage [concat $args]
90 if { $vmessage == ""} {
91 set vmessage $pattern
92 }
93
94 if [regexp -- $pattern $text] {
95 pass "$testcase scan-assembler $vmessage"
96 } else {
97 fail "$testcase scan-assembler $vmessage"
98 }
99 }
100
101 # Call pass if demangled pattern is not present, otherwise fail.
102 proc scan-assembler-dem-not { pattern args } {
103 global cxxfilt
104 global base_dir
105
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"
112 }
113
114 set testcase [uplevel 2 { expr { $name } }]
115 set output_file "[file rootname [file tail $testcase]].s"
116
117 set fd [open "| $cxxfilt < $output_file" r]
118 set text [read $fd]
119 close $fd
120
121 set vmessage [concat $args]
122 if { $vmessage == ""} {
123 set vmessage $pattern
124 }
125
126 if ![regexp -- $pattern $text] {
127 pass "$testcase scan-assembler-not $vmessage"
128 } else {
129 fail "$testcase scan-assembler-not $vmessage"
130 }
131 }
This page took 0.041997 seconds and 4 git commands to generate.