]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgomp.exp: Load torture-options.exp from gcc lib.
authorJanis Johnson <janis187@us.ibm.com>
Thu, 15 May 2008 16:59:21 +0000 (16:59 +0000)
committerJanis Johnson <janis@gcc.gnu.org>
Thu, 15 May 2008 16:59:21 +0000 (16:59 +0000)
libgomp:
* testsuite/lib/libgomp.exp: Load torture-options.exp from gcc lib.

gcc/doc:
* doc/sourcebuild.texi: Document support for torture tests.

gcc/testsuite:
* lib/torture-options.exp: New support for torture options.
* lib/gfortran-dg.exp (gfortran-dg-runtest): Use new torture
procs.
* lib/c-torture.exp: Define C_TORTURE_OPTIONS instead of
TORTURE_OPTIONS; don't define torture_with_loops and
torture_without_loops.
* lib/gcc-dg.exp: Define DG_TORTURE_OPTIONS instead of
TORTURE_OPTIONS; don't define torture_with_loops and
torture_without_loops.
(gcc-dg-runtest): Use new torture procs if no torture options
defined.
* lib/fortran-torture.exp: Define FORTRAN_TORTURE_OPTIONS instead of
TORTURE_OPTIONS.
(fortran-torture-execute): Use torture_with_loops instead of
TORTURE_OPTIONS.
(fortran-torture): Ditto.
* lib/objc-torture.exp: Define OBJC_TORTURE_OPTIONS instead of
TORTURE_OPTIONS; don't define torture_with_loops and
torture_without_loops.
* gcc.c-torture/execute/execute.exp: Use new torture procs.
* gcc.c-torture/execute/builtins/builtins.exp: Ditto.
* gcc.c-torture/execute/ieee/ieee.exp: Ditto.
* gcc.c-torture/unsorted/unsorted.exp: Ditto.
* gfortran.fortran-torture/execute/execute.exp: Ditto.
* gfortran.fortran-torture/compile/compile.exp: Ditto.
* gcc.target/x86_64/abi/abi-x86_64.exp: Ditto.
* gcc.target/i386/math-torture/math-torture.exp: Define
MATH_TORTURE_OPTIONS, use new torture procs.
* gcc.dg/pch/pch.exp: Use new torture procs.
* gcc.dg/format/format.exp: Ditto.
* gcc.misc-tests/i386-prefetch.exp: Ditto.
* gcc.misc-tests/dectest.exp: Ditto.
* objc.dg/pch/pch.exp: Ditto.
* objc/execute/execute.exp: Ditto.
* objc/execute/exceptions/exceptions.exp: Ditto.
* objc/compile/compile.exp: Ditto.

From-SVN: r135381

27 files changed:
gcc/ChangeLog
gcc/doc/sourcebuild.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
gcc/testsuite/gcc.c-torture/execute/execute.exp
gcc/testsuite/gcc.c-torture/execute/ieee/ieee.exp
gcc/testsuite/gcc.c-torture/unsorted/unsorted.exp
gcc/testsuite/gcc.dg/format/format.exp
gcc/testsuite/gcc.dg/pch/pch.exp
gcc/testsuite/gcc.misc-tests/dectest.exp
gcc/testsuite/gcc.misc-tests/i386-prefetch.exp
gcc/testsuite/gcc.target/i386/math-torture/math-torture.exp
gcc/testsuite/gcc.target/x86_64/abi/abi-x86_64.exp
gcc/testsuite/gfortran.fortran-torture/compile/compile.exp
gcc/testsuite/gfortran.fortran-torture/execute/execute.exp
gcc/testsuite/lib/c-torture.exp
gcc/testsuite/lib/fortran-torture.exp
gcc/testsuite/lib/gcc-dg.exp
gcc/testsuite/lib/gfortran-dg.exp
gcc/testsuite/lib/objc-torture.exp
gcc/testsuite/lib/torture-options.exp [new file with mode: 0644]
gcc/testsuite/objc.dg/pch/pch.exp
gcc/testsuite/objc/compile/compile.exp
gcc/testsuite/objc/execute/exceptions/exceptions.exp
gcc/testsuite/objc/execute/execute.exp
libgomp/ChangeLog
libgomp/testsuite/lib/libgomp.exp

