diff mbox

Avoid inter-test dependencies in gfortran.dg (PR fortran/56408)

Message ID 20140915161347.GN17454@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Sept. 15, 2014, 4:13 p.m. UTC
Hi!

Here is an attempt to fix gfortran dg.exp testing in case of very
fine-grained parallelization.
So far tested just with
make check-gfortran "RUNTESTFLAGS=dg.exp='binding_label_tests_10_main.f03 binding_label_tests_11_main.f03 binding_label_tests_13_main.f03 binding_label_tests_26b.f90 coarray_29_2.f90 test_common_binding_labels_2_main.f03 test_common_binding_labels_3_main.f03 whole_file_29.f90 whole_file_31.f90 class_45b.f03 class_4a.f03'"
and
make check-gfortran "RUNTESTFLAGS=dg.exp='binding_label_tests_10.f03 binding_label_tests_11.f03 binding_label_tests_13.f03 binding_label_tests_26a.f90 coarray_29_1.f90 test_common_binding_labels_2.f03 test_common_binding_labels_3.f03 whole_file_28.f90 whole_file_30.f90 class_45a.f03 class_4b.f03 class_4c.f03'"
where the latter would keep around tons of non-cleaned up modules and
the former would mostly fail.
The patch introduces a new dg-compile-aux-modules directive which instructs
dejagnu to compile the in there named test first (that test shouldn't
need to have keep-modules; but you probably need cleanup-modules in the
test that uses dg-compile-aux-modules because the tests won't be automatically
discovered (perhaps can be changed later)).

2014-09-15  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/56408
	* gfortran.dg/dg.exp (gfortran_test_path, gfortran_aux_module_flags):
	New global vars.
	(dg-compile-aux-modules): New procedure.
	* gfortran.dg/binding_label_tests_10.f03: Remove comment
	and keep-modules.
	* gfortran.dg/binding_label_tests_10_main.f03: Remove comment,
	use dg-compile-aux-modules.
	* gfortran.dg/binding_label_tests_11.f03: Remove comment
	and keep-modules.
	* gfortran.dg/binding_label_tests_11_main.f03: Remove comment,
	use dg-compile-aux-modules.
	* gfortran.dg/binding_label_tests_13.f03: Remove comment
	and keep-modules.
	* gfortran.dg/binding_label_tests_13_main.f03: Remove comment,
	use dg-compile-aux-modules.
	* gfortran.dg/binding_label_tests_26a.f90: Remove comment
	and keep-modules.
	* gfortran.dg/binding_label_tests_26b.f90: Remove comment,
	use dg-compile-aux-modules.
	* gfortran.dg/class_45a.f03: Remove keep-modules.
	* gfortran.dg/class_45b.f03: Use dg-compile-aux-modules
	and cleanup-modules.
	* gfortran.dg/class_4a.f03: Use dg-do link, use
	dg-additional-sources and cleanup-modules, remove keep-modules
	and update comment.
	* gfortran.dg/class_4b.f03: Don't compile anywhere, remove
	keep-modules, adjust comment.
	* gfortran.dg/class_4c.f03: Don't compile anywhere, remove
	dg-additional-sources and cleanup-modules.
	* gfortran.dg/coarray_29_1.f90: Remove keep-modules and
	associated comment.
	* gfortran.dg/coarray_29_2.f90: Use dg-compile-aux-modules,
	remove comment.
	* gfortran.dg/test_common_binding_labels_2.f03: Remove keep-modules.
	* gfortran.dg/test_common_binding_labels_2_main.f03: Remove comment,
	use dg-compile-aux-modules.
	* gfortran.dg/test_common_binding_labels_3.f03: Remove keep-modules.
	* gfortran.dg/test_common_binding_labels_3_main.f03: Remove comment,
	use dg-compile-aux-modules.
	* gfortran.dg/whole_file_28.f90: Remove comment and keep-modules.
	* gfortran.dg/whole_file_29.f90: Remove comment, use
	dg-compile-aux-modules.
	* gfortran.dg/whole_file_30.f90: Remove comment and keep-modules.
	* gfortran.dg/whole_file_31.f90: Remove comment, use
	dg-compile-aux-modules.


	Jakub

Comments

Mike Stump Sept. 15, 2014, 5:48 p.m. UTC | #1
On Sep 15, 2014, at 9:13 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Here is an attempt to fix gfortran dg.exp testing in case of very
> fine-grained parallelization.

Ok.
Bernhard Reutner-Fischer Sept. 15, 2014, 10:59 p.m. UTC | #2
On 15 September 2014 19:49:03 Mike Stump <mikestump@comcast.net> wrote:

