* elf32-spu.c (build_stub): Fix malloc under-allocation.
[binutils.git] / binutils / testsuite / binutils-all / windres / windres.exp
blob2ef73ffeba9ca01260f73e0e26ddf3e7c8a011a2
1 # Copyright 2001, 2003, 2004, 2006, 2007, 2009 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 3 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-dejagnu@prep.ai.mit.edu
20 # Written by DJ Delorie <dj@redhat.com>
22 if {![istarget "i*86-*-*"] && ![istarget "x86_64-*-mingw*"] } {
23 return
26 if {![info exists WINDRES]} then {
27 return
30 if {[which $WINDRES] == 0} then {
31 return
34 set wr "$WINDRES --include-dir $srcdir/$subdir"
36 if [file exists "$srcdir/../../winsup/w32api/include"] {
37 set wr "$wr --include-dir $srcdir/../../winsup/w32api/include"
38 } else {
39 send_log "\nWarning: Assuming windres can find the win32 headers\n\n"
42 set res_list [lsort [glob -nocomplain $srcdir/$subdir/*.rc]]
44 proc oneline { file } {
45 while { 1 } {
46 if { [gets $file line] == -1 } {
47 return ""
49 if [regexp "^ \[0-9a-z\]\[0-9a-z\]* " $line] {
50 return $line
55 foreach res $res_list {
56 set sroot [file rootname $res]
57 set broot [file tail $sroot]
58 set done 0
59 set cpp_opts ""
61 set rc [open $res]
62 while { [gets $rc line] != -1 } {
63 if ![regexp "^(//|/\*|#)" $line] {
64 break
66 if [regexp "\[xp\]fail *(\[^ \]*)" $line junk sys] {
67 setup_xfail $sys
68 continue
70 if [regexp "cpparg *(\[^ \]*)" $line junk cppopt] {
71 set cpp_opts "--preprocessor-arg \"$cppopt\""
72 continue
76 verbose "$wr -J rc -O res $res tmpdir/$broot.res" 1
77 catch "exec $wr $cpp_opts -J rc -O res $res tmpdir/$broot.res" err
79 if ![string match "" $err] then {
80 send_log "$err\n"
81 verbose "$err" 1
82 if [string match "*windows.h: No such file*" $err] then {
83 unsupported "windres/$broot (parse)"
84 } else {
85 fail "windres/$broot (parse)"
87 continue
89 pass "windres/$broot (parse)"
91 set rc [open $res]
92 while { [gets $rc line] != -1 } {
93 if ![regexp "^(//|/\*|#)" $line] {
94 break
96 if [regexp "parse-only" $line] {
97 file delete "tmpdir/$broot.res"
98 set done 1
99 break
101 if [regexp "\[xc\]fail *(\[^ \]*)" $line junk sys] {
102 setup_xfail $sys
103 continue
106 if { $done != 0 } {
107 continue
110 verbose "$OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" 1
111 catch "exec $OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" err
113 if ![string match "" $err] then {
114 send_log "$err\n"
115 verbose "$err" 1
116 fail "windres/$broot (compare)"
117 continue
120 set pat [open "$sroot.rsd"]
121 set out [open "tmpdir/$broot.dump"]
122 set patline "foo"
124 while { ![string match $patline ""] } {
125 set patline [oneline $pat]
126 set outline [oneline $out]
128 if ![string match $patline $outline] {
129 send_log "< $patline\n"
130 send_log "> $outline\n"
131 fail "windres/$broot (compare)"
132 set done 1
133 break
136 if { $done == 0 } {
137 pass "windres/$broot (compare)"
138 file delete "tmpdir/$broot.res"
139 file delete "tmpdir/$broot.dump"