index ff5aa2b95029072ed0a0497412e385286b30663b..579a7c98ef9d465718a53ba53a3cd8b6e00dfe6e 100644 (file)
@@ -1,3 +1,7 @@
+2008-05-15  Janis Johnson  <janis187@us.ibm.com>
+
+       * doc/sourcebuild.texi: Document support for torture tests.
+
 2008-05-15  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/sse.md (*vec_concatv2sf_sse4_1): Add "m" constraint
index 896190cd536345dd8903742d1cfe02190eee96b3..6c551aa8156217a3adeab93b3c5c38fe63a5aacb 100644 (file)
@@ -822,6 +822,7 @@ here; FIXME: document the others.
 * gcov Testing::    Support for testing gcov.
 * profopt Testing:: Support for testing profile-directed optimizations.
 * compat Testing::  Support for testing binary compatibility.
+* Torture Tests::   Support for torture testing using multiple options.
 @end menu
 
 @node Test Idioms
@@ -1531,3 +1532,43 @@ This command can be used in a secondary source file to specify that
 compilation is expected to fail for particular options on particular
 targets.
 @end table
+
+@node Torture Tests
+@subsection Support for torture testing using multiple options
+
+Throughout the compiler testsuite there are several directories whose
+tests are run multiple times, each with a different set of options.
+These are known as torture tests.
+@file{gcc/testsuite/lib/torture-options.exp} defines procedures to
+set up these lists:
+
+@table @code
+@item torture-init
+Initialize use of torture lists.
+@item set-torture-options
+Set lists of torture options to use for tests with and without loops.
+Optionally combine a set of torture options with a set of other
+options, as is done with Objective-C runtime options.
+@item torture-finish
+Finalize use of torture lists.
+@end table
+
+The @file{.exp} file for a set of tests that use torture options must
+include calls to these three procecures if:
+
+@itemize bullet
+@item It calls @code{gcc-dg-runtest} and overrides @var{DG_TORTURE_OPTIONS}.
+
+@item It calls @var{$@{tool@}}@code{-torture} or
+@var{$@{tool@}}@code{-torture-execute}, where @var{tool} is @code{c},
+@code{fortran}, or @code{objc}.
+
+@item It calls @code{dg-pch}.
+@end itemize
+
+It is not necessary for a @file{.exp} file that calls @code{gcc-dg-runtest}
+to call the torture procedures if the tests should use the list in
+@var{DG_TORTURE_OPTIONS} defined in @file{gcc-dg.exp}.
+
+Most uses of torture options can override the default lists by defining
+@var{TORTURE_OPTIONS} in a @file{.dejagnurc} file.
index fae0f99623ba4da0a6e40bb039bb2bbf6605aaca..0f3a4ea724f619175c3725fa45c500e296a65566 100644 (file)
@@ -1,3 +1,42 @@
+2008-05-15  Janis Johnson  <janis187@us.ibm.com>
+
+       * lib/torture-options.exp: New support for torture options.
+       * lib/gfortran-dg.exp (gfortran-dg-runtest): Use new torture
+       procs.
+       * lib/c-torture.exp: Define C_TORTURE_OPTIONS instead of
+       TORTURE_OPTIONS; don't define torture_with_loops and
+       torture_without_loops.
+       * lib/gcc-dg.exp: Define DG_TORTURE_OPTIONS instead of
+       TORTURE_OPTIONS; don't define torture_with_loops and
+       torture_without_loops.
+       (gcc-dg-runtest): Use new torture procs if no torture options
+       defined.
+       * lib/fortran-torture.exp: Define FORTRAN_TORTURE_OPTIONS instead of
+       TORTURE_OPTIONS.
+       (fortran-torture-execute): Use torture_with_loops instead of
+       TORTURE_OPTIONS.
+       (fortran-torture): Ditto.
+       * lib/objc-torture.exp: Define OBJC_TORTURE_OPTIONS instead of
+       TORTURE_OPTIONS; don't define torture_with_loops and
+       torture_without_loops.
+       * gcc.c-torture/execute/execute.exp: Use new torture procs.
+       * gcc.c-torture/execute/builtins/builtins.exp: Ditto.
+       * gcc.c-torture/execute/ieee/ieee.exp: Ditto.
+       * gcc.c-torture/unsorted/unsorted.exp: Ditto.
+       * gfortran.fortran-torture/execute/execute.exp: Ditto.
+       * gfortran.fortran-torture/compile/compile.exp: Ditto.
+       * gcc.target/x86_64/abi/abi-x86_64.exp: Ditto.
+       * gcc.target/i386/math-torture/math-torture.exp: Define
+       MATH_TORTURE_OPTIONS, use new torture procs.
+       * gcc.dg/pch/pch.exp: Use new torture procs.
+       * gcc.dg/format/format.exp: Ditto.
+       * gcc.misc-tests/i386-prefetch.exp: Ditto.
+       * gcc.misc-tests/dectest.exp: Ditto.
+       * objc.dg/pch/pch.exp: Ditto.
+       * objc/execute/execute.exp: Ditto.
+       * objc/execute/exceptions/exceptions.exp: Ditto.
+       * objc/compile/compile.exp: Ditto.
+
 2008-05-15  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/36245
