OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [lib/] [gcc-dg.exp] - Blame information for rev 706

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 701 jeremybenn
#   Copyright (C) 1997, 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
2
#   2010 Free Software Foundation, Inc.
3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with GCC; see the file COPYING3.  If not see
16
# .
17
 
18
load_lib dg.exp
19
load_lib file-format.exp
20
load_lib target-supports.exp
21
load_lib target-supports-dg.exp
22
load_lib scanasm.exp
23
load_lib scanrtl.exp
24
load_lib scantree.exp
25
load_lib scanipa.exp
26
load_lib timeout.exp
27
load_lib timeout-dg.exp
28
load_lib prune.exp
29
load_lib libgloss.exp
30
load_lib target-libpath.exp
31
load_lib torture-options.exp
32
 
33
# We set LC_ALL and LANG to C so that we get the same error messages as expected.
34
setenv LC_ALL C
35
setenv LANG C
36
 
37
# Many hosts now default to a non-ASCII C locale, however, so
38
# they can set a charset encoding here if they need.
39
if { [ishost "*-*-cygwin*"] } {
40
  setenv LC_ALL C.ASCII
41
  setenv LANG C.ASCII
42
}
43
 
44
global GCC_UNDER_TEST
45
if ![info exists GCC_UNDER_TEST] {
46
    set GCC_UNDER_TEST "[find_gcc]"
47
}
48
 
49
if [info exists TORTURE_OPTIONS] {
50
    set DG_TORTURE_OPTIONS $TORTURE_OPTIONS
51
} else {
52
    # It is theoretically beneficial to group all of the O2/O3 options together,
53
    # as in many cases the compiler will generate identical executables for
54
    # all of them--and the c-torture testsuite will skip testing identical
55
    # executables multiple times.
56
    # Also note that -finline-functions is explicitly included in one of the
57
    # items below, even though -O3 is also specified, because some ports may
58
    # choose to disable inlining functions by default, even when optimizing.
59
    set DG_TORTURE_OPTIONS [list \
60
        { -O0 } \
61
        { -O1 } \
62
        { -O2 } \
63
        { -O3 -fomit-frame-pointer } \
64
        { -O3 -fomit-frame-pointer -funroll-loops } \
65
        { -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions } \
66
        { -O3 -g } \
67
        { -Os } ]
68
}
69
 
70
if [info exists ADDITIONAL_TORTURE_OPTIONS] {
71
    set DG_TORTURE_OPTIONS \
72
        [concat $DG_TORTURE_OPTIONS $ADDITIONAL_TORTURE_OPTIONS]
73
}
74
 
75
set LTO_TORTURE_OPTIONS ""
76
 
77
# Some torture-options cause intermediate code output, unusable for
78
# testing using e.g. scan-assembler.  In this variable are the options
79
# how to force it, when needed.
80
global gcc_force_conventional_output
81
set gcc_force_conventional_output ""
82
 
83
if [check_effective_target_lto] {
84
    # When having plugin test both slim and fat LTO and plugin/nonplugin
85
    # path.
86
    if [check_linker_plugin_available] {
87
      set LTO_TORTURE_OPTIONS [list \
88
          { -O2 -flto -fno-use-linker-plugin -flto-partition=none } \
89
          { -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects }
90
      ]
91
      set gcc_force_conventional_output "-ffat-lto-objects"
92
    } else {
93
      set LTO_TORTURE_OPTIONS [list \
94
          { -O2 -flto -flto-partition=none } \
95
          { -O2 -flto }
96
      ]
97
    }
98
}
99
 
100
global orig_environment_saved
101
 
102
# This file may be sourced, so don't override environment settings
103
# that have been previously setup.
104
if { $orig_environment_saved == 0 } {
105
    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
106
    set_ld_library_path_env_vars
107
}
108
 
109
# Define gcc callbacks for dg.exp.
110
 
