update copyright dates
[platform/upstream/binutils.git] / binutils / testsuite / binutils-all / windres / windres.exp
1 # Copyright 2001, 2003, 2004, 2006, 2007, 2009 Free Software Foundation, Inc.
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 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.
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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, 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-*-*"] && ![istarget "x86_64-*-mingw*"] } {
23     return
24 }
25
26 if {![info exists WINDRES]} then {
27     return
28 }
29
30 if {[which $WINDRES] == 0} then {
31     return
32 }
33
34 set wr "$WINDRES --include-dir $srcdir/$subdir"
35
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"
40 }
41
42 set res_list [lsort [glob -nocomplain $srcdir/$subdir/*.rc]]
43
44 proc oneline { file } {
45     while { 1 } {
46         if { [gets $file line] == -1 } {
47             return ""
48         }
49         if [regexp "^ \[0-9a-z\]\[0-9a-z\]* " $line] {
50             return $line
51         }
52     }
53 }
54
55 foreach res $res_list {
56     set sroot [file rootname $res]
57     set broot [file tail $sroot]
58     set done 0
59
60     set rc [open $res]
61     while { [gets $rc line] != -1 } {
62         if ![regexp "^(//|/\*|#)" $line] {
63             break
64         }
65         if [regexp "\[xp\]fail *(\[^ \]*)" $line junk sys] {
66             setup_xfail $sys
67             continue
68         }
69     }
70
71     verbose "$wr -J rc -O res $res tmpdir/$broot.res" 1
72     catch "exec $wr -J rc -O res $res tmpdir/$broot.res" err
73
74     if ![string match "" $err] then {
75         send_log "$err\n"
76         verbose "$err" 1
77         if [string match "*windows.h: No such file*" $err] then {
78             unsupported "windres/$broot (parse)"
79         } else {
80             fail "windres/$broot (parse)"
81         }
82         continue
83     }
84     pass "windres/$broot (parse)"
85
86     set rc [open $res]
87     while { [gets $rc line] != -1 } {
88         if ![regexp "^(//|/\*|#)" $line] {
89             break
90         }
91         if [regexp "parse-only" $line] {
92             file delete "tmpdir/$broot.res"
93             set done 1
94             break
95         }
96         if [regexp "\[xc\]fail *(\[^ \]*)" $line junk sys] {
97             setup_xfail $sys
98             continue
99         }
100     }
101     if { $done != 0 } {
102         continue
103     }
104
105     verbose "$OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" 1
106     catch "exec $OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" err
107
108     if ![string match "" $err] then {
109         send_log "$err\n"
110         verbose "$err" 1
111         fail "windres/$broot (compare)"
112         continue
113     }
114
115     set pat [open "$sroot.rsd"]
116     set out [open "tmpdir/$broot.dump"]
117     set patline "foo"
118
119     while { ![string match $patline ""] } {
120         set patline [oneline $pat]
121         set outline [oneline $out]
122
123         if ![string match $patline $outline] {
124             send_log "< $patline\n"
125             send_log "> $outline\n"
126             fail "windres/$broot (compare)"
127             set done 1
128             break
129         }
130     }
131     if { $done == 0 } {
132         pass "windres/$broot (compare)"
133         file delete "tmpdir/$broot.res"
134         file delete "tmpdir/$broot.dump"
135     }
136 }