index 5aff873451f5a331007042e6c0df4d0c7fcfe2ec..e82d2fddfd0c26c2c71419c7e81986571684c933 100644 (file)
 # that needs them.  They shouldn't call any external functions in case
 # those functions were overridden too.
 
+load_lib torture-options.exp
 load_lib c-torture.exp
 
+torture-init
+set-torture-options $C_TORTURE_OPTIONS
+
 set additional_flags ""
 if [istarget "powerpc-*-darwin*"] {
    lappend additional_flags "-Wl,-multiply_defined,suppress"
@@ -28,3 +32,5 @@ foreach src [lsort [find $srcdir/$subdir *.c]] {
                                $additional_flags
     }
 }
+
+torture-finish
index 2214b9d1e42121b0a16972c16f75303fe319064b..f0e379f3849fe20a6477147b9838e66a3049f32d 100644 (file)
@@ -28,8 +28,12 @@ if $tracelevel then {
 }
 
 # load support procs
+load_lib torture-options.exp
 load_lib c-torture.exp
 
+torture-init
+set-torture-options $C_TORTURE_OPTIONS
+
 #
 # main test loop
 #
@@ -42,3 +46,5 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
 
     c-torture-execute $src
 }
+
+torture-finish
index d02471b865d21bd6042ed234121a6bc81b9dcaa2..3d7e56c6b30fdb762a7a354d6fe35b27407b7245 100644 (file)
@@ -21,6 +21,7 @@
 
 # Load support procs.
 load_lib gcc-dg.exp
+load_lib torture-options.exp
 
 # These tests come from Torbjorn Granlund's (tege@cygnus.com)
 # C torture test suite, and other contributors.
@@ -32,6 +33,9 @@ if $tracelevel then {
     strace $tracelevel
 }
 
+torture-init
+set-torture-options $C_TORTURE_OPTIONS
+
 set additional_flags ""
 
 # We must use -ffloat-store/-mieee to ensure that excess precision on some
@@ -70,4 +74,5 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
 }
 
 # All done.
+torture-finish
 gcc_finish
index d300d9e94681871876375b71132aa47bbfb61482..dbcea137a003868db08755ba780ecc292731078c 100644 (file)
@@ -30,6 +30,10 @@ if $tracelevel then {
 
 # load support procs
 load_lib c-torture.exp
+load_lib torture-options.exp
+
+torture-init
+set-torture-options $C_TORTURE_OPTIONS
 
 #
 # This loop will run c-torture on any *.c file found in this directory.
@@ -52,3 +56,5 @@ foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
 
     c-torture $testcase
 }
+
+torture-finish
index 2f2124148ed0bf3d755f841062ed85b0ed40929c..352149850e35c16d04ce7062d272c5338ff76044 100644 (file)
 # Don't run this directory with any default CFLAGS, but run tests with
 # and without -DWIDE.
 
-if [info exists TORTURE_OPTIONS] {
-    set old_TORTURE_OPTIONS $TORTURE_OPTIONS
-} elseif [info exists old_TORTURE_OPTIONS] {
-    unset old_TORTURE_OPTIONS
-}
-if [info exists torture_with_loops] {
-    set old_torture_with_loops $torture_with_loops
-} elseif [info exists old_torture_with_loops] {
-    unset old_torture_with_loops
-}
-if [info exists torture_without_loops] {
-    set old_torture_without_loops $torture_without_loops
-} elseif [info exists old_torture_without_loops] {
-    unset old_torture_without_loops
-}
-set TORTURE_OPTIONS [list { } { -DWIDE } ]
-set torture_with_loops [list { } { -DWIDE } ]
-set torture_without_loops [list { } { -DWIDE } ]
-
 # Need to copy the format.h header.
 if [is_remote host] {
     remote_download host $srcdir/$subdir/format.h
 }
 
 load_lib gcc-dg.exp