111
proc gcc-dg-test-1 { target_compile prog do_what extra_tool_flags } {
112
    # Set up the compiler flags, based on what we're going to do.
113
 
114
    set options [list]
115
 
116
    # Tests should be able to use "dg-do repo".  However, the dg test
117
    # driver checks the argument to dg-do against a list of acceptable
118
    # options, and "repo" is not among them.  Therefore, we resort to
119
    # this ugly approach.
120
    if [string match "*-frepo*" $extra_tool_flags] then {
121
        set do_what "repo"
122
    }
123
 
124
    switch $do_what {
125
        "preprocess" {
126
            set compile_type "preprocess"
127
            set output_file "[file rootname [file tail $prog]].i"
128
        }
129
        "compile" {
130
            set compile_type "assembly"
131
            set output_file "[file rootname [file tail $prog]].s"
132
        }
133
        "assemble" {
134
            set compile_type "object"
135
            set output_file "[file rootname [file tail $prog]].o"
136
        }
137
        "precompile" {
138
            set compile_type "precompiled_header"
139
            set output_file "[file tail $prog].gch"
140
        }
141
        "link" {
142
            set compile_type "executable"
143
            set output_file "[file rootname [file tail $prog]].exe"
144
            # The following line is needed for targets like the i960 where
145
            # the default output file is b.out.  Sigh.
146
        }
147
        "repo" {
148
            set compile_type "object"
149
            set output_file "[file rootname [file tail $prog]].o"
150
        }
151
        "run" {
152
            set compile_type "executable"
153
            # FIXME: "./" is to cope with "." not being in $PATH.
154
            # Should this be handled elsewhere?
155
            # YES.
156
            set output_file "./[file rootname [file tail $prog]].exe"
157
            # This is the only place where we care if an executable was
158
            # created or not.  If it was, dg.exp will try to run it.
159
            catch { remote_file build delete $output_file }
160
        }
161
        default {
162
            perror "$do_what: not a valid dg-do keyword"
163
            return ""
164
        }
165
    }
166
 
167
    # Let { dg-final { action } } force options as returned by an
168
    # optional proc ${action}_required_options.
169
    upvar 2 dg-final-code finalcode
170
    foreach x [split $finalcode "\n"] {
171
        set finalcmd [lindex $x 0]
172
        if { [info procs ${finalcmd}_required_options] != "" } {
173
            set req [${finalcmd}_required_options]
174
            if { $req != "" } {
175
                lappend extra_tool_flags $req
176
            }
177
        }
178
    }
179
 
180
    if { $extra_tool_flags != "" } {
181
        lappend options "additional_flags=$extra_tool_flags"
182
    }
183
 
184
    set comp_output [$target_compile "$prog" "$output_file" "$compile_type" $options]
185
 
186
    # Look for an internal compiler error, which sometimes masks the fact
187
    # that we didn't get an expected error message.  XFAIL an ICE via
188
    # dg-xfail-if and use { dg-prune-output ".*internal compiler error.*" }
189
    # to avoid a second failure for excess errors.
190
    if [string match "*internal compiler error*" $comp_output] {
191
        upvar 2 name name
192
        fail "$name (internal compiler error)"
193
    }
194
 
195
    if { $do_what == "repo" } {
196
        set object_file "$output_file"
197
        set output_file "[file rootname [file tail $prog]].exe"
198
        set comp_output \
199
            [ concat $comp_output \
200
                  [$target_compile "$object_file" "$output_file" \
201
                       "executable" $options] ]
202
    }
203
 
204
    return [list $comp_output $output_file]
205
}
206
 
207
proc gcc-dg-test { prog do_what extra_tool_flags } {
208
    return [gcc-dg-test-1 gcc_target_compile $prog $do_what $extra_tool_flags]
209
}
210
 
211
proc gcc-dg-prune { system text } {
212
    global additional_prunes
213
 
214
    set text [prune_gcc_output $text]
215
 
216
    foreach p $additional_prunes {
217
        if { [string length $p] > 0 } {
218
            # Following regexp matches a complete line containing $p.
219
            regsub -all "(^|\n)\[^\n\]*$p\[^\n\]*" $text "" text
220
        }
221
    }
222
 
223
    # If we see "region xxx is full" then the testcase is too big for ram.
224
    # This is tricky to deal with in a large testsuite like c-torture so
225
    # deal with it here.  Just mark the testcase as unsupported.
226
    if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $text] {
227
        # The format here is important.  See dg.exp.
228
        return "::unsupported::memory full"
229
    }
230
 
231
    # Likewise, if we see ".text exceeds local store range" or
232
    # similar.
233
    if {[string match "spu-*" $system] && \
234
            [string match "*exceeds local store*" $text]} {
235
        # The format here is important.  See dg.exp.
236
        return "::unsupported::memory full"
237
    }
238
 
239
    return $text
240
}
241
 
