-# Copyright (C) 1997, 1999, 2000, 2003, 2004, 2005, 2006, 2007
+# Copyright (C) 1997, 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
load_lib scanrtl.exp
load_lib scantree.exp
load_lib scanipa.exp
+load_lib timeout.exp
+load_lib timeout-dg.exp
load_lib prune.exp
load_lib libgloss.exp
load_lib target-libpath.exp
+load_lib torture-options.exp
# We set LC_ALL and LANG to C so that we get the same error messages as expected.
setenv LC_ALL C
setenv LANG C
-if ![info exists TORTURE_OPTIONS] {
+if [info exists TORTURE_OPTIONS] {
+ set DG_TORTURE_OPTIONS $TORTURE_OPTIONS
+} else {
# It is theoretically beneficial to group all of the O2/O3 options together,
# as in many cases the compiler will generate identical executables for
# all of them--and the c-torture testsuite will skip testing identical
# Also note that -finline-functions is explicitly included in one of the
# items below, even though -O3 is also specified, because some ports may
# choose to disable inlining functions by default, even when optimizing.
- set TORTURE_OPTIONS [list \
+ set DG_TORTURE_OPTIONS [list \
{ -O0 } \
{ -O1 } \
{ -O2 } \
{ -Os } ]
}
+if [info exists ADDITIONAL_TORTURE_OPTIONS] {
+ set DG_TORTURE_OPTIONS \
+ [concat $DG_TORTURE_OPTIONS $ADDITIONAL_TORTURE_OPTIONS]
+}
+
global GCC_UNDER_TEST
if ![info exists GCC_UNDER_TEST] {
set GCC_UNDER_TEST "[find_gcc]"
set_ld_library_path_env_vars
}
-# Split TORTURE_OPTIONS into two choices: one for testcases with loops and
-# one for testcases without loops.
-
-set torture_with_loops $TORTURE_OPTIONS
-set torture_without_loops ""
-foreach option $TORTURE_OPTIONS {
- if ![string match "*loop*" $option] {
- lappend torture_without_loops $option
- }
-}
-
# Define gcc callbacks for dg.exp.
proc gcc-dg-test-1 { target_compile prog do_what extra_tool_flags } {
set comp_output [$target_compile "$prog" "$output_file" "$compile_type" $options]
# Look for an internal compiler error, which sometimes masks the fact
- # that we didn't get an expected error message. An ICE always fails,
- # there's no way to XFAIL it.
+ # that we didn't get an expected error message. XFAIL an ICE via
+ # dg-xfail-if and use { dg-prune-output ".*internal compiler error.*" }
+ # to avoid a second failure for excess errors.
if [string match "*internal compiler error*" $comp_output] {
upvar 2 name name
fail "$name (internal compiler error)"
# Likewise, if we see ".text exceeds local store range" or
# similar.
if {[string match "spu-*" $system] && \
- [string match "*exceeds local store range*" $text]} {
+ [string match "*exceeds local store*" $text]} {
# The format here is important. See dg.exp.
return "::unsupported::memory full"
}
proc gcc-dg-runtest { testcases default-extra-flags } {
global runtests
+ # Some callers set torture options themselves; don't override those.
+ set existing_torture_options [torture-options-exist]
+ if { $existing_torture_options == 0 } {
+ global DG_TORTURE_OPTIONS
+ torture-init
+ set-torture-options $DG_TORTURE_OPTIONS
+ }
+ dump-torture-options
+
foreach test $testcases {
+ global torture_with_loops torture_without_loops
# If we're only testing specific files and this isn't one of
# them, skip it.
if ![runtest_file_p $runtests $test] {
# Look for a loop within the source code - if we don't find one,
# don't pass -funroll[-all]-loops.
- global torture_with_loops torture_without_loops
if [expr [search_for $test "for*("]+[search_for $test "while*("]] {
set option_list $torture_with_loops
} else {
dg-test $test $flags ${default-extra-flags}
}
}
+
+ if { $existing_torture_options == 0 } {
+ torture-finish
+ }
}
proc gcc-dg-debug-runtest { target_compile trivial opt_opts testcases } {
$comp_output] } {
remove-build-file "trivial.S"
foreach level {1 "" 3} {
- lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
- foreach opt $opt_opts {
- lappend DEBUG_TORTURE_OPTIONS \
- [list "${type}${level}" "$opt" ]
+ if { ($type == "-gdwarf-2") && ($level != "") } {
+ lappend DEBUG_TORTURE_OPTIONS [list "${type}" "-g${level}"]
+ foreach opt $opt_opts {
+ lappend DEBUG_TORTURE_OPTIONS \
+ [list "${type}" "-g${level}" "$opt" ]
+ }
+ } else {
+ lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
+ foreach opt $opt_opts {
+ lappend DEBUG_TORTURE_OPTIONS \
+ [list "${type}${level}" "$opt" ]
+ }
}
}
}
if { ([string match {*/debug-[126].c} "$nshort"] \
|| [string match {*/enum-1.c} "$nshort"] \
|| [string match {*/enum-[12].C} "$nshort"]) \
- && [string match "*1" [lindex "$flags" 0] ] } {
+ && ([string match "*1" [lindex "$flags" 0] ]
+ || [lindex "$flags" 1] == "-g1") } {
set doit 0
}
set file_list "[glob -nocomplain $pat]"
verbose "remove-build-file `$file_list'" 2
foreach output_file $file_list {
+ if [is_remote host] {
+ # Ensure the host knows the file is gone by deleting there
+ # first.
+ remote_file host delete $output_file
+ }
remote_file build delete $output_file
}
}
+# Remove runtime-generated profile file for the current test.
+proc cleanup-profile-file { } {
+ remove-build-file "mon.out"
+ remove-build-file "gmon.out"
+}
+
# Remove compiler-generated coverage files for the current test.
proc cleanup-coverage-files { } {
# This assumes that we are two frames down from dg-test or some other proc
# Remove files kept by --save-temps for the current test.
#
-# Currently this is only .i, .ii and .s files, but more can be added
+# Currently this is only .i, .ii, .s and .o files, but more can be added
# if there are tests generating them.
-proc cleanup-saved-temps { } {
+# ARGS is a list of suffixes to NOT delete.
+proc cleanup-saved-temps { args } {
global additional_sources
+ set suffixes {}
+
+ # add the to-be-kept suffixes
+ foreach suffix {".ii" ".i" ".s" ".o"} {
+ if {[lsearch $args $suffix] < 0} {
+ lappend suffixes $suffix
+ }
+ }
# This assumes that we are two frames down from dg-test or some other proc
# that stores the filename of the testcase in a local variable "name".
# A cleaner solution would require a new DejaGnu release.
upvar 2 name testcase
- remove-build-file "[file rootname [file tail $testcase]].ii"
- remove-build-file "[file rootname [file tail $testcase]].i"
+ foreach suffix $suffixes {
+ remove-build-file "[file rootname [file tail $testcase]]$suffix"
+ }
# Clean up saved temp files for additional source files.
if [info exists additional_sources] {
foreach srcfile $additional_sources {
- remove-build-file "[file rootname [file tail $srcfile]].ii"
- remove-build-file "[file rootname [file tail $srcfile]].i"
+ foreach suffix $suffixes {
+ remove-build-file "[file rootname [file tail $srcfile]]$suffix"
+ }
}
}
}
if [info exists compiler_conditional_xfail_data] {
unset compiler_conditional_xfail_data
}
+ unset_timeout_vars
error $errmsg $saved_info
}
set additional_files ""
set additional_sources ""
set additional_prunes ""
set shouldfail 0
+ unset_timeout_vars
if [info exists compiler_conditional_xfail_data] {
unset compiler_conditional_xfail_data
}
process-message saved-dg-error "$gcc_error_prefix" "$args"
}
+
+ # Override dg-bogus at the same time. It doesn't handle a prefix
+ # but its expression should include a column number. Otherwise the
+ # line number can match the column number for other messages, leading
+ # to insanity.
+ rename dg-bogus saved-dg-bogus
+
+ proc dg-bogus { args } {
+ upvar dg-messages dg-messages
+ process-message saved-dg-bogus "" $args
+ }
}
# Modify the regular expression saved by a DejaGnu message directive to
return;
}
- # Prepend the message prefix to the regular expression and make
- # it match a single line.
+ # Get the entry for the new message. Prepend the message prefix to
+ # the regular expression and make it match a single line.
set newentry [lindex ${dg-messages} end]
set expmsg [lindex $newentry 2]
- set expmsg "$msgprefix\[^\n]*$expmsg"
+
+ # Handle column numbers from the specified expression (if there is
+ # one) and set up the search expression that will be used by DejaGnu.
+ if [regexp "^(\[0-9\]+):" $expmsg "" column] {
+ # The expression in the directive included a column number.
+ # Remove "COLUMN:" from the original expression and move it
+ # to the proper place in the search expression.
+ regsub "^\[0-9\]+:" $expmsg "" expmsg
+ set expmsg "$column: $msgprefix\[^\n\]*$expmsg"
+ } elseif [string match "" [lindex $newentry 0]] {
+ # The specified line number is 0; don't expect a column number.
+ set expmsg "$msgprefix\[^\n\]*$expmsg"
+ } else {
+ # There is no column number in the search expression, but we
+ # should expect one in the message itself.
+ set expmsg "\[0-9\]+: $msgprefix\[^\n\]*$expmsg"
+ }
+
set newentry [lreplace $newentry 2 2 $expmsg]
set dg-messages [lreplace ${dg-messages} end end $newentry]
verbose "process-message:\n${dg-messages}" 2