+load_lib torture-options.exp
+
+torture-init
+set-torture-options [list { } { -DWIDE } ]
 
 dg-init
 gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] ""
-if [info exists old_TORTURE_OPTIONS] {
-    set TORTURE_OPTIONS $old_TORTURE_OPTIONS
-} else {
-    unset TORTURE_OPTIONS
-}
-if [info exists old_torture_with_loops] {
-    set torture_with_loops $old_torture_with_loops
-} else {
-    unset torture_with_loops
-}
-if [info exists old_torture_without_loops] {
-    set torture_without_loops $old_torture_without_loops
-} else {
-    unset torture_without_loops
-}
+torture-finish
 dg-finish
index 77c5ff38fdc8f65e9599e5de552416b6b383ad19..e2ec69fd7bde9ab121b701c779176ba040349494 100644 (file)
 # Load support procs.
 load_lib gcc-dg.exp
 load_lib dg-pch.exp
+load_lib torture-options.exp
 
 # Initialize `dg'.
 dg-init
+torture-init
+set-torture-options $DG_TORTURE_OPTIONS
 
 set old_dg_do_what_default "${dg-do-what-default}"
 
@@ -56,4 +59,5 @@ file delete $testh
 set dg-do-what-default "$old_dg_do_what_default"
 
 # All done.
+torture-finish
 dg-finish
index 45225765ac7a3fa3956e149d7b2993611ee5e88e..435276d8160b4ce3625b7dd3e901e18429515373 100644 (file)
@@ -20,7 +20,7 @@
 #
 # Contributed by Ben Elliston <bje@au.ibm.com>.
 