242
# Replace ${tool}_load with a wrapper to provide for an expected nonzero
243
# exit status.  Multiple languages include this file so this handles them
244
# all, not just gcc.
245
if { [info procs ${tool}_load] != [list] \
246
      && [info procs saved_${tool}_load] == [list] } {
247
    rename ${tool}_load saved_${tool}_load
248
 
249
    proc ${tool}_load { program args } {
250
        global tool
251
        global shouldfail
252
        set result [eval [list saved_${tool}_load $program] $args]
253
        if { $shouldfail != 0 } {
254
            switch [lindex $result 0] {
255
                "pass" { set status "fail" }
256
                "fail" { set status "pass" }
257
            }
258
            set result [list $status [lindex $result 1]]
259
        }
260
        return $result
261
    }
262
}
263
 
264
# Utility routines.
265
 
266
#
267
# search_for -- looks for a string match in a file
268
#
269
proc search_for { file pattern } {
270
    set fd [open $file r]
271
    while { [gets $fd cur_line]>=0 } {
272
        if [string match "*$pattern*" $cur_line] then {
273
            close $fd
274
            return 1
275
        }
276
    }
277
    close $fd
278
    return 0
279
}
280
 
281
# Modified dg-runtest that can cycle through a list of optimization options
282
# as c-torture does.
283
proc gcc-dg-runtest { testcases default-extra-flags } {
284
    global runtests
285
 
286
    # Some callers set torture options themselves; don't override those.
287
    set existing_torture_options [torture-options-exist]
288
    if { $existing_torture_options == 0 } {
289
        global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS
290
        torture-init
291
        set-torture-options $DG_TORTURE_OPTIONS [list {}] $LTO_TORTURE_OPTIONS
292
    }
293
    dump-torture-options
294
 
295
    foreach test $testcases {
296
        global torture_with_loops torture_without_loops
297
        # If we're only testing specific files and this isn't one of
298
        # them, skip it.
299
        if ![runtest_file_p $runtests $test] {
300
            continue
301
        }
302
 
303
        # Look for a loop within the source code - if we don't find one,
304
        # don't pass -funroll[-all]-loops.
305
        if [expr [search_for $test "for*("]+[search_for $test "while*("]] {
306
            set option_list $torture_with_loops
307
        } else {
308
            set option_list $torture_without_loops
309
        }
310
 
311
        set nshort [file tail [file dirname $test]]/[file tail $test]
312
 
313
        foreach flags $option_list {
314
            verbose "Testing $nshort, $flags" 1
315
            dg-test $test $flags ${default-extra-flags}
316
        }
317
    }
318
 
319
    if { $existing_torture_options == 0 } {
320
        torture-finish
321
    }
322
}
323
 
324
proc gcc-dg-debug-runtest { target_compile trivial opt_opts testcases } {
325
    global srcdir subdir
326
 
327
    if ![info exists DEBUG_TORTURE_OPTIONS] {
328
        set DEBUG_TORTURE_OPTIONS ""
329
        foreach type {-gdwarf-2 -gstabs -gstabs+ -gxcoff -gxcoff+ -gcoff} {
330
            set comp_output [$target_compile \
331
                    "$srcdir/$subdir/$trivial" "trivial.S" assembly \
332
                    "additional_flags=$type"]
333
            if { ! [string match "*: target system does not support the * debug format*" \
334
                    $comp_output] } {
335
                remove-build-file "trivial.S"
336
                foreach level {1 "" 3} {
337
                    if { ($type == "-gdwarf-2") && ($level != "") } {
338
                        lappend DEBUG_TORTURE_OPTIONS [list "${type}" "-g${level}"]
339
                        foreach opt $opt_opts {
340
                            lappend DEBUG_TORTURE_OPTIONS \
341
                                    [list "${type}" "-g${level}" "$opt" ]
342
                        }
343
                    } else {
344
                        lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
345
                        foreach opt $opt_opts {
346
                            lappend DEBUG_TORTURE_OPTIONS \
347
                                    [list "${type}${level}" "$opt" ]
348
                        }
349
                    }
350
                }
351
            }
352
        }
353
    }
354
 
355
    verbose -log "Using options $DEBUG_TORTURE_OPTIONS"
356
 
357
    global runtests
358
 
359
    foreach test $testcases {
360
        # If we're only testing specific files and this isn't one of
361
        # them, skip it.
362
        if ![runtest_file_p $runtests $test] {
363
            continue
364
        }
365
 
366
        set nshort [file tail [file dirname $test]]/[file tail $test]
367
 
368
        foreach flags $DEBUG_TORTURE_OPTIONS {
369
            set doit 1
370
 
371
            # These tests check for information which may be deliberately
372
            # suppressed at -g1.
373
            if { ([string match {*/debug-[126].c} "$nshort"] \
374
                   || [string match {*/enum-1.c} "$nshort"] \
375
                   || [string match {*/enum-[12].C} "$nshort"]) \
376
                    && ([string match "*1" [lindex "$flags" 0] ]
377
                        || [lindex "$flags" 1] == "-g1") } {
378
                set doit 0
379
            }
380
 
381
    # High optimization can remove the variable whose existence is tested.
382
    # Dwarf debugging with commentary (-dA) preserves the symbol name in the
383
    # assembler output, but stabs debugging does not.
384
    # http://gcc.gnu.org/ml/gcc-regression/2003-04/msg00095.html
385
            if { [string match {*/debug-[12].c} "$nshort"] \
386
                    && [string match "*O*" "$flags"] \
387
                    && ( [string match "*coff*" "$flags"] \
388
                         || [string match "*stabs*" "$flags"] ) } {
389
                set doit 0
390
            }
391
 
392
            if { $doit } {
393
                verbose -log "Testing $nshort, $flags" 1
394
                dg-test $test $flags ""
395
            }
396
        }
397
    }
398
}
399
 
