This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PCH] Testing by comparing .s files
- From: Geoffrey Keating <gkeating at apple dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 11 Nov 2002 15:40:02 -0800 (PST)
- Subject: [PCH] Testing by comparing .s files
This changes the testing framework for PCH to work by comparing the .s
files with and without a PCH. I'd always meant to do it this way,
because this gives certain assurance that the PCH file doesn't change
the compiler's behaviour.
Tested by running pch.exp on an unstable compiler.
--
- Geoffrey Keating <geoffk@apple.com>
===File ~/patches/pchbranch-dotscompare.patch===============
2002-11-11 Geoffrey Keating <geoffk@apple.com>
* gcc.dg/pch/pch.exp: Compare .s files with/without PCH,
rather than trying to build and run a program using PCH.
* gcc.dg/pch: Remove dg-do commands from test files.
Index: testsuite/gcc.dg/pch/common-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/common-1.c,v
retrieving revision 1.1.2.1
diff -u -p -u -p -r1.1.2.1 common-1.c
--- testsuite/gcc.dg/pch/common-1.c 4 Nov 2002 19:00:26 -0000 1.1.2.1
+++ testsuite/gcc.dg/pch/common-1.c 11 Nov 2002 23:37:36 -0000
@@ -1,4 +1,3 @@
-/* { dg-do compile } */
#include "common-1.h"
int foo2 = 3;
int zz = 2;
Index: testsuite/gcc.dg/pch/decl-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/decl-1.c,v
retrieving revision 1.1.2.1
diff -u -p -u -p -r1.1.2.1 decl-1.c
--- testsuite/gcc.dg/pch/decl-1.c 4 Nov 2002 19:00:26 -0000 1.1.2.1
+++ testsuite/gcc.dg/pch/decl-1.c 11 Nov 2002 23:37:36 -0000
@@ -1,3 +1,2 @@
-/* { dg-do compile } */
#include "decl-1.h"
int main(void) { return foo; }
Index: testsuite/gcc.dg/pch/decl-2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/decl-2.c,v
retrieving revision 1.1.2.1
diff -u -p -u -p -r1.1.2.1 decl-2.c
--- testsuite/gcc.dg/pch/decl-2.c 4 Nov 2002 19:00:26 -0000 1.1.2.1
+++ testsuite/gcc.dg/pch/decl-2.c 11 Nov 2002 23:37:36 -0000
@@ -1,3 +1,2 @@
-/* { dg-do compile } */
#include "decl-2.h"
int main(void) { return fun (1, 2); }
Index: testsuite/gcc.dg/pch/decl-3.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/decl-3.c,v
retrieving revision 1.1.2.1
diff -u -p -u -p -r1.1.2.1 decl-3.c
--- testsuite/gcc.dg/pch/decl-3.c 4 Nov 2002 19:00:26 -0000 1.1.2.1
+++ testsuite/gcc.dg/pch/decl-3.c 11 Nov 2002 23:37:36 -0000
@@ -1,4 +1,3 @@
-/* { dg-do compile } */
#include "decl-3.h"
foo_p bar (void)
Index: testsuite/gcc.dg/pch/decl-4.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/decl-4.c,v
retrieving revision 1.1.2.1
diff -u -p -u -p -r1.1.2.1 decl-4.c
--- testsuite/gcc.dg/pch/decl-4.c 4 Nov 2002 19:00:26 -0000 1.1.2.1
+++ testsuite/gcc.dg/pch/decl-4.c 11 Nov 2002 23:37:36 -0000
@@ -1,4 +1,3 @@
-/* { dg-do compile } */
#include "decl-4.h"
int bar (foo_p f)
Index: testsuite/gcc.dg/pch/decl-5.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/decl-5.c,v
retrieving revision 1.1.2.1
diff -u -p -u -p -r1.1.2.1 decl-5.c
--- testsuite/gcc.dg/pch/decl-5.c 4 Nov 2002 19:00:26 -0000 1.1.2.1
+++ testsuite/gcc.dg/pch/decl-5.c 11 Nov 2002 23:37:36 -0000
@@ -1,3 +1,2 @@
-/* { dg-do compile } */
#include "decl-5.h"
static int (*t)(void) = foo;
Index: testsuite/gcc.dg/pch/empty.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/empty.c,v
retrieving revision 1.1.2.1
diff -u -p -u -p -r1.1.2.1 empty.c
--- testsuite/gcc.dg/pch/empty.c 27 Aug 2002 23:58:29 -0000 1.1.2.1
+++ testsuite/gcc.dg/pch/empty.c 11 Nov 2002 23:37:36 -0000
@@ -1,5 +1,3 @@
-/* { dg-do run } */
-
/* Yes, it's called "empty" because it has no contents at all.
Even this comment goes here, rather than in empty.h. */
#include "empty.hp"
Index: testsuite/gcc.dg/pch/global-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/global-1.c,v
retrieving revision 1.1.2.1
diff -u -p -u -p -r1.1.2.1 global-1.c
--- testsuite/gcc.dg/pch/global-1.c 4 Nov 2002 19:00:26 -0000 1.1.2.1
+++ testsuite/gcc.dg/pch/global-1.c 11 Nov 2002 23:37:36 -0000
@@ -1,3 +1,2 @@
-/* { dg-do compile } */
#include "global-1.h"
const int bar = 3;
Index: testsuite/gcc.dg/pch/inline-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/inline-1.c,v
retrieving revision 1.1.2.1
diff -u -p -u -p -r1.1.2.1 inline-1.c
--- testsuite/gcc.dg/pch/inline-1.c 4 Nov 2002 19:00:26 -0000 1.1.2.1
+++ testsuite/gcc.dg/pch/inline-1.c 11 Nov 2002 23:37:36 -0000
@@ -1,4 +1,3 @@
-/* { dg-do compile } */
#include "inline-1.h"
int bar(int a, int b)
{
Index: testsuite/gcc.dg/pch/inline-2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/inline-2.c,v
retrieving revision 1.1.2.1
diff -u -p -u -p -r1.1.2.1 inline-2.c
--- testsuite/gcc.dg/pch/inline-2.c 4 Nov 2002 19:00:26 -0000 1.1.2.1
+++ testsuite/gcc.dg/pch/inline-2.c 11 Nov 2002 23:37:36 -0000
@@ -1,4 +1,3 @@
-/* { dg-do compile } */
#include "inline-2.h"
extern inline char
bar(int a)
Index: testsuite/gcc.dg/pch/macro-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/macro-1.c,v
retrieving revision 1.1.2.1
diff -u -p -u -p -r1.1.2.1 macro-1.c
--- testsuite/gcc.dg/pch/macro-1.c 2 Sep 2002 00:35:03 -0000 1.1.2.1
+++ testsuite/gcc.dg/pch/macro-1.c 11 Nov 2002 23:37:36 -0000
@@ -1,5 +1,3 @@
-/* { dg-do run } */
-
#include "macro-1.hp"
int main(void)
Index: testsuite/gcc.dg/pch/macro-2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/macro-2.c,v
retrieving revision 1.1.2.1
diff -u -p -u -p -r1.1.2.1 macro-2.c
--- testsuite/gcc.dg/pch/macro-2.c 2 Sep 2002 00:35:03 -0000 1.1.2.1
+++ testsuite/gcc.dg/pch/macro-2.c 11 Nov 2002 23:37:36 -0000
@@ -1,5 +1,3 @@
-/* { dg-do run } */
-
#define DEFINED_VALUE_2 3
#include "macro-2.hp"
Index: testsuite/gcc.dg/pch/macro-3.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/macro-3.c,v
retrieving revision 1.1.2.1
diff -u -p -u -p -r1.1.2.1 macro-3.c
--- testsuite/gcc.dg/pch/macro-3.c 9 Nov 2002 01:12:23 -0000 1.1.2.1
+++ testsuite/gcc.dg/pch/macro-3.c 11 Nov 2002 23:37:36 -0000
@@ -1,5 +1,3 @@
-/* { dg-do run } */
-
#define DEFINED_FUNC_2(x) (3 + (x))
#include "macro-3.hp"
Index: testsuite/gcc.dg/pch/pch.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/pch.exp,v
retrieving revision 1.1.2.2
diff -u -p -u -p -r1.1.2.2 pch.exp
--- testsuite/gcc.dg/pch/pch.exp 2 Sep 2002 00:35:03 -0000 1.1.2.2
+++ testsuite/gcc.dg/pch/pch.exp 11 Nov 2002 23:37:36 -0000
@@ -23,6 +23,8 @@ load_lib gcc-dg.exp
# Initialize `dg'.
dg-init
+set old_dg_do_what_default "${dg-do-what-default}"
+
# Main loop.
foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
global runtests torture_without_loops dg-do-what-default
@@ -36,6 +38,8 @@ foreach test [lsort [glob -nocomplain $s
catch { file delete "$bname.hp.pch" }
catch { file delete "$bname.h.pch" }
+ catch { file delete "$bname.s" }
+ catch { file delete "$bname.s-pch" }
# We don't try to use the loop-optimizing options, since they are highly
# unlikely to make any difference to PCH.
@@ -43,10 +47,11 @@ foreach test [lsort [glob -nocomplain $s
verbose "Testing $nshort, $flags" 1
# For the header files, the default is to precompile.
- set old_dg_do_what_default "${dg-do-what-default}"
set dg-do-what-default precompile
dg-test -keep-output "[file rootname $test].h" $flags ""
- set dg-do-what-default "$old_dg_do_what_default"
+
+ # For the rest, the default is to compile to .s.
+ set dg-do-what-default compile
if { [ file exists "$bname.h.pch" ] } {
# To ensure that the PCH is used, not the original header,
@@ -56,13 +61,39 @@ foreach test [lsort [glob -nocomplain $s
remote_download host "$bname.hp.pch"
}
- dg-test $test $flags "-I."
+ dg-test -keep-output $test $flags "-I."
file delete "$bname.hp.pch"
+ if { [ file exists "$bname.s" ] } {
+ file rename "$bname.s" "$bname.s-pch"
+ if { [ is_remote host ] } {
+ remote_upload host "[file rootname $test].h" "$bname.hp"
+ } else {
+ file copy "[file rootname $test].h" "$bname.hp"
+ }
+ dg-test -keep-output $test $flags "-I."
+ remote_file host delete "$bname.hp"
+ set tmp [ diff "$bname.s" "$bname.s-pch" ]
+ if { $tmp == 0 } {
+ untested "$nshort $flags assembly comparison"
+ } elseif { $tmp == 1 } {
+ pass "$nshort $flags assembly comparison"
+ } else {
+ fail "$nshort $flags assembly comparison"
+ }
+ file delete "$bname.s"
+ file delete "$bname.s-pch"
+ } else {
+ untested "$nshort $flags assembly comparison"
+ }
+
} else {
- untested $test
+ untested $nshort
+ untested "$nshort $flags assembly comparison"
}
}
}
+
+set dg-do-what-default "$old_dg_do_what_default"
# All done.
dg-finish
Index: testsuite/gcc.dg/pch/static-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/static-1.c,v
retrieving revision 1.1.2.1
diff -u -p -u -p -r1.1.2.1 static-1.c
--- testsuite/gcc.dg/pch/static-1.c 4 Nov 2002 19:00:26 -0000 1.1.2.1
+++ testsuite/gcc.dg/pch/static-1.c 11 Nov 2002 23:37:36 -0000
@@ -1,4 +1,3 @@
-/* { dg-do compile } */
#include "static-1.h"
static int bar(void)
{
Index: testsuite/gcc.dg/pch/static-2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pch/Attic/static-2.c,v
retrieving revision 1.1.2.1
diff -u -p -u -p -r1.1.2.1 static-2.c
--- testsuite/gcc.dg/pch/static-2.c 4 Nov 2002 19:00:26 -0000 1.1.2.1
+++ testsuite/gcc.dg/pch/static-2.c 11 Nov 2002 23:37:36 -0000
@@ -1,4 +1,3 @@
-/* { dg-do compile } */
#include "static-2.h"
int bar(void)
{
============================================================