> On Sep 15, 2014, at 9:13 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> > Here is an attempt to fix gfortran dg.exp testing in case of very
> > fine-grained parallelization.
>
> Ok.

Looks like the right approach, yes.
Many thanks for doing this!
Cheers,

Sent with AquaMail for Android
http://www.aqua-mail.com
VandeVondele Joost Sept. 16, 2014, 8:28 a.m. UTC | #3
Hi Jakub,

thanks!

> +    dg-test $gfortran_test_path/[lindex $args 1] "" $gfortran_aux_module_flags
> +    # cleanup-modules isn't intentionally invoked here.

should this be 'is intentionally not invoked here' ?

I'm currently seeing a lot of errors in the log of make -j32 -k check.  Similar to the ones below.

Joost

ERROR: tcl error sourcing /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/dg.exp.
ERROR: can't rename "dg-save-unknown": command doesn't exist
    while executing
"rename dg-save-unknown unknown"
    (procedure "saved-dg-test" line 96)
    invoked from within
"saved-dg-test /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/test_common_binding_labels_2_main.f03 {  -O } { -pedantic-errors}"
    ("eval" body line 1)
    invoked from within
"eval saved-dg-test $args "
    (procedure "dg-test" line 11)
    invoked from within
"dg-test $test "$flags $flags_t" ${default-extra-flags}"
    (procedure "gfortran-dg-runtest" line 28)
    invoked from within
"gfortran-dg-runtest [lsort \
       [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] "" $DEFAULT_FFLAGS"
    (file "/data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/dg.exp" line 47)
    invoked from within
"source /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/dg.exp"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 source /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/dg.exp"
    invoked from within
"catch "uplevel #0 source $test_file_name""
Running /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/gomp/gomp.exp ...
ERROR: tcl error sourcing /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/gomp/gomp.exp.
ERROR: torture-init: torture_without_loops is not empty as expected
    while executing
"error "torture-init: torture_without_loops is not empty as expected""
    invoked from within
"if [info exists torture_without_loops] {
	error "torture-init: torture_without_loops is not empty as expected"
    }"
    (procedure "torture-init" line 4)
    invoked from within
"torture-init"
    (procedure "gfortran-dg-runtest" line 5)
    invoked from within
"gfortran-dg-runtest [lsort \
       [find $srcdir/$subdir *.\[fF\]{,90,95,03,08} ] ] "" "-fopenmp""
    (file "/data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/gomp/gomp.exp" line 32)
    invoked from within
"source /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/gomp/gomp.exp"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 source /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/gomp/gomp.exp"
    invoked from within
"catch "uplevel #0 source $test_file_name""
Running /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/graphite/graphite.exp ...
ERROR: tcl error sourcing /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/graphite/graphite.exp.
Jakub Jelinek Sept. 16, 2014, 8:42 a.m. UTC | #4
On Tue, Sep 16, 2014 at 08:28:48AM +0000, VandeVondele  Joost wrote:
> > +    dg-test $gfortran_test_path/[lindex $args 1] "" $gfortran_aux_module_flags
> > +    # cleanup-modules isn't intentionally invoked here.
> 
> should this be 'is intentionally not invoked here' ?

Isn't that the same?

> I'm currently seeing a lot of errors in the log of make -j32 -k check.  Similar to the ones below.