400
# Prune any messages matching ARGS[1] (a regexp) from test output.
401
proc dg-prune-output { args } {
402
    global additional_prunes
403
 
404
    if { [llength $args] != 2 } {
405
        error "[lindex $args 1]: need one argument"
406
        return
407
    }
408
 
409
    lappend additional_prunes [lindex $args 1]
410
}
411
 
412
# Remove files matching the pattern from the build machine.
413
proc remove-build-file { pat } {
414
    verbose "remove-build-file `$pat'" 2
415
    set file_list "[glob -nocomplain $pat]"
416
    verbose "remove-build-file `$file_list'" 2
417
    foreach output_file $file_list {
418
        if [is_remote host] {
419
            # Ensure the host knows the file is gone by deleting there
420
            # first.
421
            remote_file host delete $output_file
422
        }
423
        remote_file build delete $output_file
424
    }
425
}
426
 
427
# Remove runtime-generated profile file for the current test.
428
proc cleanup-profile-file { } {
429
    remove-build-file "mon.out"
430
    remove-build-file "gmon.out"
431
}
432
 
433
# Remove compiler-generated coverage files for the current test.
434
proc cleanup-coverage-files { } {
435
    # This assumes that we are two frames down from dg-test or some other proc
436
    # that stores the filename of the testcase in a local variable "name".
437
    # A cleaner solution would require a new DejaGnu release.
438
    upvar 2 name testcase
439
    # The name might include a list of options; extract the file name.
440
    set testcase [lindex $testcase 0]
441
    remove-build-file "[file rootname [file tail $testcase]].gc??"
442
 
443
    # Clean up coverage files for additional source files.
444
    if [info exists additional_sources] {
445
        foreach srcfile $additional_sources {
446
            remove-build-file "[file rootname [file tail $srcfile]].gc??"
447
        }
448
    }
449
}
450
 
451
# Remove compiler-generated files from -repo for the current test.
452
proc cleanup-repo-files { } {
453
    # This assumes that we are two frames down from dg-test or some other proc
454
    # that stores the filename of the testcase in a local variable "name".
455
    # A cleaner solution would require a new DejaGnu release.
456
    upvar 2 name testcase
457
    # The name might include a list of options; extract the file name.
458
    set testcase [lindex $testcase 0]
459
    remove-build-file "[file rootname [file tail $testcase]].o"
460
    remove-build-file "[file rootname [file tail $testcase]].rpo"
461
 
462
    # Clean up files for additional source files.
463
    if [info exists additional_sources] {
464
        foreach srcfile $additional_sources {
465
            remove-build-file "[file rootname [file tail $srcfile]].o"
466
            remove-build-file "[file rootname [file tail $srcfile]].rpo"
467
        }
468
    }
469
}
470
 
471
# Remove compiler-generated RTL dump files for the current test.
472
#
473
# SUFFIX is the filename suffix pattern.
474
proc cleanup-rtl-dump { suffix } {
475
  cleanup-dump "\[0-9\]\[0-9\]\[0-9\]r.$suffix"
476
}
477
 
