Commit | Line | Data |
---|---|---|
85eb5110 | 1 | # Copyright 2001, 2003 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 | |
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. | |
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 | |
15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
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 | ||
22 | if {![istarget "i*86-*-*"]} { | |
23 | return | |
24 | } | |
25 | ||
25268c03 L |
26 | if {![istarget "i*86-*-*pe*"] \ |
27 | && ![istarget "i*86-*-cygwin*"] \ | |
28 | && ![istarget "i*86-*-mingw32*"] } { | |
29 | set target_xfail "yes" | |
30 | } else { | |
31 | set target_xfail "no" | |
32 | } | |
33 | ||
64e08727 DD |
34 | if {![info exists WINDRES]} then { |
35 | return | |
36 | } | |
37 | ||
38 | if {[which $WINDRES] == 0} then { | |
39 | return | |
40 | } | |
41 | ||
42 | set wr "$WINDRES --include-dir $srcdir/$subdir" | |
43 | ||
44 | if [file exists "$srcdir/../../winsup/w32api/include"] { | |
45 | set wr "$wr --include-dir $srcdir/../../winsup/w32api/include" | |
25268c03 | 46 | set target_xfail "no" |
64e08727 DD |
47 | } else { |
48 | send_log "\nWarning: Assuming windres can find the win32 headers\n\n" | |
49 | } | |
50 | ||
51 | set res_list [lsort [glob -nocomplain $srcdir/$subdir/*.rc]] | |
52 | ||
53 | proc oneline { file } { | |
54 | while { 1 } { | |
55 | if { [gets $file line] == -1 } { | |
56 | return "" | |
57 | } | |
58 | if [regexp "^ \[0-9a-z\]\[0-9a-z\]* " $line] { | |
59 | return $line | |
60 | } | |
61 | } | |
62 | } | |
63 | ||
64 | foreach res $res_list { | |
65 | set sroot [file rootname $res] | |
66 | set broot [file tail $sroot] | |
67 | set done 0 | |
68 | ||
69 | set rc [open $res] | |
70 | while { [gets $rc line] != -1 } { | |
71 | if ![regexp "^(//|/\*|#)" $line] { | |
72 | break | |
73 | } | |
74 | if [regexp "\[xp\]fail *(\[^ \]*)" $line junk sys] { | |
75 | setup_xfail $sys | |
76 | continue; | |
77 | } | |
78 | } | |
79 | ||
25268c03 L |
80 | if { "$broot" != "bmpalign" && "$target_xfail" == "yes" } { |
81 | setup_xfail *-* | |
82 | } | |
83 | ||
85eb5110 NC |
84 | verbose "$wr -J rc -O res $res tmpdir/$broot.res" 1 |
85 | catch "exec $wr -J rc -O res $res tmpdir/$broot.res" err | |
64e08727 DD |
86 | |
87 | if ![string match "" $err] then { | |
88 | send_log "$err\n" | |
89 | verbose "$err" 1 | |
90 | fail "windres/$broot (parse)" | |
91 | continue; | |
92 | } | |
93 | pass "windres/$broot (parse)" | |
94 | ||
95 | set rc [open $res] | |
96 | while { [gets $rc line] != -1 } { | |
97 | if ![regexp "^(//|/\*|#)" $line] { | |
98 | break | |
99 | } | |
100 | if [regexp "parse-only" $line] { | |
101 | file delete "tmpdir/$broot.res" | |
102 | set done 1 | |
103 | break; | |
104 | } | |
105 | if [regexp "\[xc\]fail *(\[^ \]*)" $line junk sys] { | |
106 | setup_xfail $sys | |
107 | continue; | |
108 | } | |
109 | } | |
110 | if { $done != 0 } { | |
111 | continue; | |
112 | } | |
113 | ||
8bd8d215 | 114 | if { "$broot" != "bmpalign" && "$target_xfail" == "yes" } { |
25268c03 L |
115 | setup_xfail *-* |
116 | } | |
117 | ||
64e08727 DD |
118 | verbose "$OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" 1 |
119 | catch "exec $OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" err | |
120 | ||
121 | if ![string match "" $err] then { | |
122 | send_log "$err\n" | |
123 | verbose "$err" 1 | |
124 | fail "windres/$broot (compare)" | |
125 | continue; | |
126 | } | |
127 | ||
128 | set pat [open "$sroot.rsd"] | |
129 | set out [open "tmpdir/$broot.dump"] | |
130 | set patline "foo" | |
131 | ||
132 | while { ![string match $patline ""] } { | |
133 | set patline [oneline $pat] | |
134 | set outline [oneline $out] | |
135 | ||
136 | if ![string match $patline $outline] { | |
137 | send_log "< $patline\n"; | |
138 | send_log "> $outline\n"; | |
139 | fail "windres/$broot (compare)"; | |
140 | set done 1 | |
141 | break; | |
142 | } | |
143 | } | |
144 | if { $done == 0 } { | |
145 | pass "windres/$broot (compare)" | |
146 | file delete "tmpdir/$broot.res" | |
147 | file delete "tmpdir/$broot.dump" | |
148 | } | |
149 | } |