-set TORTURE_OPTIONS [list {} -O1 -O2 -O3 -Os -msoft-float]
+set DEC_TORTURE_OPTIONS [list {} -O1 -O2 -O3 -Os -msoft-float]
 
 proc target-specific-flags {} {
   set result "-frounding-math "
@@ -30,6 +30,7 @@ proc target-specific-flags {} {
 # Load support procs (borrow these from c-torture).
 load_lib c-torture.exp
 load_lib target-supports.exp
+load_lib torture-options.exp
 
 # Skip these tests for targets that don't support this extension.
 if { ![check_effective_target_dfp] } {
@@ -516,6 +517,11 @@ if [catch {set testdir $env(DECTEST)}] {
     return
 }
 
+torture-init
+set-torture-options $DEC_TORTURE_OPTIONS
+
 note "Using tests in $testdir"
 dfp-run-tests [lsort [glob -nocomplain $testdir/*.decTest]]
 unset testdir
+
+torture-finish
index 2601d7e2de4866df0e12f628c7b69de7c268a762..c4c2bbccb04b86aaeeb58f5853f2612b3e0a5967 100644 (file)
@@ -84,32 +84,24 @@ if $tracelevel then {
 
 # Load support procs.
 load_lib gcc-dg.exp
+load_lib torture-options.exp
 
 # Initialize harness.
 dg-init
+torture-init
 
-# Save these.  They are needed if testsuite loops over multiple ABIs
-set saved_torture_with_loops $torture_with_loops
-set saved_torture_without_loops $torture_without_loops
-
-set torture_with_loops $PREFETCH_NONE
-set torture_without_loops $PREFETCH_NONE
+set-torture-options $PREFETCH_NONE
 gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-none-*.c]] ""
 
-set torture_with_loops $PREFETCH_SSE
-set torture_without_loops $PREFETCH_SSE
+set-torture-options $PREFETCH_SSE
 gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-sse-*.c]] ""
 
-set torture_with_loops $PREFETCH_3DNOW
-set torture_without_loops $PREFETCH_3DNOW
+set-torture-options $PREFETCH_3DNOW
 gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-3dnow-*.c]] ""
 
-set torture_with_loops $PREFETCH_ATHLON
-set torture_without_loops $PREFETCH_ATHLON
+set-torture-options $PREFETCH_ATHLON
 gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-athlon-*.c]] ""
 
-set torture_with_loops $saved_torture_with_loops
-set torture_without_loops $saved_torture_without_loops
-
+torture-finish
 dg-finish
 
index 2bd847d4df609966e45fe9fb227481a4bea227d4..43ea6ea2f7dc3a5391a116fcefefb62b58423453 100644 (file)
@@ -5,7 +5,7 @@ if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then {
   return
 }
 
-set TORTURE_OPTIONS [list \
+set MATH_TORTURE_OPTIONS [list \
         { -O0 } \
         { -O0 -mfpmath=387 } \
         { -O0 -msse -mno-sse2 -mfpmath=sse } \
@@ -29,8 +29,14 @@ set TORTURE_OPTIONS [list \
         { -O2 -msse -mno-sse2 -mfpmath=sse,387 -ffast-math } \
         { -O2 -msse -msse2 -mfpmath=sse,387 -ffast-math } \
 ]
+
 load_lib gcc-dg.exp
+load_lib torture-options.exp
+
+torture-init
+set-torture-options $MATH_TORTURE_OPTIONS
 
 dg-init
 gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] ""
+torture-finish
 dg-finish
index 3b2e3184464c00a00059c2a8380efe826bbacb73..4f9fd46441f45ec4a811d6473be6d6ce0889f13a 100644 (file)
@@ -19,6 +19,7 @@
 
 load_lib c-torture.exp
 load_lib target-supports.exp
+load_lib torture-options.exp
 
 if { (![istarget x86_64-*-*] && ![istarget i?86-*-*])
      || ![is-effective-target lp64] } then {
@@ -26,6 +27,8 @@ if { (![istarget x86_64-*-*] && ![istarget i?86-*-*])
 }
 
 
+torture-init
+set-torture-options $C_TORTURE_OPTIONS
 set additional_flags "-W -Wall"
 
 foreach src [lsort [find $srcdir/$subdir test_*.c]] {
@@ -41,3 +44,5 @@ foreach src [lsort [find $srcdir/$subdir test_*.c]] {
        }
     }
 }
+
+torture-finish
index d52b730646a586de96e9074b2205732749a8a178..b18e25c5f6f37ab8d6e1511ada46a1f6081c33af 100644 (file)
@@ -23,6 +23,10 @@ if $tracelevel then {
 
 # load support procs
 load_lib fortran-torture.exp
+load_lib torture-options.exp
+
+torture-init
+set-torture-options $FORTRAN_TORTURE_OPTIONS
 
 foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.f]] {
     # If we're only testing specific files and this isn't one of them, skip it.
@@ -94,3 +98,5 @@ foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.F08]] {
     }
     fortran-torture $testcase
 }
+
+torture-finish
index d22372ad0da83ce8f6dfb1e4604bfe7dd757b542..157c2404601e8108e0d14b76fad172c7ddbaa834 100644 (file)
@@ -27,6 +27,10 @@ if $tracelevel then {
 
 # load support procs
 load_lib fortran-torture.exp
+load_lib torture-options.exp
+
+torture-init
+set-torture-options $FORTRAN_TORTURE_OPTIONS
 
 foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.f]] {
     # If we're only testing specific files and this isn't one of them, skip it.
@@ -98,3 +102,5 @@ foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.F08]] {
     }
     fortran-torture-execute $testcase
 }
+
+torture-finish
index abd2eb6b743e7d0144c043fe5b98ba8e5978ce92..6413b2d85ba99417f11171b1c20c81af3a051c79 100644 (file)
@@ -22,7 +22,9 @@ load_lib target-libpath.exp
 # The default option list can be overridden by
 # TORTURE_OPTIONS="{ { list1 } ... { listN } }"
 
-if ![info exists TORTURE_OPTIONS] {
+if [info exists TORTURE_OPTIONS] {
+    set C_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
@@ -30,7 +32,7 @@ if ![info exists TORTURE_OPTIONS] {
     # 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 C_TORTURE_OPTIONS [list \
        { -O0 } \
        { -O1 } \
        { -O2 } \
@@ -55,17 +57,6 @@ if { $orig_environment_saved == 0 } {
     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
-    }
-}
-
 #
 # c-torture-compile -- runs the Tege C-torture test
 #
index f169c6cc729aaf2c777e23bad32eeb571df589e9..3286ad91e8a397ceeadbc22177a2690eb48ab53c 100644 (file)
@@ -25,7 +25,9 @@ load_lib target-supports.exp
 # The default option list can be overridden by
 # TORTURE_OPTIONS="{ { list1 } ... { listN } }"
 
-if ![info exists TORTURE_OPTIONS] {
+if [info exists TORTURE_OPTIONS] {
+    set FORTRAN_TORTURE_OPTIONS $TORTURE_OPTIONS
+} else {
     # determine if host supports vectorization, and the necessary set
     # of options, based on code from testsuite/vect/vect.exp
 
@@ -59,7 +61,7 @@ if ![info exists TORTURE_OPTIONS] {
        set test_tree_vectorize 0
     }
 
-    set TORTURE_OPTIONS [list \
+    set FORTRAN_TORTURE_OPTIONS [list \
        { -O0 } { -O1 } { -O2 } \
        { -O2 -fomit-frame-pointer -finline-functions } \
        { -O2 -fomit-frame-pointer -finline-functions -funroll-loops } \
@@ -68,7 +70,7 @@ if ![info exists TORTURE_OPTIONS] {
        { -Os }]
 
     if { $test_tree_vectorize } {
-       lappend TORTURE_OPTIONS $vectorizer_options
+       lappend FORTRAN_TORTURE_OPTIONS $vectorizer_options
     }
 }
 
@@ -174,7 +176,7 @@ proc fortran-torture-execute { src } {
     global srcdir tmpdir
     global tool
     global compiler_conditional_xfail_data
-    global TORTURE_OPTIONS
+    global torture_with_loops
 
     # Check for alternate driver.
     set additional_flags ""
@@ -188,7 +190,7 @@ proc fortran-torture-execute { src } {
     }
 
     # Setup the options for the testcase run.
-    set option_list $TORTURE_OPTIONS
+    set option_list $torture_with_loops
     set executable $tmpdir/[file tail [file rootname $src].x]
     regsub "(?q)$srcdir/" $src "" testcase
 
@@ -348,7 +350,7 @@ proc search_for_re { file pattern } {
 proc fortran-torture { args } {
     global srcdir subdir
     global compiler_conditional_xfail_data
-    global TORTURE_OPTIONS
+    global torture_with_loops
 
     set src [lindex $args 0]
     if { [llength $args] > 1 } {
@@ -373,7 +375,7 @@ proc fortran-torture { args } {
     }
    
     # loop through all the options
-    set option_list $TORTURE_OPTIONS
+    set option_list $torture_with_loops
     foreach option $option_list {
 
        # torture_compile_xfail is set by the .x script (if present)
index 1d462135c8e69d5501a4acd7ad201c59081f5ec5..ad5fc26c73fdc0fcb3346496e5aa9a662f8b7d1d 100644 (file)
@@ -26,12 +26,15 @@ load_lib scanipa.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
@@ -39,7 +42,7 @@ if ![info exists TORTURE_OPTIONS] {
     # 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 } \
@@ -64,17 +67,6 @@ if { $orig_environment_saved == 0 } {
     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 } {
@@ -239,7 +231,17 @@ proc search_for { file pattern } {
 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] {
@@ -248,7 +250,6 @@ proc gcc-dg-runtest { testcases default-extra-flags } {
 
        # 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 {
@@ -262,6 +263,10 @@ proc gcc-dg-runtest { testcases default-extra-flags } {
            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 } {
index 401651c2b79de8afd6e55b1079a91c2297cf2f2b..d7b1f2d78249c53058c9686448a705553548bf25 100644 (file)
@@ -15,6 +15,7 @@
 # <http://www.gnu.org/licenses/>.
 
 load_lib gcc-dg.exp
+load_lib torture-options.exp
 
 # Define gfortran callbacks for dg.exp.
 
@@ -82,7 +83,10 @@ proc gfortran-dg-prune { system text } {
 # as c-torture does.
 proc gfortran-dg-runtest { testcases default-extra-flags } {
     global runtests
-    global TORTURE_OPTIONS
+    global DG_TORTURE_OPTIONS torture_with_loops
+
+    torture-init
+    set-torture-options $DG_TORTURE_OPTIONS
 
     foreach test $testcases {
        # If we're only testing specific files and this isn't one of
@@ -94,7 +98,7 @@ proc gfortran-dg-runtest { testcases default-extra-flags } {
        # look if this is dg-do-run test, in which case
        # we cycle through the option list, otherwise we don't
        if [expr [search_for $test "dg-do run"]] {
-           set option_list $TORTURE_OPTIONS
+           set option_list $torture_with_loops
        } else {
            set option_list [list { -O } ]
        }
@@ -106,6 +110,8 @@ proc gfortran-dg-runtest { testcases default-extra-flags } {
            dg-test $test $flags ${default-extra-flags}
        }
     }
+
+    torture-finish
 }
 
 proc gfortran-dg-debug-runtest { target_compile trivial opt_opts testcases } {
index dda44d3abef2a306b26068c13455eeddc7bc82fa..31967f4eabcea5d664bc43c27daab25387ed3c1a 100644 (file)
@@ -18,9 +18,6 @@
 
 load_lib file-format.exp
 
-# The default option list can be overridden by
-# TORTURE_OPTIONS="{ { list1 } ... { listN } }"
-
 if ![info exists OBJC_RUNTIME_OPTIONS] {
   set OBJC_RUNTIME_OPTIONS ""
   foreach type {-fgnu-runtime -fnext-runtime} {
@@ -39,7 +36,12 @@ if ![info exists OBJC_RUNTIME_OPTIONS] {
 verbose -log "Using the following runtimes: $OBJC_RUNTIME_OPTIONS"
 
 
-if ![info exists TORTURE_OPTIONS] {
+# The default option list can be overridden by
+# TORTURE_OPTIONS="{ { list1 } ... { listN } }"
+
+if [info exists TORTURE_OPTIONS] {
+    set OBJC_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 objc-torture testsuite will skip testing identical
@@ -47,7 +49,7 @@ if ![info exists TORTURE_OPTIONS] {
     # 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 OBJC_TORTURE_OPTIONS [list \
        " -O0 " \
        " -O1 " \
        " -O2 " \
@@ -58,23 +60,6 @@ if ![info exists TORTURE_OPTIONS] {
        " -Os " ]
 }
 
-
-# Split TORTURE_OPTIONS into two choices: one for testcases with loops and
-# one for testcases without loops. Add in the objc runtime options also.
-
-set torture_with_loops ""
-set torture_without_loops ""
-foreach objc_option $OBJC_RUNTIME_OPTIONS {
-  foreach option $TORTURE_OPTIONS {
-  
-    if ![string match "*loop*" $option] {
-       lappend torture_without_loops "$option $objc_option"
-    }
-    lappend torture_with_loops "$option $objc_option"
-  }
-}
-
-
 #
 # objc-torture-compile -- runs the Tege OBJC-torture test
 #
diff --git a/gcc/testsuite/lib/torture-options.exp b/gcc/testsuite/lib/torture-options.exp
new file mode 100644 (file)
index 0000000..7721f90
--- /dev/null
@@ -0,0 +1,112 @@
+# Copyright (C) 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Prepare to use a new set of torture options. 
+#
+# Letting options leak from one set of tests to another can be confusing.
+# Make sure variables are not set at the time we're called, because that
+# would mean they were set without being cleared.
+proc torture-init { args } {
+    global torture_without_loops global_with_loops
+
+    if [info exists torture_without_loops] {
+       error "torture-init: torture_without_loops is not empty as expected"
+    }
+    if [info exists torture_with_loops] {
+       error "torture-init: torture_with_loops is not empty as expected"
+    }
+}
+
+# Return 1 if torture options have already been set, 0 otherwise.
+proc torture-options-exist { args } {
+    global torture_with_loops
+    return [info exists torture_with_loops]
+}
+
+# Return 1 if compiler option ARG only affects loops, 0 otherwise.
+proc contains-loop-option-p { arg } {
+    switch -glob -- $arg {
+      "*loop*"         { return 1 }
+      default          { return 0 }
+    }
+}
+
+# Set torture options variables for tests with and without loops.
+#
+# Argument 0 is the list to use as torture options
+# Argument 1 is the list to combine with the torture options.
+proc set-torture-options { args } {
+    global torture_with_loops torture_without_loops
+
+    set torture_list [lindex $args 0]
+
+    if { [llength $args] != 1 } {
+       set other_list [lindex $args 1]
+    } else {
+       set other_list [list {}]
+    }
+
+    set torture_with_loops ""
+    set torture_without_loops ""
+    foreach torture_opts $torture_list {
+       foreach other_opts $other_list {
+           # Remove trailing space[s] to match previous output.
+           set torture_opts [string trimright $torture_opts]
+           if ![contains-loop-option-p $torture_opts] {
+               lappend torture_without_loops "$torture_opts $other_opts"
+           }
+           lappend torture_with_loops "$torture_opts $other_opts"
+       }
+    }
+}
+
+# Finish up after using a set of torture options.
+#
+# Letting options leak from one set of tests to another can be confusing.
+# Make sure variables are set at the time we're called, and then unset
+# them to prevent interference with other sets of tests.
+proc torture-finish { args } {
+    global torture_without_loops torture_with_loops
+
+    if [info exists torture_without_loops] {
+       unset torture_without_loops
+    } else {
+       error "torture-finish: torture_without_loops is not defined"
+    }
+
+    if [info exists torture_with_loops] {
+       unset torture_with_loops
+    } else {
+       error "torture-finish: torture_with_loops is not defined"
+    }
+}
+
+# Useful for debugging .exp files.
+proc dump-torture-options { args } {
+    global torture_without_loops torture_with_loops
+
+    if [info exists torture_without_loops] {
+       verbose "torture_without_loops = \"${torture_without_loops}\"" 1
+    } else {
+       verbose "torture_without_loops is not defined" 1
+    }
+
+    if [info exists torture_with_loops] {
+       verbose "torture_with_loops = \"${torture_with_loops}\"" 1
+    } else {
+       verbose "torture_with_loops is not defined" 1
+    }
+}
index aa95b84cc27351320a93d3ec7955de0b651c3e87..95af1656864c1125a8e52dcffd51c8075a4a0d78 100644 (file)
 # Load support procs.
 load_lib objc-dg.exp
 load_lib dg-pch.exp
+load_lib torture-options.exp
 
 # Initialize `dg'.
 dg-init
 
+torture-init
+set-torture-options $DG_TORTURE_OPTIONS
+
 set old_dg_do_what_default "${dg-do-what-default}"
 
 # Main loop.
@@ -40,4 +44,5 @@ foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.m]] {
 set dg-do-what-default "$old_dg_do_what_default"
 
 # All done.
+torture-finish
 dg-finish
index 08d263265714c69b43b810650d859c4edf972fa3..0f6a7e915c74c405ffea6a2740fdcab9c6b03251 100644 (file)
@@ -23,6 +23,10 @@ if $tracelevel then {
 
 # load support procs
 load_lib objc-torture.exp
+load_lib torture-options.exp
+
+torture-init
+set-torture-options $OBJC_TORTURE_OPTIONS $OBJC_RUNTIME_OPTIONS
 
 #
 # main test loop
@@ -36,3 +40,5 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.m]] {
 
     objc-torture $src
 }
+
+torture-finish
index 271a61748391c53fc4e85c492a26b35710e0832c..d3a37385746ed0d1b285e4484252e1ea3a028758 100644 (file)
@@ -27,6 +27,10 @@ lappend additional_flags "-fobjc-exceptions"
 
 # load support procs
 load_lib objc-torture.exp
+load_lib torture-options.exp
+
+torture-init
+set-torture-options $OBJC_TORTURE_OPTIONS $OBJC_RUNTIME_OPTIONS
 
 #
 # main test loop
@@ -40,3 +44,5 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.m]] {
 
     objc-torture-execute $src $additional_flags
 }
+
+torture-finish
index 38329f1a729fe91fe24b13b8d23d8bdb301337ec..c69d9f4c70f7c8954bda55c09d45a0c33512012b 100644 (file)
@@ -24,6 +24,10 @@ if $tracelevel then {
 
 # load support procs
 load_lib objc-torture.exp
+load_lib torture-options.exp
+
+torture-init
+set-torture-options $OBJC_TORTURE_OPTIONS $OBJC_RUNTIME_OPTIONS
 
 #
 # main test loop
@@ -37,3 +41,5 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.m]] {
 
     objc-torture-execute $src
 }
+
+torture-finish
index 3e98750e75159150e11f56ee5223f270a75bcff2..f1f5a8ea70c537697f216e82e52e3888b7d28b62 100644 (file)
@@ -1,3 +1,7 @@
+2008-05-15  Janis Johnson  <janis187@us.ibm.com>
+
+       * testsuite/lib/libgomp.exp: Load torture-options.exp from gcc lib.
+
 2008-05-07  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/36106
index 2e9f9d8a72643b954c87d3f61c4a81eeee16747d..274ee17f0a7e3cacf70a430297fb9a1d58ad887a 100644 (file)
@@ -21,6 +21,7 @@ load_gcc_lib prune.exp
 load_gcc_lib target-libpath.exp
 load_gcc_lib wrapper.exp
 load_gcc_lib gcc-defs.exp
+load_gcc_lib torture-options.exp
 load_gcc_lib gcc-dg.exp
 load_gcc_lib gfortran-dg.exp