Weird.  Works just fine for me, on two different boxes,
one with dejagnu 1.5 and one with dejagnu 1.5.1.  There is
no dg-save-unknown in gfortran.dg/test_common_binding_labels_2_main.f03,
but dg-compile-aux-modules and that is defined in gfortran.dg/dg.exp.
> 
> ERROR: tcl error sourcing /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/dg.exp.
> ERROR: can't rename "dg-save-unknown": command doesn't exist
>     while executing
> "rename dg-save-unknown unknown"
>     (procedure "saved-dg-test" line 96)
>     invoked from within
> "saved-dg-test /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/test_common_binding_labels_2_main.f03 {  -O } { -pedantic-errors}"
>     ("eval" body line 1)
>     invoked from within
> "eval saved-dg-test $args "
>     (procedure "dg-test" line 11)
>     invoked from within
> "dg-test $test "$flags $flags_t" ${default-extra-flags}"
>     (procedure "gfortran-dg-runtest" line 28)
>     invoked from within
> "gfortran-dg-runtest [lsort \
>        [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] "" $DEFAULT_FFLAGS"
>     (file "/data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/dg.exp" line 47)
>     invoked from within
> "source /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/dg.exp"
>     ("uplevel" body line 1)
>     invoked from within
> "uplevel #0 source /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/dg.exp"
>     invoked from within
> "catch "uplevel #0 source $test_file_name""
> Running /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/gomp/gomp.exp ...
> ERROR: tcl error sourcing /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/gomp/gomp.exp.
> ERROR: torture-init: torture_without_loops is not empty as expected
>     while executing
> "error "torture-init: torture_without_loops is not empty as expected""
>     invoked from within
> "if [info exists torture_without_loops] {
> 	error "torture-init: torture_without_loops is not empty as expected"
>     }"
>     (procedure "torture-init" line 4)
>     invoked from within
> "torture-init"
>     (procedure "gfortran-dg-runtest" line 5)
>     invoked from within
> "gfortran-dg-runtest [lsort \
>        [find $srcdir/$subdir *.\[fF\]{,90,95,03,08} ] ] "" "-fopenmp""
>     (file "/data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/gomp/gomp.exp" line 32)
>     invoked from within
> "source /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/gomp/gomp.exp"
>     ("uplevel" body line 1)
>     invoked from within
> "uplevel #0 source /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/gomp/gomp.exp"
>     invoked from within
> "catch "uplevel #0 source $test_file_name""
> Running /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/graphite/graphite.exp ...
> ERROR: tcl error sourcing /data/vjoost/gnu/gcc_trunk/gcc/gcc/testsuite/gfortran.dg/graphite/graphite.exp.

	Jakub
Jakub Jelinek Sept. 16, 2014, 8:47 a.m. UTC | #5
On Tue, Sep 16, 2014 at 10:42:46AM +0200, Jakub Jelinek wrote:
> > I'm currently seeing a lot of errors in the log of make -j32 -k check.  Similar to the ones below.
> 
> Weird.  Works just fine for me, on two different boxes,
> one with dejagnu 1.5 and one with dejagnu 1.5.1.  There is
> no dg-save-unknown in gfortran.dg/test_common_binding_labels_2_main.f03,
> but dg-compile-aux-modules and that is defined in gfortran.dg/dg.exp.

Looking around in gcc-testresults, for some people (e.g. H.J.'s testresults,
Andreas Schwab ia64, etc.) it works just fine too,
https://gcc.gnu.org/ml/gcc-testresults/2014-09/msg01551.html
shows the same symptomps as you report.  What dejagnu version are you using?

	Jakub
Paolo Carlini Sept. 16, 2014, 8:56 a.m. UTC | #6
Hi,

On 09/16/2014 10:42 AM, Jakub Jelinek wrote:
> On Tue, Sep 16, 2014 at 08:28:48AM +0000, VandeVondele  Joost wrote:
>>> +    dg-test $gfortran_test_path/[lindex $args 1] "" $gfortran_aux_module_flags
>>> +    # cleanup-modules isn't intentionally invoked here.
>> should this be 'is intentionally not invoked here' ?
> Isn't that the same?
Well, if the module "isn't intentionally invoked" it could still be 
invoked, only, not intentionally. If something "is intentionally not 
invoked", that can't happen, because the code intentionally, 'actively' 
so to speak, does *not* invoke it.

My guess too is that you want the latter exact meaning.

Paolo.
VandeVondele Joost Sept. 16, 2014, 8:58 a.m. UTC | #7
>> What dejagnu version are you using?

> runtest --version
WARNING: Couldn't find the global config file.
Expect version is	5.44.1.15
Tcl version is		8.5
Framework version is	1.4.4
Andreas Schwab Sept. 16, 2014, 9:14 a.m. UTC | #8
"VandeVondele  Joost" <joost.vandevondele@mat.ethz.ch> writes:

>>> What dejagnu version are you using?
>
>> runtest --version
> WARNING: Couldn't find the global config file.
> Expect version is	5.44.1.15
> Tcl version is		8.5
> Framework version is	1.4.4

You need at least dejagnu 1.5, which includes this fix:

http://git.savannah.gnu.org/cgit/dejagnu.git/commit/?id=fd70857

Andreas.
VandeVondele Joost Sept. 16, 2014, 9:17 a.m. UTC | #9
> > Framework version is  1.4.4
> You need at least dejagnu 1.5, which includes this fix:

I see, but that's contrary to :
https://gcc.gnu.org/install/prerequisites.html
Jakub Jelinek Sept. 16, 2014, 9:21 a.m. UTC | #10
On Tue, Sep 16, 2014 at 11:14:33AM +0200, Andreas Schwab wrote:
> "VandeVondele  Joost" <joost.vandevondele@mat.ethz.ch> writes:
> 
> >>> What dejagnu version are you using?
> >
> >> runtest --version
> > WARNING: Couldn't find the global config file.
> > Expect version is	5.44.1.15
> > Tcl version is		8.5
> > Framework version is	1.4.4
> 
> You need at least dejagnu 1.5, which includes this fix:
> 
> http://git.savannah.gnu.org/cgit/dejagnu.git/commit/?id=fd70857