478
# Remove a specific tree dump file for the current test.
479
#
480
# SUFFIX is the tree dump file suffix pattern.
481
proc cleanup-tree-dump { suffix } {
482
  cleanup-dump "\[0-9\]\[0-9\]\[0-9\]t.$suffix"
483
}
484
 
485
# Remove a specific ipa dump file for the current test.
486
#
487
# SUFFIX is the ipa dump file suffix pattern.
488
proc cleanup-ipa-dump { suffix } {
489
  cleanup-dump "\[0-9\]\[0-9\]\[0-9\]i.$suffix"
490
}
491
 
492
# Remove a stack usage file for the current test.
493
proc cleanup-stack-usage { } {
494
    # This assumes that we are two frames down from dg-test or some other proc
495
    # that stores the filename of the testcase in a local variable "name".
496
    # A cleaner solution would require a new DejaGnu release.
497
    upvar 2 name testcase
498
    # The name might include a list of options; extract the file name.
499
    set testcase [lindex $testcase 0]
500
    remove-build-file "[file rootname [file tail $testcase]].su"
501
 
502
    # Clean up files for additional source files.
503
    if [info exists additional_sources] {
504
        foreach srcfile $additional_sources {
505
            remove-build-file "[file rootname [file tail $srcfile]].su"
506
        }
507
    }
508
}
509
 
510
# Remove all dump files with the provided suffix.
511
proc cleanup-dump { suffix } {
512
    # This assumes that we are three frames down from dg-test or some other
513
    # proc that stores the filename of the testcase in a local variable
514
    # "name".  A cleaner solution would require a new DejaGnu release.
515
    upvar 3 name testcase
516
    # The name might include a list of options; extract the file name.
517
    set src [file tail [lindex $testcase 0]]
518
    remove-build-file "[file tail $src].$suffix"
519
    remove-build-file "[file rootname [file tail $src]].exe.$suffix"
520
    remove-build-file "[file rootname [file tail $src]].exe.ltrans\[0-9\]*.$suffix"
521
    # -fcompare-debug dumps
522
    remove-build-file "[file tail $src].gk.$suffix"
523
 
524
    # Clean up dump files for additional source files.
525
    if [info exists additional_sources] {
526
        foreach srcfile $additional_sources {
527
            remove-build-file "[file tail $srcfile].$suffix"
528
            remove-build-file "[file rootname [file tail $srcfile]].exe.$suffix"
529
            remove-build-file "[file rootname [file tail $srcfile]].exe.ltrans\[0-9\]*.$suffix"
530
            # -fcompare-debug dumps
531
            remove-build-file "[file tail $srcfile].gk.$suffix"
532
        }
533
    }
534
}
535
 
536
# Remove files kept by --save-temps for the current test.
537
#
538
# Currently this is only .i, .ii, .s and .o files, but more can be added
539
# if there are tests generating them.
540
# ARGS is a list of suffixes to NOT delete.
541
proc cleanup-saved-temps { args } {
542
    global additional_sources
543
    set suffixes {}
544
 
545
    # add the to-be-kept suffixes
546
    foreach suffix {".ii" ".i" ".s" ".o" ".gkd"} {
547
        if {[lsearch $args $suffix] < 0} {
548
            lappend suffixes $suffix
549
        }
550
    }
551
 
552
    # This assumes that we are two frames down from dg-test or some other proc
553
    # that stores the filename of the testcase in a local variable "name".
554
    # A cleaner solution would require a new DejaGnu release.
555
    upvar 2 name testcase
556
    # The name might include a list of options; extract the file name.
557
    set testcase [lindex $testcase 0]
558
    foreach suffix $suffixes {
559
        remove-build-file "[file rootname [file tail $testcase]]$suffix"
560
        # -fcompare-debug dumps
561
        remove-build-file "[file rootname [file tail $testcase]].gk$suffix"
562
    }
563
 
564
    # Clean up saved temp files for additional source files.
565
    if [info exists additional_sources] {
566
        foreach srcfile $additional_sources {
567
            foreach suffix $suffixes {
568
                remove-build-file "[file rootname [file tail $srcfile]]$suffix"
569
                # -fcompare-debug dumps
570
                remove-build-file "[file rootname [file tail $srcfile]].gk$suffix"
571
            }
572
        }
573
    }
574
}
575
 
