2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / lib / dg-pch.exp
blob5ab34ec7bef7c9a788f53c4e629053be58ead63d
1 # Copyright (C) 2003 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.
7 #
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 load_lib copy-file.exp
19 proc dg-pch { subdir test options suffix } {
20 global runtests dg-do-what-default
22 # If we're only testing specific files and this isn't one of them, skip it.
23 if ![runtest_file_p $runtests $test] {
24 return
26 set nshort "$subdir/[file tail $test]"
27 set bname "[file rootname [file tail $nshort]]"
29 catch { file delete "$bname$suffix.gch" }
30 catch { file delete "$bname.s" }
31 catch { file delete "$bname.s-gch" }
33 # We don't try to use the loop-optimizing options, since they are highly
34 # unlikely to make any difference to PCH.
35 foreach flags $options {
36 verbose "Testing $nshort, $flags" 1
38 # For the header files, the default is to precompile.
39 set dg-do-what-default precompile
40 catch { file delete "$bname$suffix" }
41 gcc_copy_files "[file rootname $test]${suffix}s" "$bname$suffix"
42 dg-test -keep-output "./$bname$suffix" $flags ""
44 # For the rest, the default is to compile to .s.
45 set dg-do-what-default compile
47 if { [ file exists "$bname$suffix.gch" ] } {
48 # Ensure that the PCH file is used, not the original header.
49 file delete "$bname$suffix"
51 dg-test -keep-output $test $flags "-I."
52 file delete "$bname$suffix.gch"
53 if { [ file exists "$bname.s" ] } {
54 file rename "$bname.s" "$bname.s-gch"
55 gcc_copy_files "[file rootname $test]${suffix}s" "$bname$suffix"
56 dg-test -keep-output $test $flags "-I."
57 set tmp [ diff "$bname.s" "$bname.s-gch" ]
58 if { $tmp == 0 } {
59 untested "$nshort $flags assembly comparison"
60 } elseif { $tmp == 1 } {
61 pass "$nshort $flags assembly comparison"
62 } else {
63 fail "$nshort $flags assembly comparison"
65 file delete "$bname$suffix"
66 file delete "$bname.s"
67 file delete "$bname.s-gch"
68 } else {
69 untested "$nshort $flags assembly comparison"
72 } else {
73 untested "$nshort $flags"
74 untested "$nshort $flags assembly comparison"