1
# `dg' general purpose testcase driver.
2
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3
# 2001, 2002, 2003 Free Software Foundation, Inc.
5
# This file is part of DejaGnu.
7
# DejaGnu is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
12
# DejaGnu is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
# General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with DejaGnu; if not, write to the Free Software Foundation,
19
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
# This file was written by Doug Evans (dje@cygnus.com).
23
# This file is based on old-dejagnu.exp. It is intended to be more extensible
24
# without incurring the overhead that old-dejagnu.exp can. All test framework
25
# commands appear in the testcase as "{ dg-xxx args ... }". We pull them out
26
# with one grep, and then run the function(s) named by "dg-xxx". When running
27
# dg-xxx, the line number that it occurs on is always passed as the first
28
# argument. We also support different kinds of tools via callbacks.
30
# The currently supported options are:
35
# dg-options "options ..." [{ target selector }]
36
# specify special options to pass to the tool (eg: compiler)
38
# dg-do do-what-keyword [{ target/xfail selector }]
39
# `do-what-keyword' is tool specific and is passed unchanged to
40
# ${tool}-dg-test. An example is gcc where `keyword' can be any of:
41
# preprocess|compile|assemble|link|run
42
# and will do one of: produce a .i, produce a .s, produce a .o,
43
# produce an a.out, or produce an a.out and run it (the default is
46
# dg-error regexp comment [{ target/xfail selector } [{.|0|linenum}]]
47
# indicate an error message <regexp> is expected on this line
48
# (the test fails if it doesn't occur)
49
# Linenum=0 for general tool messages (eg: -V arg missing).
50
# "." means the current line.
52
# dg-warning regexp comment [{ target/xfail selector } [{.|0|linenum}]]
53
# indicate a warning message <regexp> is expected on this line
54
# (the test fails if it doesn't occur)
56
# dg-bogus regexp comment [{ target/xfail selector } [{.|0|linenum}]]
57
# indicate a bogus error message <regexp> use to occur here
58
# (the test fails if it does occur)
60
# dg-build regexp comment [{ target/xfail selector }]
61
# indicate the build use to fail for some reason
62
# (errors covered here include bad assembler generated, tool crashes,
64
# (the test fails if it does occur)
66
# dg-excess-errors comment [{ target/xfail selector }]
67
# indicate excess errors are expected (any line)
68
# (this should only be used sparingly and temporarily)
70
# dg-output regexp [{ target selector }]
71
# indicate the expected output of the program is <regexp>
72
# (there may be multiple occurrences of this, they are concatenated)
74
# dg-final { tcl code }
75
# add some tcl code to be run at the end
76
# (there may be multiple occurrences of this, they are concatenated)
77
# (unbalanced braces must be \-escaped)
79
# "{ target selector }" is a list of expressions that determine whether the
80
# test succeeds or fails for a particular target, or in some cases whether the
81
# option applies for a particular target. If the case of `dg-do' it specifies
82
# whether the testcase is even attempted on the specified target.
84
# The target selector is always optional. The format is one of:
86
# { xfail *-*-* ... } - the test is expected to fail for the given targets
87
# { target *-*-* ... } - the option only applies to the given targets
89
# At least one target must be specified, use *-*-* for "all targets".
90
# At present it is not possible to specify both `xfail' and `target'.
91
# "native" may be used in place of "*-*-*".
95
# [ ... some complicated code ... ]
96
# return a; /* { dg-build "fatal" "ran out of spill regs" { xfail i386-*-* } } */
98
# In this example, the compiler use to crash on the "return a;" for some
99
# target and that it still does crash on i386-*-*. Admittedly, this is a
102
# ??? It might be possible to add additional optional arguments by having
103
# something like: { dg-error ".*syntax.*" "syntax error" { { foo 1 } ... } }
107
# ${tool}-dg-test testfile do-what-keyword extra-flags
109
# Run the test, be it compiler, assembler, or whatever.
111
# ${tool}-dg-prune target_triplet text
113
# Optional callback to delete output from the tool that can occur
114
# even in successful ("pass") situations and interfere with output
115
# pattern matching. This also gives the tool an opportunity to review
116
# the output and check for any conditions which indicate an "untested"
117
# or "unresolved" state. An example is if a testcase is too big and
118
# fills all available ram (which can happen for 16 bit cpus). The
119
# result is either the pruned text or
120
# "::untested|unresolved|unsupported::message"
121
# (eg: "::unsupported::memory full").
124
# 1) All runnable testcases must return 0 from main() for success.
125
# You can't rely on getting any return code from target boards, and the
126
# `exec' command says a program fails if it returns non-zero.
128
# Language independence is (theoretically) achieved by:
130
# 1) Using global $tool to indicate the language (eg: gcc, g++, gas, etc.).
131
# This should only be used to look up other objects. We don't want to
132
# have to add code for each new language that is supported. If this is
133
# done right, no code needs to be added here for each new language.
135
# 2) Passing tool options in as arguments.
137
# Earlier versions of ${tool}_start (eg: gcc_start) would only take the name
138
# of the file to compile as an argument. Newer versions accept a list of
139
# one or two elements, the second being a string of *all* options to pass
140
# to the tool. We require this facility.
144
# Try not to do anything else that makes life difficult.
146
# The normal way to write a testsuite is to have a .exp file containing:
148
# load_lib ${tool}-dg.exp
150
# dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/foo*]] ...
153
# Global state variables.
154
# The defaults are for GCC.
156
# The default do-what keyword.
157
set dg-do-what-default compile
159
# When dg-interpreter-batch-mode is 1, no execution test or excess error
160
# tests are performed.
161
set dg-interpreter-batch-mode 0
163
# Line number format. This is how line numbers appear in program output.
164
set dg-linenum-format ":%d:"
165
proc dg-format-linenum { linenum } {
166
global dg-linenum-format
167
return [format ${dg-linenum-format} $linenum]
170
# Useful subroutines.
172
# dg-get-options -- pick out the dg-xxx options in a testcase
174
# PROG is the file name of the testcase.
175
# The result is a list of options found.
177
# Example: For the following testcase:
179
# /* { dg-prms-id 1234 } */
180
# int foo { return 0; } /* { dg-build fatal "some comment" } */
184
# { dg-prms-id 1 1234 } { dg-build 2 fatal "some comment" }
186
proc dg-get-options { prog } {
189
set tmp [grep $prog "{\[ \t\]\+dg-\[-a-z\]\+\[ \t\]\+.*\[ \t\]\+}" line]
190
if ![string match "" $tmp] {
192
#send_user "Found: $i\n"
193
# FIXME: When to use "+" and "\+" isn't clear.
194
# Seems to me it took awhile to get this to work.
195
regexp "(\[0-9\]\+)\[ \t\]\+{\[ \t\]+(dg-\[-a-z\]+)\[ \t\]\+(.*)\[ \t\]+}\[^\}\]*(\n|$)" $i i line cmd args
196
#send_user "Found: $cmd $line $args\n"
197
append result " { $cmd $line $args }"
201
#send_user "Returning: $result\n"
206
# Process optional xfail/target arguments
208
# SELECTOR is "xfail target-triplet-1 ..." or "target target-triplet-1 ..."
209
# `target-triplet' may be "native".
210
# For xfail, the result is "F" (expected to Fail) if the current target is
211
# affected, otherwise "P" (expected to Pass).
212
# For target, the result is "S" (target is Selected) if the target is selected,
213
# otherwise "N" (target is Not selected).
215
proc dg-process-target { selector } {
216
global target_triplet
218
set isnative [isnative]
221
#send_user "dg-process-target: $selector\n"
223
set selector [string trim $selector]
224
if [regexp "^xfail " $selector] {
226
} elseif [regexp "^target " $selector] {
229
# The use of error here and in other dg-xxx utilities is intentional.
230
# dg-test will catch them and do the right thing.
231
error "syntax error in target selector \"$selector\""
234
# ??? This should work but it doesn't. tcl bug?
235
#if [regexp "^${what}(( \[^ \]+-\[^ \]+-\[^ \]+)|( native))+$" $selector tmp selector]
236
if [regexp "^${what}( \[^ \]+-\[^ \]+-\[^ \]+| native)+$" $selector] {
237
regsub "^${what} " $selector "" selector
238
#send_user "selector: $selector\n"
239
foreach triplet $selector {
240
if [string match $triplet $target_triplet] {
242
} elseif { $isnative && $triplet == "native" } {
247
error "syntax error in target selector \"$selector\""
250
if { $triplet_match } {
251
return [expr { $what == "xfail" ? "F" : "S" }]
253
return [expr { $what == "xfail" ? "P" : "N" }]
257
# Predefined user option handlers.
258
# The line number is always the first element.
259
# Note that each of these are varargs procs (they have an `args' argument).
260
# Tests for optional arguments are coded with ">=" to simplify adding new ones.
262
proc dg-prms-id { args } {
263
global prms_id ;# this is a testing framework variable
265
if { [llength $args] > 2 } {
266
error "[lindex $args 0]: too many arguments"
270
set prms_id [lindex $args 1]
276
# Different options can be used for different targets by having multiple
277
# instances, selecting a different target each time. Since options are
278
# processed in order, put the default value first. Subsequent occurrences
279
# will override previous ones.
282
proc dg-options { args } {
283
upvar dg-extra-tool-flags extra-tool-flags
285
if { [llength $args] > 3 } {
286
error "[lindex $args 0]: too many arguments"
290
if { [llength $args] >= 3 } {
291
switch [dg-process-target [lindex $args 2]] {
292
"S" { set extra-tool-flags [lindex $args 1] }
294
"F" { error "[lindex $args 0]: `xfail' not allowed here" }
295
"P" { error "[lindex $args 0]: `xfail' not allowed here" }
298
set extra-tool-flags [lindex $args 1]
303
# Record what to do (compile/run/etc.)
305
# Multiple instances are supported (since we don't support target and xfail
306
# selectors on one line), though it doesn't make much sense to change the
307
# compile/assemble/link/run field. Nor does it make any sense to have
308
# multiple lines of target selectors (use one line).
310
proc dg-do { args } {
311
upvar dg-do-what do-what
313
if { [llength $args] > 3 } {
314
error "[lindex $args 0]: too many arguments"
318
set selected [lindex ${do-what} 1] ;# selected? (""/S/N)
319
set expected [lindex ${do-what} 2] ;# expected to pass/fail (P/F)
321
if { [llength $args] >= 3 } {
322
switch [dg-process-target [lindex $args 2]] {
327
# Don't deselect a target if it's been explicitly selected,
328
# but indicate a specific target has been selected (so don't
329
# do this testcase if it's not appropriate for this target).
330
# The user really shouldn't have multiple lines of target
331
# selectors, but try to do the intuitive thing (multiple lines
332
# are OR'd together).
333
if { $selected != "S" } {
337
"F" { set expected "F" }
339
# There's nothing to do for "P". We don't want to clobber a
340
# previous xfail for this target.
344
# Note: A previous occurrence of `dg-do' with target/xfail selectors
345
# is a user mistake. We clobber previous values here.
350
switch [lindex $args 1] {
357
error "[lindex $args 0]: syntax error"
360
set do-what [list [lindex $args 1] $selected $expected]
363
proc dg-error { args } {
364
upvar dg-messages messages
366
if { [llength $args] > 5 } {
367
error "[lindex $args 0]: too many arguments"
372
if { [llength $args] >= 4 } {
373
switch [dg-process-target [lindex $args 3]] {
374
"F" { set xfail "X" }
377
# If we get "N", this error doesn't apply to us so ignore it.
383
if { [llength $args] >= 5 } {
384
switch [lindex $args 4] {
385
"." { set line [dg-format-linenum [lindex $args 0]] }
387
"default" { set line [dg-format-linenum [lindex $args 4]] }
390
set line [dg-format-linenum [lindex $args 0]]
393
lappend messages [list $line "${xfail}ERROR" [lindex $args 1] [lindex $args 2]]
396
proc dg-warning { args } {
397
upvar dg-messages messages
399
if { [llength $args] > 5 } {
400
error "[lindex $args 0]: too many arguments"
405
if { [llength $args] >= 4 } {
406
switch [dg-process-target [lindex $args 3]] {
407
"F" { set xfail "X" }
410
# If we get "N", this warning doesn't apply to us so ignore it.
416
if { [llength $args] >= 5 } {
417
switch [lindex $args 4] {
418
"." { set line [dg-format-linenum [lindex $args 0]] }
420
"default" { set line [dg-format-linenum [lindex $args 4]] }
423
set line [dg-format-linenum [lindex $args 0]]
426
lappend messages [list $line "${xfail}WARNING" [lindex $args 1] [lindex $args 2]]
429
proc dg-bogus { args } {
430
upvar dg-messages messages
432
if { [llength $args] > 5 } {
433
error "[lindex $args 0]: too many arguments"
438
if { [llength $args] >= 4 } {
439
switch [dg-process-target [lindex $args 3]] {
440
"F" { set xfail "X" }
443
# If we get "N", this message doesn't apply to us so ignore it.
449
if { [llength $args] >= 5 } {
450
switch [lindex $args 4] {
451
"." { set line [dg-format-linenum [lindex $args 0]] }
453
"default" { set line [dg-format-linenum [lindex $args 4]] }
456
set line [dg-format-linenum [lindex $args 0]]
459
lappend messages [list $line "${xfail}BOGUS" [lindex $args 1] [lindex $args 2]]
462
proc dg-build { args } {
463
upvar dg-messages messages
465
if { [llength $args] > 4 } {
466
error "[lindex $args 0]: too many arguments"
471
if { [ llength $args] >= 4 } {
472
switch [dg-process-target [lindex $args 3]] {
473
"F" { set xfail "X" }
476
# If we get "N", this lossage doesn't apply to us so ignore it.
482
lappend messages [list [lindex $args 0] "${xfail}BUILD" [lindex $args 1] [lindex $args 2]]
485
proc dg-excess-errors { args } {
486
upvar dg-excess-errors-flag excess-errors-flag
488
if { [llength $args] > 3 } {
489
error "[lindex $args 0]: too many arguments"
493
if { [llength $args] >= 3 } {
494
switch [dg-process-target [lindex $args 2]] {
495
"F" { set excess-errors-flag 1 }
496
"S" { set excess-errors-flag 1 }
499
set excess-errors-flag 1
504
# Indicate expected program output
506
# We support multiple occurrences, but we do not implicitly insert newlines
509
# Note that target boards don't all support this kind of thing so it's a good
510
# idea to specify the target all the time. If one or more targets are
511
# explicitly selected, the test won't be performed if we're not one of them
512
# (as long as we were never mentioned).
514
# If you have target dependent output and want to set an xfail for one or more
515
# of them, use { dg-output "" { xfail a-b-c ... } }. The "" won't contribute
516
# to the expected output.
518
proc dg-output { args } {
519
upvar dg-output-text output-text
521
if { [llength $args] > 3 } {
522
error "[lindex $args 0]: too many arguments"
526
# Allow target dependent output.
528
set expected [lindex ${output-text} 0]
529
if { [llength $args] >= 3 } {
530
switch [dg-process-target [lindex $args 2]] {
533
"F" { set expected "F" }
534
# Don't override a previous xfail.
539
if { [llength ${output-text}] == 1 } {
541
set output-text [list $expected [lindex $args 1]]
543
set output-text [list $expected "[lindex ${output-text} 1][lindex $args 1]"]
547
proc dg-final { args } {
548
upvar dg-final-code final-code
550
if { [llength $args] > 2 } {
551
error "[lindex $args 0]: too many arguments"
555
#send_user "dg-final: $args\n"
556
append final-code "[lindex $args 1]\n"
560
# Set up our environment
562
# There currently isn't much to do, but always calling it allows us to add
563
# enhancements without having to update our callers.
564
# It must be run before calling `dg-test'.
569
# dg-runtest -- simple main loop useful to most testsuites
571
# FLAGS is a set of options to always pass.
572
# DEFAULT_EXTRA_FLAGS is a set of options to pass if the testcase doesn't
573
# specify any (with dg-option).
574
# ??? We're flipping between "flag" and "option" here.
576
proc dg-runtest { testcases flags default-extra-flags } {
579
foreach testcase $testcases {
580
# If we're only testing specific files and this isn't one of them, skip it.
581
if ![runtest_file_p $runtests $testcase] {
584
verbose "Testing [file tail [file dirname $testcase]]/[file tail $testcase]"
585
dg-test $testcase $flags ${default-extra-flags}
589
# dg-trim-dirname -- rip DIR_NAME out of FILE_NAME
591
# Syntax: dg-trim-dirname dir_name file_name
592
# We need to go through this contorsion in order to properly support
593
# directory-names which might have embedded regexp special characters.
595
proc dg-trim-dirname { dir_name file_name } {
596
set special_character "\[\?\+\-\.\(\)\$\|\]"
597
regsub -all $special_character $dir_name "\\\\&" dir_name
598
regsub "^$dir_name/?" $file_name "" file_name
602
# dg-test -- runs a new style DejaGnu test
604
# Syntax: dg-test [-keep-output] prog tool_flags default_extra_tool_flags
606
# PROG is the full path name of the file to pass to the tool (eg: compiler).
607
# TOOL_FLAGS is a set of options to always pass.
608
# DEFAULT_EXTRA_TOOL_FLAGS are additional options if the testcase has none.
610
#proc dg-test { prog tool_flags default_extra_tool_flags } {
611
proc dg-test { args } {
612
global dg-do-what-default dg-interpreter-batch-mode dg-linenum-format
613
global errorCode errorInfo
615
global srcdir ;# eg: /calvin/dje/build/gcc/./testsuite/
616
global host_triplet target_triplet
621
if { [string index [lindex $args 0] 0] == "-" } {
622
for { set i 0 } { $i < [llength $args] } { incr i } {
623
if { [lindex $args $i] == "--" } {
626
} elseif { [lindex $args $i] == "-keep-output" } {
628
} elseif { [string index [lindex $args $i] 0] == "-" } {
629
clone_output "ERROR: dg-test: illegal argument: [lindex $args $i]"
637
if { $i + 3 != [llength $args] } {
638
clone_output "ERROR: dg-test: missing arguments in call"
641
set prog [lindex $args $i]
642
set tool_flags [lindex $args [expr $i + 1]]
643
set default_extra_tool_flags [lindex $args [expr $i + 2]]
645
set text "\[- A-Za-z0-9\.\;\"\_\:\'\`\(\)\!\#\=\+\?\&\*]*"
647
set name [dg-trim-dirname $srcdir $prog]
648
# If we couldn't rip $srcdir out of `prog' then just do the best we can.
649
# The point is to reduce the unnecessary noise in the logs. Don't strip
650
# out too much because different testcases with the same name can confuse
652
if [string match "/*" $name] {
653
set name "[file tail [file dirname $prog]]/[file tail $prog]"
656
# We append the compilation flags, if any, to ensure that the test case
658
if { "$tool_flags" != "" } {
659
set name "$name $tool_flags"
662
# Process any embedded dg options in the testcase.
664
# Use "" for the second element of dg-do-what so we can tell if it's been
665
# explicitly set to "S".
666
set dg-do-what [list ${dg-do-what-default} "" P]
667
set dg-excess-errors-flag 0
669
set dg-extra-tool-flags $default_extra_tool_flags
672
# `dg-output-text' is a list of two elements: pass/fail and text.
673
# Leave second element off for now (indicates "don't perform test")
674
set dg-output-text "P"
676
# Define our own "special function" `unknown' so we catch spelling errors.
677
# But first rename the existing one so we can restore it afterwards.
678
catch {rename dg-save-unknown ""}
679
rename unknown dg-save-unknown
680
proc unknown { args } {
681
return -code error "unknown dg option: $args"
684
set tmp [dg-get-options $prog]
686
verbose "Processing option: $op" 3
687
set status [catch "$op" errmsg]
688
if { $status != 0 } {
689
if { 0 && [info exists errorInfo] } {
690
# This also prints a backtrace which will just confuse
691
# testcase writers, so it's disabled.
692
perror "$name: $errorInfo\n"
694
perror "$name: $errmsg for \"$op\"\n"
696
# ??? The call to unresolved here is necessary to clear `errcnt'.
697
# What we really need is a proc like perror that doesn't set errcnt.
698
# It should also set exit_status to 1.
699
unresolved "$name: $errmsg for \"$op\""
704
# Restore normal error handling.
706
rename dg-save-unknown unknown
708
# If we're not supposed to try this test on this target, we're done.
709
if { [lindex ${dg-do-what} 1] == "N" } {
711
verbose "$name not supported on this target, skipping it" 3
715
# Run the tool and analyze the results.
716
# The result of ${tool}-dg-test is in a bit of flux.
717
# Currently it is the name of the output file (or "" if none).
718
# If we need more than this it will grow into a list of things.
719
# No intention is made (at this point) to preserve upward compatibility
720
# (though at some point we'll have to).
722
set results [${tool}-dg-test $prog [lindex ${dg-do-what} 0] "$tool_flags ${dg-extra-tool-flags}"]
724
set comp_output [lindex $results 0]
725
set output_file [lindex $results 1]
727
#send_user "\nold_dejagnu.exp: comp_output1 = :$comp_output:\n\n"
728
#send_user "\nold_dejagnu.exp: message = :$message:\n\n"
729
#send_user "\nold_dejagnu.exp: message length = [llength $message]\n\n"
731
foreach i ${dg-messages} {
732
verbose "Scanning for message: $i" 4
734
# Remove all error messages for the line [lindex $i 0]
735
# in the source file. If we find any, success!
736
set line [lindex $i 0]
737
set pattern [lindex $i 2]
738
set comment [lindex $i 3]
739
#send_user "Before:\n$comp_output\n"
740
if [regsub -all "(^|\n)(\[^\n\]+$line\[^\n\]*($pattern)\[^\n\]*\n?)+" $comp_output "\n" comp_output] {
741
set comp_output [string trimleft $comp_output]
748
#send_user "After:\n$comp_output\n"
750
# $line will either be a formatted line number or a number all by
751
# itself. Delete the formatting.
752
scan $line ${dg-linenum-format} line
753
switch [lindex $i 1] {
755
$ok "$name $comment (test for errors, line $line)"
758
x$ok "$name $comment (test for errors, line $line)"
761
$ok "$name $comment (test for warnings, line $line)"
764
x$ok "$name $comment (test for warnings, line $line)"
767
$uhoh "$name $comment (test for bogus messages, line $line)"
770
x$uhoh "$name $comment (test for bogus messages, line $line)"
773
$uhoh "$name $comment (test for build failure, line $line)"
776
x$uhoh "$name $comment (test for build failure, line $line)"
781
#send_user "\nold_dejagnu.exp: comp_output2= :$comp_output:\n\n"
783
#send_user "\nold_dejagnu.exp: comp_output3 = :$comp_output:\n\n"
785
# Remove messages from the tool that we can ignore.
786
#send_user "comp_output: $comp_output\n"
787
set comp_output [prune_warnings $comp_output]
789
if { [info proc ${tool}-dg-prune] != "" } {
790
set comp_output [${tool}-dg-prune $target_triplet $comp_output]
791
switch -glob $comp_output {
793
regsub "::untested::" $comp_output "" message
794
untested "$name: $message"
798
regsub "::unresolved::" $comp_output "" message
799
unresolved "$name: $message"
803
regsub "::unsupported::" $comp_output "" message
804
unsupported "$name: $message"
810
# See if someone forgot to delete the extra lines.
811
regsub -all "\n+" $comp_output "\n" comp_output
812
regsub "^\n+" $comp_output "" comp_output
813
#send_user "comp_output: $comp_output\n"
815
# Don't do this if we're testing an interpreter.
817
if { ${dg-interpreter-batch-mode} == 0 } {
818
# Catch excess errors (new bugs or incomplete testcases).
819
if ${dg-excess-errors-flag} {
822
if ![string match "" $comp_output] {
823
fail "$name (test for excess errors)"
824
send_log "Excess errors:\n$comp_output\n"
826
pass "$name (test for excess errors)"
830
# Run the executable image if asked to do so.
831
# FIXME: This is the only place where we assume a standard meaning to
832
# the `keyword' argument of dg-do. This could be cleaned up.
833
if { [lindex ${dg-do-what} 0] == "run" } {
834
if ![file exists $output_file] {
835
warning "$name compilation failed to produce executable"
838
set result [${tool}_load $output_file]
839
set status [lindex $result 0]
840
set output [lindex $result 1]
841
#send_user "After exec, status: $status\n"
842
if { [lindex ${dg-do-what} 2] == "F" } {
845
if { "$status" == "pass" } {
846
pass "$name execution test"
847
verbose "Exec succeeded." 3
848
if { [llength ${dg-output-text}] > 1 } {
849
#send_user "${dg-output-text}\n"
850
if { [lindex ${dg-output-text} 0] == "F" } {
853
set texttmp [lindex ${dg-output-text} 1]
854
if { ![regexp $texttmp ${output}] } {
855
fail "$name output pattern test, is ${output}, should match $texttmp"
856
verbose "Failed test for output pattern $texttmp" 3
858
pass "$name output pattern test, $texttmp"
859
verbose "Passed test for output pattern $texttmp" 3
863
} elseif { "$status" == "fail" } {
864
# It would be nice to get some info out of errorCode.
865
if [info exists errorCode] {
866
verbose "Exec failed, errorCode: $errorCode" 3
868
verbose "Exec failed, errorCode not defined!" 3
870
fail "$name execution test"
872
$status "$name execution test"
877
# Are there any further tests to perform?
878
# Note that if the program has special run-time requirements, running
879
# of the program can be delayed until here. Ditto for other situations.
880
# It would be a bit cumbersome though.
882
if ![string match ${dg-final-code} ""] {
883
regsub -all "\\\\(\[{}\])" ${dg-final-code} "\\1" dg-final-code
884
# Note that the use of `args' here makes this a varargs proc.
885
proc dg-final-proc { args } ${dg-final-code}
886
verbose "Running dg-final tests." 3
887
verbose "dg-final-proc:\n[info body dg-final-proc]" 4
888
if [catch "dg-final-proc $prog" errmsg] {
889
perror "$name: error executing dg-final: $errmsg"
890
# ??? The call to unresolved here is necessary to clear `errcnt'.
891
# What we really need is a proc like perror that doesn't set errcnt.
892
# It should also set exit_status to 1.
893
unresolved "$name: error executing dg-final: $errmsg"
897
# Do some final clean up.
898
# When testing an interpreter, we don't compile something and leave an
900
if { ! ${keep} && ${dg-interpreter-batch-mode} == 0 } {
901
catch "exec rm -f $output_file"
906
# Do any necessary cleanups
908
# This is called at the end to undo anything dg-init did (that needs undoing).
911
# Reset this in case caller wonders whether s/he should.
915
# The framework doesn't like to see any error remnants, so remove them.
917
if [info exists errorInfo] {
921
# If the tool has a "finish" routine, call it.
922
# There may be a bit of duplication (eg: resetting prms_id), leave it.
923
# Let's keep these procs robust.
925
if ![string match "" [info procs ${tool}_finish]] {