576
# Remove files for specified Fortran modules.
577
proc cleanup-modules { modlist } {
578
    foreach modname $modlist {
579
        remove-build-file [string tolower $modname].mod
580
    }
581
}
582
 
583
# Scan Fortran modules for a given regexp.
584
#
585
# Argument 0 is the module name
586
# Argument 1 is the regexp to match
587
proc scan-module { args } {
588
    set modfilename [string tolower [lindex $args 0]].mod
589
    set fd [open $modfilename r]
590
    set text [read $fd]
591
    close $fd
592
 
593
    upvar 2 name testcase
594
    if [regexp -- [lindex $args 1] $text] {
595
      pass "$testcase scan-module [lindex $args 1]"
596
    } else {
597
      fail "$testcase scan-module [lindex $args 1]"
598
    }
599
}
600
 
601
# Scan Fortran modules for absence of a given regexp.
602
#
603
# Argument 0 is the module name
604
# Argument 1 is the regexp to match
605
proc scan-module-absence { args } {
606
    set modfilename [string tolower [lindex $args 0]].mod
607
    set fd [open $modfilename r]
608
    set text [read $fd]
609
    close $fd
610
 
611
    upvar 2 name testcase
612
    if [regexp -- [lindex $args 1] $text] {
613
      fail "$testcase scan-module [lindex $args 1]"
614
    } else {
615
      pass "$testcase scan-module [lindex $args 1]"
616
    }
617
}
618
 
619
# Verify that the compiler output file exists, invoked via dg-final.
620
proc output-exists { args } {
621
    # Process an optional target or xfail list.
622
    if { [llength $args] >= 1 } {
623
        switch [dg-process-target [lindex $args 0]] {
624
            "S" { }
625
            "N" { return }
626
            "F" { setup_xfail "*-*-*" }
627
            "P" { }
628
        }
629
    }
630
 
631
    # Access variables from gcc-dg-test-1.
632
    upvar 2 name testcase
633
    upvar 2 output_file output_file
634
 
635
    if [file exists $output_file] {
636
        pass "$testcase output-exists $output_file"
637
    } else {
638
        fail "$testcase output-exists $output_file"
639
    }
640
}
641
 
642
# Verify that the compiler output file does not exist, invoked via dg-final.
643
proc output-exists-not { args } {
644
    # Process an optional target or xfail list.
645
    if { [llength $args] >= 1 } {
646
        switch [dg-process-target [lindex $args 0]] {
647
            "S" { }
648
            "N" { return }
649
            "F" { setup_xfail "*-*-*" }
650
            "P" { }
651
        }
652
    }
653
 
654
    # Access variables from gcc-dg-test-1.
655
    upvar 2 name testcase
656
    upvar 2 output_file output_file
657
 
658
    if [file exists $output_file] {
659
        fail "$testcase output-exists-not $output_file"
660
    } else {
661
        pass "$testcase output-exists-not $output_file"
662
    }
663
}
664
 
665
# We need to make sure that additional_* are cleared out after every
666
# test.  It is not enough to clear them out *before* the next test run
667
# because gcc-target-compile gets run directly from some .exp files
668
# (outside of any test).  (Those uses should eventually be eliminated.)
669
 
670
# Because the DG framework doesn't provide a hook that is run at the
671
# end of a test, we must replace dg-test with a wrapper.
672
 
673
if { [info procs saved-dg-test] == [list] } {
674
    rename dg-test saved-dg-test
675
 
676
    proc dg-test { args } {
677
        global additional_files
678
        global additional_sources
679
        global additional_prunes
680
        global errorInfo
681
        global compiler_conditional_xfail_data
682
        global shouldfail
683
 
684
        if { [ catch { eval saved-dg-test $args } errmsg ] } {
685
            set saved_info $errorInfo
686
            set additional_files ""
687
            set additional_sources ""
688
            set additional_prunes ""
689
            set shouldfail 0
690
            if [info exists compiler_conditional_xfail_data] {
691
                unset compiler_conditional_xfail_data
692
            }
693
            unset_timeout_vars
694
            error $errmsg $saved_info
695
        }
696
        set additional_files ""
697
        set additional_sources ""
698
        set additional_prunes ""
699
        set shouldfail 0
700
        unset_timeout_vars
701
        if [info exists compiler_conditional_xfail_data] {
702
            unset compiler_conditional_xfail_data
703
        }
704
    }
705
}
706
 
