]>
Commit | Line | Data |
---|---|---|
f70a4714 KR |
1 | # Copyright (C) 1993 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
16 | ||
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # [email protected] | |
19 | ||
20 | # This file was written by Ken Raeburn ([email protected]). | |
21 | ||
22 | proc gas_version {} { | |
23 | global AS | |
fd9b8885 | 24 | catch "exec $AS -version < /dev/null" tmp |
f70a4714 KR |
25 | # Should find a way to discard constant parts, keep whatever's |
26 | # left, so the version string could be almost anything at all... | |
23c6150b | 27 | regexp "version (cygnus-|)\[-0-9.a-zA-Z-\]+" $tmp version |
f70a4714 | 28 | set tmp $version |
23c6150b | 29 | clone_output "[which $AS] $version\n" |
f70a4714 KR |
30 | unset tmp |
31 | unset version | |
32 | } | |
33 | ||
fd9b8885 | 34 | proc gas_run { prog as_opts redir } { |
f70a4714 KR |
35 | global AS |
36 | global ASFLAGS | |
37 | global comp_output | |
fd9b8885 RS |
38 | global srcdir |
39 | global subdir | |
f70a4714 | 40 | |
fd9b8885 RS |
41 | verbose "Executing $AS $ASFLAGS $as_opts $prog $redir" |
42 | catch "exec $srcdir/lib/run $AS $ASFLAGS $as_opts $srcdir/$subdir/$prog $redir" comp_output | |
43 | } | |
44 | ||
45 | proc all_ones { args } { | |
46 | foreach x $args { if [expr $x!=1] { return 0 } } | |
47 | return 1 | |
48 | } | |
49 | ||
50 | proc gas_start { prog as_opts } { | |
51 | global AS | |
52 | global ASFLAGS | |
53 | global srcdir | |
54 | global subdir | |
55 | global spawn_id | |
56 | ||
57 | verbose "Starting $AS $ASFLAGS $as_opts $prog" 2 | |
58 | catch { | |
59 | spawn -noecho -nottyinit $srcdir/lib/run $AS $ASFLAGS $as_opts $srcdir/$subdir/$prog | |
60 | } foo | |
61 | if ![regexp {^[0-9]+} $foo] then { | |
62 | error "Can't run $subdir/$prog: $foo" | |
f70a4714 | 63 | } |
fd9b8885 RS |
64 | } |
65 | ||
66 | proc gas_finish { } { | |
67 | global spawn_id | |
68 | ||
69 | # Don't need to do anything? | |
70 | } | |
71 | ||
72 | proc want_no_output { testname } { | |
73 | global comp_output | |
74 | ||
f70a4714 KR |
75 | if ![string match "" $comp_output] then { |
76 | send_log "$comp_output\n" | |
fd9b8885 RS |
77 | verbose "$comp_output" 3 |
78 | } | |
79 | if [string match "" $comp_output] then { | |
80 | pass "$testname" | |
81 | return 1 | |
82 | } else { | |
83 | fail "$testname" | |
84 | return 0 | |
85 | } | |
86 | } | |
87 | ||
88 | proc gas_test_old { file as_opts testname } { | |
89 | gas_run $file $as_opts "" | |
90 | return [want_no_output $testname] | |
91 | } | |
92 | ||
93 | proc gas_test { file as_opts var_opts testname } { | |
94 | global comp_output | |
95 | ||
96 | set i 0 | |
97 | foreach word $var_opts { | |
98 | set ignore_stdout($i) [string match "*>" $word] | |
99 | set opt($i) [string trim $word {>}] | |
100 | incr i | |
101 | } | |
102 | set max [expr 1<<$i] | |
103 | for {set i 0} {[expr $i<$max]} {incr i} { | |
104 | set maybe_ignore_stdout "" | |
105 | set extra_opts "" | |
106 | for {set bit 0} {(1<<$bit)<$max} {incr bit} { | |
107 | set num [expr 1<<$bit] | |
108 | if [expr $i&$num] then { | |
109 | set extra_opts "$extra_opts $opt($bit)" | |
110 | if $ignore_stdout($bit) then { | |
111 | set maybe_ignore_stdout "1>/dev/null" | |
112 | } | |
113 | } | |
114 | } | |
115 | set extra_opts [string trim $extra_opts] | |
116 | gas_run $file "$as_opts $extra_opts" $maybe_ignore_stdout | |
117 | ||
118 | # Should I be able to use a conditional expression here? | |
119 | if [string match "" $extra_opts] then { | |
120 | want_no_output $testname | |
121 | } else { | |
122 | want_no_output "$testname ($extra_opts)" | |
f70a4714 KR |
123 | } |
124 | } | |
23c6150b RS |
125 | if [info exists errorInfo] then { |
126 | unset errorInfo | |
127 | } | |
f70a4714 KR |
128 | } |
129 | ||
fd9b8885 | 130 | proc gas_test_ignore_stdout { file as_opts testname } { |
f70a4714 KR |
131 | global comp_output |
132 | ||
fd9b8885 RS |
133 | gas_run $file $as_opts "2>&1 1>/dev/null" |
134 | want_no_output $testname | |
135 | } | |
136 | ||
137 | proc gas_test_error { file as_opts testname } { | |
138 | global comp_output | |
139 | ||
140 | gas_run $file $as_opts "2>&1 1>/dev/null" | |
f70a4714 KR |
141 | if ![string match "" $comp_output] then { |
142 | send_log "$comp_output\n" | |
fd9b8885 | 143 | verbose "$comp_output" 3 |
f70a4714 KR |
144 | } |
145 | if [string match "" $comp_output] then { | |
f70a4714 | 146 | fail "$testname" |
fd9b8885 RS |
147 | } else { |
148 | pass "$testname" | |
149 | } | |
150 | } | |
151 | ||
152 | proc gas_exit {} {} | |
153 | ||
154 | proc gas_init {} { | |
155 | global target_cpu | |
156 | global target_cpu_family | |
157 | global target_family | |
158 | global target_vendor | |
159 | global target_os | |
160 | global stdoptlist | |
161 | ||
162 | case "$target_cpu" in { | |
163 | "m68???" { set target_cpu_family m68k } | |
164 | "i[34]86" { set target_cpu_family i386 } | |
165 | default { set target_cpu_family $target_cpu } | |
f70a4714 | 166 | } |
fd9b8885 RS |
167 | |
168 | set target_family "$target_cpu_family-$target_vendor-$target_os" | |
169 | set stdoptlist "-a>" | |
170 | # Need to return an empty string. | |
171 | return | |
172 | } | |
173 | ||
174 | proc objdump_start_common { prog objdump_opts prefix } { | |
175 | global OBJDUMP | |
176 | global srcdir | |
177 | global spawn_id | |
178 | ||
179 | verbose "Starting $OBJDUMP $objdump_opts $prog" 2 | |
180 | catch { | |
181 | spawn -noecho -nottyinit $srcdir/lib/run $OBJDUMP $objdump_opts $prefix$prog | |
182 | } foo | |
183 | if ![regexp {^[0-9]+} $foo] then { | |
184 | error "Can't run $prog: $foo" | |
185 | } | |
186 | } | |
187 | ||
188 | proc objdump_start { prog opts } { | |
189 | global subdir | |
190 | global objdir | |
191 | objdump_start_common $prog $opts "$objdir/$subdir/" | |
192 | } | |
193 | ||
194 | proc objdump_start_no_subdir { prog opts } { | |
195 | objdump_start_common $prog $opts "" | |
196 | } | |
197 | ||
198 | proc objdump_finish { } { | |
199 | global spawn_id | |
200 | ||
201 | # Don't need to do anything? | |
202 | } | |
203 | ||
204 | expect_after { | |
205 | timeout { error "timeout" } | |
206 | "virtual memory exhausted" { error "virtual memory exhausted" } | |
207 | buffer_full { error "buffer full" } | |
208 | eof { error "eof" } | |
f70a4714 | 209 | } |