BTW, even that change doesn't look right to me,
with nested calls, my reading of the change is that in case of
nested calls, the outer one will rename unknown to dg-save-unknown,
then inner call will not rename anything because dg-save-unknown
already exists, then when about to return, the nested call will rename
dg-save-unknown to unknown (but, I'd say that it should be the outer, not
inner call that does that), then the outer call will not rename anything.
So, either it can use a trick with [info level] I've used, or just remember
in some local variable if a particular call renamed it and only if it did,
rename it back.

	Jakub
Thomas Schwinge March 21, 2019, 7:34 p.m. UTC | #11
Hi!

On Mon, 15 Sep 2014 18:13:47 +0200, Jakub Jelinek <jakub@redhat.com> wrote:
> --- gcc/testsuite/gfortran.dg/dg.exp.jj	2014-07-04 10:20:35.000000000 +0200
> +++ gcc/testsuite/gfortran.dg/dg.exp	2014-09-15 17:05:04.038126245 +0200

> +proc dg-compile-aux-modules { args } {
> +    global gfortran_test_path
> +    global gfortran_aux_module_flags
> +    if { [llength $args] != 2 } {
> +	error "dg-set-target-env-var: needs one argument"

As obvious committed "[testsuite] Fix 'dg-compile-aux-modules'
diagnostic" to trunk in r269851, to gcc-8-branch in r269852, and to
gcc-7-branch in r269853, see attached.


Grüße
 Thomas
From f2137b85e1a6b044a2398de20ef8d458734dc6e6 Mon Sep 17 00:00:00 2001
From: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 21 Mar 2019 19:29:57 +0000
Subject: [PATCH] [testsuite] Fix 'dg-compile-aux-modules' diagnostic

	gcc/testsuite/
	PR fortran/56408
	* gcc.target/powerpc/ppc-fortran/ppc-fortran.exp
	(dg-compile-aux-modules): Fix diagnostic.
	* gfortran.dg/coarray/caf.exp (dg-compile-aux-modules): Likewise.
	* gfortran.dg/dg.exp (dg-compile-aux-modules): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@269851 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/testsuite/ChangeLog                                     | 6 ++++++
 .../gcc.target/powerpc/ppc-fortran/ppc-fortran.exp          | 2 +-
 gcc/testsuite/gfortran.dg/coarray/caf.exp                   | 2 +-
 gcc/testsuite/gfortran.dg/dg.exp                            | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 40446965212e..a5211cca6c6a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,11 @@
 2019-03-21  Thomas Schwinge  <thomas@codesourcery.com>
 
+	PR fortran/56408
+	* gcc.target/powerpc/ppc-fortran/ppc-fortran.exp
+	(dg-compile-aux-modules): Fix diagnostic.
+	* gfortran.dg/coarray/caf.exp (dg-compile-aux-modules): Likewise.
+	* gfortran.dg/dg.exp (dg-compile-aux-modules): Likewise.
+
 	PR fortran/56408
 	* gfortran.dg/coarray/caf.exp (dg-compile-aux-modules): Workaround
 	missing nexted dg-test call support in dejaGNU 1.4.4.
diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-fortran/ppc-fortran.exp b/gcc/testsuite/gcc.target/powerpc/ppc-fortran/ppc-fortran.exp
index 53c3c7464423..586d7dd3019e 100644
--- a/gcc/testsuite/gcc.target/powerpc/ppc-fortran/ppc-fortran.exp
+++ b/gcc/testsuite/gcc.target/powerpc/ppc-fortran/ppc-fortran.exp
@@ -36,7 +36,7 @@ proc dg-compile-aux-modules { args } {
     global gfortran_test_path
     global gfortran_aux_module_flags
     if { [llength $args] != 2 } {
-	error "dg-set-target-env-var: needs one argument"
+	error "dg-compile-aux-modules: needs one argument"
 	return
     }
 
diff --git a/gcc/testsuite/gfortran.dg/coarray/caf.exp b/gcc/testsuite/gfortran.dg/coarray/caf.exp
index e3204c34779b..68b60b86a949 100644
--- a/gcc/testsuite/gfortran.dg/coarray/caf.exp
+++ b/gcc/testsuite/gfortran.dg/coarray/caf.exp
@@ -51,7 +51,7 @@ proc dg-compile-aux-modules { args } {
     global gfortran_test_path
     global gfortran_aux_module_flags
     if { [llength $args] != 2 } {
-	error "dg-set-target-env-var: needs one argument"
+	error "dg-compile-aux-modules: needs one argument"
 	return
     }
 
diff --git a/gcc/testsuite/gfortran.dg/dg.exp b/gcc/testsuite/gfortran.dg/dg.exp
index 53c3c7464423..586d7dd3019e 100644
--- a/gcc/testsuite/gfortran.dg/dg.exp
+++ b/gcc/testsuite/gfortran.dg/dg.exp
@@ -36,7 +36,7 @@ proc dg-compile-aux-modules { args } {
     global gfortran_test_path
     global gfortran_aux_module_flags
     if { [llength $args] != 2 } {
-	error "dg-set-target-env-var: needs one argument"
+	error "dg-compile-aux-modules: needs one argument"
 	return
     }
diff mbox

Patch

--- gcc/testsuite/gfortran.dg/dg.exp.jj	2014-07-04 10:20:35.000000000 +0200
+++ gcc/testsuite/gfortran.dg/dg.exp	2014-09-15 17:05:04.038126245 +0200
@@ -28,6 +28,21 @@  if ![info exists DEFAULT_FFLAGS] then {
 # Initialize `dg'.
 dg-init
 
+global gfortran_test_path
+global gfortran_aux_module_flags
+set gfortran_test_path $srcdir/$subdir
+set gfortran_aux_module_flags $DEFAULT_FFLAGS
+proc dg-compile-aux-modules { args } {
+    global gfortran_test_path
+    global gfortran_aux_module_flags
+    if { [llength $args] != 2 } {
+	error "dg-set-target-env-var: needs one argument"
+	return
+    }
+    dg-test $gfortran_test_path/[lindex $args 1] "" $gfortran_aux_module_flags
+    # cleanup-modules isn't intentionally invoked here.
+}
+
 # Main loop.
 gfortran-dg-runtest [lsort \
        [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] "" $DEFAULT_FFLAGS
--- gcc/testsuite/gfortran.dg/binding_label_tests_10.f03.jj	2012-03-20 08:51:24.000000000 +0100
+++ gcc/testsuite/gfortran.dg/binding_label_tests_10.f03	2014-09-15 16:50:57.710322608 +0200
@@ -1,9 +1,6 @@ 
 ! { dg-do compile }
-! This file must be compiled BEFORE binding_label_tests_10_main.f03, which it 
-! should be because dejagnu will sort the files.
 module binding_label_tests_10
   use iso_c_binding
   implicit none
   integer(c_int), bind(c,name="c_one") :: one
 end module binding_label_tests_10
-! { dg-final { keep-modules "" } }
--- gcc/testsuite/gfortran.dg/binding_label_tests_10_main.f03.jj	2014-01-13 08:54:27.000000000 +0100
+++ gcc/testsuite/gfortran.dg/binding_label_tests_10_main.f03	2014-09-15 17:05:57.810859201 +0200
@@ -1,6 +1,5 @@ 
 ! { dg-do compile }
-! This file must be compiled AFTER binding_label_tests_10.f03, which it 
-! should be because dejagnu will sort the files.
+! { dg-compile-aux-modules "binding_label_tests_10.f03" }
 module binding_label_tests_10_main
   use iso_c_binding
   implicit none
--- gcc/testsuite/gfortran.dg/binding_label_tests_11.f03.jj	2012-03-20 08:51:24.000000000 +0100
+++ gcc/testsuite/gfortran.dg/binding_label_tests_11.f03	2014-09-15 17:07:15.888471110 +0200
@@ -1,6 +1,4 @@ 
 ! { dg-do compile }
-! This file must be compiled BEFORE binding_label_tests_11_main.f03, which it 
-! should be because dejagnu will sort the files.
 module binding_label_tests_11
   use iso_c_binding, only: c_int
   implicit none
@@ -10,4 +8,3 @@  contains
     one = 1
   end function one
 end module binding_label_tests_11
-! { dg-final { keep-modules "" } }
--- gcc/testsuite/gfortran.dg/binding_label_tests_11_main.f03.jj	2013-05-21 09:43:19.000000000 +0200
+++ gcc/testsuite/gfortran.dg/binding_label_tests_11_main.f03	2014-09-15 17:07:02.149538779 +0200
@@ -1,6 +1,5 @@ 
 ! { dg-do compile }
-! This file must be compiled AFTER binding_label_tests_11.f03, which it 
-! should be because dejagnu will sort the files.
+! { dg-compile-aux-modules "binding_label_tests_11.f03" }
 module binding_label_tests_11_main
   use iso_c_binding, only: c_int
   implicit none
--- gcc/testsuite/gfortran.dg/binding_label_tests_13.f03.jj	2012-03-20 08:51:24.000000000 +0100
+++ gcc/testsuite/gfortran.dg/binding_label_tests_13.f03	2014-09-15 17:07:25.603422353 +0200
@@ -1,9 +1,6 @@ 
 ! { dg-do compile }
-! This file must be compiled BEFORE binding_label_tests_13_main.f03, which it 
-! should be because dejagnu will sort the files.  
 module binding_label_tests_13
  use, intrinsic :: iso_c_binding, only: c_int
   integer(c_int) :: c3
   bind(c) c3
 end module binding_label_tests_13
-! { dg-final { keep-modules "" } }
--- gcc/testsuite/gfortran.dg/binding_label_tests_13_main.f03.jj	2013-05-21 09:43:20.000000000 +0200
+++ gcc/testsuite/gfortran.dg/binding_label_tests_13_main.f03	2014-09-15 17:07:52.815288018 +0200
@@ -1,7 +1,5 @@ 
 ! { dg-do compile }
-! This file must be compiled AFTER binding_label_tests_13.f03, which it 
-! should be because dejagnu will sort the files.  The module file 
-! binding_label_tests_13.mod can not be removed until after this test is done.
+! { dg-compile-aux-modules "binding_label_tests_13.f03" }
 module binding_label_tests_13_main
   use, intrinsic :: iso_c_binding, only: c_int
   integer(c_int) :: c3  ! { dg-error "Variable c3 from module binding_label_tests_13_main with binding label c3 at .1. uses the same global identifier as entity at .2. from module binding_label_tests_13" }
--- gcc/testsuite/gfortran.dg/binding_label_tests_26a.f90.jj	2014-01-08 17:45:05.000000000 +0100
+++ gcc/testsuite/gfortran.dg/binding_label_tests_26a.f90	2014-09-15 17:08:27.768112809 +0200
@@ -4,8 +4,6 @@ 
 !
 ! Contributed by Andrew Bensons <abensonca@gmail.com>
 !
-! This file must be compiled BEFORE binding_label_tests_26b.f90, which it 
-! should be because dejagnu will sort the files.  
 
 module fg
 contains
@@ -16,5 +14,3 @@  contains
     end interface
   end function
 end module
-
-! { dg-final { keep-modules "" } }
--- gcc/testsuite/gfortran.dg/binding_label_tests_26b.f90.jj	2014-01-08 17:45:05.000000000 +0100
+++ gcc/testsuite/gfortran.dg/binding_label_tests_26b.f90	2014-09-15 17:08:58.460961242 +0200
@@ -1,11 +1,9 @@ 
 ! { dg-do compile }
+! { dg-compile-aux-modules "binding_label_tests_26a.f90" }
 !
 ! PR 58182: [4.9 Regression] ICE with global binding name used as a FUNCTION
 !
 ! Contributed by Andrew Bensons <abensonca@gmail.com>
-!
-! This file must be compiled AFTER binding_label_tests_26a.f90, which it 
-! should be because dejagnu will sort the files.  
 
 module f    ! { dg-error "uses the same global identifier" }
   use fg    ! { dg-error "uses the same global identifier" }
--- gcc/testsuite/gfortran.dg/class_45a.f03.jj	2012-03-20 08:51:24.000000000 +0100
+++ gcc/testsuite/gfortran.dg/class_45a.f03	2014-09-15 17:15:52.800901905 +0200
@@ -26,4 +26,3 @@  contains
   end function basicGet
 
 end module G_Nodes
-! { dg-final { keep-modules "" } }
--- gcc/testsuite/gfortran.dg/class_45b.f03.jj	2012-05-17 08:40:32.000000000 +0200
+++ gcc/testsuite/gfortran.dg/class_45b.f03	2014-09-15 17:17:03.854547243 +0200
@@ -1,5 +1,5 @@ 
 ! { dg-do link }
-! { dg-additional-sources class_45a.f03 }
+! { dg-compile-aux-modules "class_45a.f03" }
 !
 ! PR 50227: [4.7 Regression] [OOP] ICE-on-valid with allocatable class variable
 !
@@ -10,3 +10,4 @@  program Test
   class(t0), allocatable :: c
   allocate(t1 :: c)
 end program Test
+! { dg-final { cleanup-modules "G_Nodes" } }
--- gcc/testsuite/gfortran.dg/class_4a.f03.jj	2012-03-20 08:51:24.000000000 +0100
+++ gcc/testsuite/gfortran.dg/class_4a.f03	2014-09-15 17:23:35.315599421 +0200
@@ -1,10 +1,11 @@ 
-! { dg-do compile }
+! { dg-do link }
+! { dg-additional-sources "class_4b.f03 class_4c.f03" }
 !
 ! Test the fix for PR41583, in which the different source files
 ! would generate the same 'vindex' for different class declared
 ! types.
 !
-! The test comprises class_4a, class_4b class_4c and class_4d.f03
+! The test comprises class_4a, class_4b and class_4c.f03
 
 ! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
 !
@@ -12,4 +13,4 @@  module m
   type t
   end type t
 end module m
-! { dg-final { keep-modules "m" } }
+! { dg-final { cleanup-modules "m m2" } }
--- gcc/testsuite/gfortran.dg/class_4b.f03.jj	2012-03-20 08:51:24.000000000 +0100
+++ gcc/testsuite/gfortran.dg/class_4b.f03	2014-09-15 16:08:50.064931051 +0200
@@ -1,10 +1,11 @@ 
-! { dg-do compile }
+! Don't compile this anywhere.
+! { dg-do compile { target { lp64 && { ! lp64 } } } }
 !
 ! Test the fix for PR41583, in which the different source files
 ! would generate the same 'vindex' for different class declared
 ! types.
 !
-! The test comprises class_4a, class_4b class_4c and class_4d.f03
+! The test comprises class_4a, class_4b class_4c.f03
 !
 ! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
 !
@@ -13,4 +14,3 @@  module m2
   type, extends(t) :: t2
   end type t2
 end module m2
-! { dg-final { keep-modules "m2" } }
--- gcc/testsuite/gfortran.dg/class_4c.f03.jj	2012-03-20 08:51:24.000000000 +0100
+++ gcc/testsuite/gfortran.dg/class_4c.f03	2014-09-15 16:08:33.870010430 +0200
@@ -1,5 +1,5 @@ 
-! { dg-do link }
-! { dg-additional-sources class_4a.f03 class_4b.f03 }
+! Don't compile this anywhere.
+! { dg-do compile { target { lp64 && { ! lp64 } } } }
 !
 ! Test the fix for PR41583, in which the different source files
 ! would generate the same 'vindex' for different class declared
@@ -27,4 +27,3 @@ 
   end select
   print *, i
 end
-! { dg-final { cleanup-modules "m m2" } }
--- gcc/testsuite/gfortran.dg/coarray_29_1.f90.jj	2012-11-12 16:58:41.000000000 +0100
+++ gcc/testsuite/gfortran.dg/coarray_29_1.f90	2014-09-15 17:12:01.948048800 +0200
@@ -11,6 +11,3 @@  contains
     integer scalar[*]
   end subroutine
 end module
-
-! DO NOT CLEAN UP THE MODULE FILE - coarray_29_2.f90 does it.
-! { dg-final { keep-modules "" } }
--- gcc/testsuite/gfortran.dg/coarray_29_2.f90.jj	2013-01-15 09:04:48.000000000 +0100
+++ gcc/testsuite/gfortran.dg/coarray_29_2.f90	2014-09-15 17:12:49.177813702 +0200
@@ -1,8 +1,6 @@ 
 ! { dg-do compile }
 ! { dg-options "-fcoarray=single" }
-
-! Requires that coarray_29.f90 has been compiled before
-! and that, thus, co_sum_module is available
+! { dg-compile-aux-modules "coarray_29_1.f90" }
 
 ! PR fortran/55272
 !
--- gcc/testsuite/gfortran.dg/test_common_binding_labels_2.f03.jj	2012-03-20 08:51:24.000000000 +0100
+++ gcc/testsuite/gfortran.dg/test_common_binding_labels_2.f03	2014-09-15 17:13:13.777692033 +0200
@@ -12,4 +12,3 @@  module test_common_binding_labels_2
   integer(c_int) :: i
   bind(c, name="") /com2/
 end module test_common_binding_labels_2
-! { dg-final { keep-modules "" } }
--- gcc/testsuite/gfortran.dg/test_common_binding_labels_2_main.f03.jj	2013-05-21 09:43:20.000000000 +0200
+++ gcc/testsuite/gfortran.dg/test_common_binding_labels_2_main.f03	2014-09-15 17:13:49.344513701 +0200
@@ -1,9 +1,7 @@ 
 ! { dg-do compile }
 ! { dg-options "-std=f2003" }
+! { dg-compile-aux-modules "test_common_binding_labels_2.f03" }
 !
-!
-! This file depends on the module test_common_binding_labels_2.  That module
-! must be compiled first and not be removed until after this test.
 module test_common_binding_labels_2_main
   use, intrinsic :: iso_c_binding, only: c_double, c_int
   implicit none
--- gcc/testsuite/gfortran.dg/test_common_binding_labels_3.f03.jj	2012-03-20 08:51:24.000000000 +0100
+++ gcc/testsuite/gfortran.dg/test_common_binding_labels_3.f03	2014-09-15 17:13:18.355668395 +0200
@@ -8,4 +8,3 @@  module test_common_binding_labels_3
   real(c_double) :: s
   bind(c, name="my_common_block") :: /mycom/
 end module test_common_binding_labels_3
-! { dg-final { keep-modules "" } }
--- gcc/testsuite/gfortran.dg/test_common_binding_labels_3_main.f03.jj	2013-05-21 09:43:20.000000000 +0200
+++ gcc/testsuite/gfortran.dg/test_common_binding_labels_3_main.f03	2014-09-15 17:14:01.655453621 +0200
@@ -1,6 +1,5 @@ 
 ! { dg-do compile }
-! This file depends on the module test_common_binding_labels_3.  That module
-! must be compiled first and not be removed until after this test.
+! { dg-compile-aux-modules "test_common_binding_labels_3.f03" }
 module test_common_binding_labels_3_main
   use, intrinsic :: iso_c_binding, only: c_int
   integer(c_int), bind(c, name="my_common_block") :: my_int ! { dg-error "COMMON block at .1. with binding label my_common_block uses the same global identifier as entity at .2." }
--- gcc/testsuite/gfortran.dg/whole_file_28.f90.jj	2012-03-20 08:51:24.000000000 +0100
+++ gcc/testsuite/gfortran.dg/whole_file_28.f90	2014-09-15 17:15:09.217117852 +0200
@@ -1,6 +1,5 @@ 
 ! { dg-do compile }
 ! Test the fix for the problem described in PR45077 comments #4 and #5.
-! Note that the module file is kept for whole_file_29.f90
 !
 ! Contributed by Tobias Burnus  <burnus@gcc.gnu.org>
 !
@@ -9,5 +8,3 @@  module iso_red
      character(LEN=1), dimension(:), allocatable :: chars
   end type varying_string
 end module iso_red
-! DO NOT CLEAN UP THE MODULE FILE - whole_file_29.f90 does it.
-! { dg-final { keep-modules "" } }
--- gcc/testsuite/gfortran.dg/whole_file_29.f90.jj	2012-03-20 08:51:24.000000000 +0100
+++ gcc/testsuite/gfortran.dg/whole_file_29.f90	2014-09-15 17:14:56.401181922 +0200
@@ -1,7 +1,6 @@ 
 ! { dg-do compile }
+! { dg-compile-aux-modules "whole_file_28.f90" }
 ! Test the fix for the problem described in PR45077 comments #4 and #5.
-! Note that the module file from whole_file_28.f90, 'iso_red', is
-! needed for this test.
 !
 ! Contributed by Tobias Burnus  <burnus@gcc.gnu.org>
 !
--- gcc/testsuite/gfortran.dg/whole_file_30.f90.jj	2012-03-20 08:51:24.000000000 +0100
+++ gcc/testsuite/gfortran.dg/whole_file_30.f90	2014-09-15 17:15:04.512141212 +0200
@@ -1,6 +1,5 @@ 
 ! { dg-do compile }
 ! Test the fix for the problem described in PR46818.
-! Note that the module file is kept for whole_file_31.f90
 !
 ! Contributed by Martien Hulsen  <m.a.hulsen@tue.nl>
 ! and reduced by Tobias Burnus  <burnus@gcc.gnu.org>
@@ -12,5 +11,3 @@  module system_defs_m
     real, allocatable, dimension(:) :: u
   end type sysvector_t
 end module system_defs_m
-! DO NOT CLEAN UP THE MODULE FILE - whole_file_31.f90 does it.
-! { dg-final { keep-modules "" } }
--- gcc/testsuite/gfortran.dg/whole_file_31.f90.jj	2012-03-20 08:51:24.000000000 +0100
+++ gcc/testsuite/gfortran.dg/whole_file_31.f90	2014-09-15 17:15:23.347047734 +0200
@@ -1,7 +1,6 @@ 
 ! { dg-do compile }
+! { dg-compile-aux-modules "whole_file_30.f90" }
 ! Test the fix for the problem described in PR46818.
-! Note that the module file from whole_file_30.f90, 'system_defs_m',
-! is needed for this test.
 !
 ! Contributed by Martien Hulsen  <m.a.hulsen@tue.nl>
 ! and reduced by Tobias Burnus  <burnus@gcc.gnu.org>