707
if { [info procs saved-dg-warning] == [list] \
708
     && [info exists gcc_warning_prefix] } {
709
    rename dg-warning saved-dg-warning
710
 
711
    proc dg-warning { args } {
712
        # Make this variable available here and to the saved proc.
713
        upvar dg-messages dg-messages
714
        global gcc_warning_prefix
715
 
716
        process-message saved-dg-warning "$gcc_warning_prefix" "$args"
717
    }
718
}
719
 
720
if { [info procs saved-dg-error] == [list] \
721
     && [info exists gcc_error_prefix] } {
722
    rename dg-error saved-dg-error
723
 
724
    proc dg-error { args } {
725
        # Make this variable available here and to the saved proc.
726
        upvar dg-messages dg-messages
727
        global gcc_error_prefix
728
 
729
        process-message saved-dg-error "$gcc_error_prefix" "$args"
730
    }
731
 
732
    # Override dg-bogus at the same time.  It doesn't handle a prefix
733
    # but its expression should include a column number.  Otherwise the
734
    # line number can match the column number for other messages, leading
735
    # to insanity.
736
    rename dg-bogus saved-dg-bogus
737
 
738
    proc dg-bogus { args } {
739
        upvar dg-messages dg-messages
740
        process-message saved-dg-bogus "" $args
741
    }
742
}
743
 
744
# Modify the regular expression saved by a DejaGnu message directive to
745
# include a prefix and to force the expression to match a single line.
746
# MSGPROC is the procedure to call.
747
# MSGPREFIX is the prefix to prepend.
748
# DGARGS is the original argument list.
749
 
750
proc process-message { msgproc msgprefix dgargs } {
751
    upvar dg-messages dg-messages
752
 
753
    # Process the dg- directive, including adding the regular expression
754
    # to the new message entry in dg-messages.
755
    set msgcnt [llength ${dg-messages}]
756
    catch { eval $msgproc $dgargs }
757
 
758
    # If the target expression wasn't satisfied there is no new message.
759
    if { [llength ${dg-messages}] == $msgcnt } {
760
        return;
761
    }
762
 
763
    # Get the entry for the new message.  Prepend the message prefix to
764
    # the regular expression and make it match a single line.
765
    set newentry [lindex ${dg-messages} end]
766
    set expmsg [lindex $newentry 2]
767
 
768
    # Handle column numbers from the specified expression (if there is
769
    # one) and set up the search expression that will be used by DejaGnu.
770
    if [regexp "^(\[0-9\]+):" $expmsg "" column] {
771
        # The expression in the directive included a column number.
772
        # Remove "COLUMN:" from the original expression and move it
773
        # to the proper place in the search expression.
774
        regsub "^\[0-9\]+:" $expmsg "" expmsg
775
        set expmsg "$column: $msgprefix\[^\n\]*$expmsg"
776
    } elseif [string match "" [lindex $newentry 0]] {
777
        # The specified line number is 0; don't expect a column number.
778
        set expmsg "$msgprefix\[^\n\]*$expmsg"
779
    } else {
780
        # There is no column number in the search expression, but we
781
        # should expect one in the message itself.
782
        set expmsg "\[0-9\]+: $msgprefix\[^\n\]*$expmsg"
783
    }
784
 
785
    set newentry [lreplace $newentry 2 2 $expmsg]
786
    set dg-messages [lreplace ${dg-messages} end end $newentry]
787
    verbose "process-message:\n${dg-messages}" 2
788
}
789
 
790
# Look for messages that don't have standard prefixes.
791
 
792
proc dg-message { args } {
793
    upvar dg-messages dg-messages
794
    process-message saved-dg-warning "" $args
795
}
796
 
797
# Check the existence of a gdb in the path, and return true if there
798
# is one.
799
#
800
# Set env(GDB_FOR_GCC_TESTING) accordingly.
801
 
802
proc gdb-exists { args } {
803
    if ![info exists ::env(GDB_FOR_GCC_TESTING)] {
804
        global GDB
805
        if ![info exists ::env(GDB_FOR_GCC_TESTING)] {
806
            if [info exists GDB] {
807
                setenv GDB_FOR_GCC_TESTING "$GDB"
808
            } else {
809
                setenv GDB_FOR_GCC_TESTING "[transform gdb]"
810
            }
811
        }
812
    }
813
    if { [which $::env(GDB_FOR_GCC_TESTING)] != 0 } {
814
        return 1;
815
    }
816
    return 0;
817
}
818
 
819
set additional_prunes ""

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.