1 # Copyright (C) 1997, 2002 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # GCC testsuite for precompiled header interaction,
18 # that uses the `dg.exp' driver.
26 set old_dg_do_what_default "${dg-do-what-default}"
29 foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
30 global runtests torture_without_loops dg-do-what-default
32 # If we're only testing specific files and this isn't one of them, skip it.
33 if ![runtest_file_p $runtests $test] {
36 set nshort [file tail [file dirname $test]]/[file tail $test]
37 set bname "[file rootname [file tail $test]]"
39 catch { file delete "$bname.hp.pch" }
40 catch { file delete "$bname.h.pch" }
41 catch { file delete "$bname.s" }
42 catch { file delete "$bname.s-pch" }
43 catch { file delete "$bname.hp" }
45 # We don't try to use the loop-optimizing options, since they are highly
46 # unlikely to make any difference to PCH.
47 foreach flags $torture_without_loops {
48 verbose "Testing $nshort, $flags" 1
50 # For the header files, the default is to precompile.
51 set dg-do-what-default precompile
52 dg-test -keep-output "[file rootname $test].h" $flags ""
54 # For the rest, the default is to compile to .s.
55 set dg-do-what-default compile
57 if { [ file exists "$bname.h.pch" ] } {
58 # To ensure that the PCH is used, not the original header,
59 # the actual PCH file is renamed to "<foo>.hp.pch".
60 file rename "$bname.h.pch" "$bname.hp.pch"
61 if { [ is_remote host ] } {
62 remote_download host "$bname.hp.pch"
65 dg-test -keep-output $test $flags "-I."
66 file delete "$bname.hp.pch"
67 if { [ file exists "$bname.s" ] } {
68 file rename "$bname.s" "$bname.s-pch"
69 if { [ is_remote host ] } {
70 remote_upload host "[file rootname $test].h" "$bname.hp"
72 file copy "[file rootname $test].h" "$bname.hp"
74 dg-test -keep-output $test $flags "-I."
75 remote_file host delete "$bname.hp"
76 set tmp [ diff "$bname.s" "$bname.s-pch" ]
78 untested "$nshort $flags assembly comparison"
79 } elseif { $tmp == 1 } {
80 pass "$nshort $flags assembly comparison"
82 fail "$nshort $flags assembly comparison"
84 file delete "$bname.s"
85 file delete "$bname.s-pch"
87 untested "$nshort $flags assembly comparison"
92 untested "$nshort $flags assembly comparison"
97 set dg-do-what-default "$old_dg_do_what_default"