Commit | Line | Data |
---|---|---|
32866df7 | 1 | # Copyright 2001, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. |
64e08727 DD |
2 | |
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 | |
32866df7 | 5 | # the Free Software Foundation; either version 3 of the License, or |
64e08727 DD |
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. | |
12 | # | |
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 | |
b43b5d5f | 15 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
64e08727 DD |
16 | |
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-dejagnu@prep.ai.mit.edu | |
19 | ||
20 | # Written by DJ Delorie <dj@redhat.com> | |
21 | ||
42037fe5 | 22 | if {![istarget "i*86-*-*"] && ![istarget "x86_64-*-mingw*"] } { |
64e08727 DD |
23 | return |
24 | } | |
25 | ||
25268c03 L |
26 | if {![istarget "i*86-*-*pe*"] \ |
27 | && ![istarget "i*86-*-cygwin*"] \ | |
99ad8390 | 28 | && ![istarget "i*86-*-mingw32*"] \ |
42037fe5 | 29 | && ![istarget "x86_64-*-mingw*"] } { |
25268c03 L |
30 | set target_xfail "yes" |
31 | } else { | |
32 | set target_xfail "no" | |
33 | } | |
34 | ||
64e08727 DD |
35 | if {![info exists WINDRES]} then { |
36 | return | |
37 | } | |
38 | ||
39 | if {[which $WINDRES] == 0} then { | |
40 | return | |
41 | } | |
42 | ||
43 | set wr "$WINDRES --include-dir $srcdir/$subdir" | |
44 | ||
45 | if [file exists "$srcdir/../../winsup/w32api/include"] { | |
46 | set wr "$wr --include-dir $srcdir/../../winsup/w32api/include" | |
25268c03 | 47 | set target_xfail "no" |
64e08727 DD |
48 | } else { |
49 | send_log "\nWarning: Assuming windres can find the win32 headers\n\n" | |
50 | } | |
51 | ||
52 | set res_list [lsort [glob -nocomplain $srcdir/$subdir/*.rc]] | |
53 | ||
54 | proc oneline { file } { | |
55 | while { 1 } { | |
56 | if { [gets $file line] == -1 } { | |
57 | return "" | |
58 | } | |
59 | if [regexp "^ \[0-9a-z\]\[0-9a-z\]* " $line] { | |
60 | return $line | |
61 | } | |
62 | } | |
63 | } | |
64 | ||
65 | foreach res $res_list { | |
66 | set sroot [file rootname $res] | |
67 | set broot [file tail $sroot] | |
68 | set done 0 | |
69 | ||
70 | set rc [open $res] | |
71 | while { [gets $rc line] != -1 } { | |
72 | if ![regexp "^(//|/\*|#)" $line] { | |
73 | break | |
74 | } | |
75 | if [regexp "\[xp\]fail *(\[^ \]*)" $line junk sys] { | |
76 | setup_xfail $sys | |
8d263650 | 77 | continue |
64e08727 DD |
78 | } |
79 | } | |
80 | ||
25268c03 L |
81 | if { "$broot" != "bmpalign" && "$target_xfail" == "yes" } { |
82 | setup_xfail *-* | |
83 | } | |
84 | ||
85eb5110 NC |
85 | verbose "$wr -J rc -O res $res tmpdir/$broot.res" 1 |
86 | catch "exec $wr -J rc -O res $res tmpdir/$broot.res" err | |
64e08727 DD |
87 | |
88 | if ![string match "" $err] then { | |
89 | send_log "$err\n" | |
90 | verbose "$err" 1 | |
1e1c6a43 AM |
91 | if [string match "*windows.h: No such file*" $err] then { |
92 | unsupported "windres/$broot (parse)" | |
93 | } else { | |
94 | fail "windres/$broot (parse)" | |
95 | } | |
8d263650 | 96 | continue |
64e08727 DD |
97 | } |
98 | pass "windres/$broot (parse)" | |
99 | ||
100 | set rc [open $res] | |
101 | while { [gets $rc line] != -1 } { | |
102 | if ![regexp "^(//|/\*|#)" $line] { | |
103 | break | |
104 | } | |
105 | if [regexp "parse-only" $line] { | |
106 | file delete "tmpdir/$broot.res" | |
107 | set done 1 | |
8d263650 | 108 | break |
64e08727 DD |
109 | } |
110 | if [regexp "\[xc\]fail *(\[^ \]*)" $line junk sys] { | |
111 | setup_xfail $sys | |
8d263650 | 112 | continue |
64e08727 DD |
113 | } |
114 | } | |
115 | if { $done != 0 } { | |
8d263650 | 116 | continue |
64e08727 DD |
117 | } |
118 | ||
8bd8d215 | 119 | if { "$broot" != "bmpalign" && "$target_xfail" == "yes" } { |
25268c03 L |
120 | setup_xfail *-* |
121 | } | |
122 | ||
64e08727 DD |
123 | verbose "$OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" 1 |
124 | catch "exec $OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" err | |
125 | ||
126 | if ![string match "" $err] then { | |
127 | send_log "$err\n" | |
128 | verbose "$err" 1 | |
129 | fail "windres/$broot (compare)" | |
8d263650 | 130 | continue |
64e08727 DD |
131 | } |
132 | ||
133 | set pat [open "$sroot.rsd"] | |
134 | set out [open "tmpdir/$broot.dump"] | |
135 | set patline "foo" | |
136 | ||
137 | while { ![string match $patline ""] } { | |
138 | set patline [oneline $pat] | |
139 | set outline [oneline $out] | |
140 | ||
141 | if ![string match $patline $outline] { | |
8d263650 BE |
142 | send_log "< $patline\n" |
143 | send_log "> $outline\n" | |
144 | fail "windres/$broot (compare)" | |
64e08727 | 145 | set done 1 |
8d263650 | 146 | break |
64e08727 DD |
147 | } |
148 | } | |
149 | if { $done == 0 } { | |
150 | pass "windres/$broot (compare)" | |
151 | file delete "tmpdir/$broot.res" | |
152 | file delete "tmpdir/$broot.dump" | |
153 | } | |
154 | } |