Hardcode host-specific name for LTO plugin
[platform/upstream/binutils.git] / binutils / testsuite / binutils-all / windres / windres.exp
1 # Copyright (C) 2001-2014 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*"] && ![istarget "x86_64-*-cygwin"] } {
23     verbose "Not a Cygwin/Mingw target" 1
24     return
25 }
26
27 if {![info exists WINDRES]} then {
28     verbose "WINDRES not defined" 1
29     return
30 }
31
32 if {[which $WINDRES] == 0} then {
33     verbose "$WINDRES not found" 1
34     return
35 }
36
37 set wr "$WINDRES --include-dir $srcdir/$subdir"
38
39 if [file exists "$srcdir/../../winsup/w32api/include"] {
40     set wr "$wr --include-dir $srcdir/../../winsup/w32api/include"
41 } else {
42     return
43     send_log "\nWarning: Assuming windres can find the win32 headers\n\n"
44 }
45
46 set res_list [lsort [glob -nocomplain $srcdir/$subdir/*.rc]]
47
48 proc oneline { file } {
49     while { 1 } {
50         if { [gets $file line] == -1 } {
51             return ""
52         }
53         if [regexp "^ \[0-9a-z\]\[0-9a-z\]* " $line] {
54             return $line
55         }
56     }
57 }
58
59 foreach res $res_list {
60     set sroot [file rootname $res]
61     set broot [file tail $sroot]
62     set done 0
63     set cpp_opts ""
64
65     set rc [open $res]
66     while { [gets $rc line] != -1 } {
67         if ![regexp "^(//|/\*|#)" $line] {
68             break
69         }
70         if [regexp "\[xp\]fail *(\[^ \]*)" $line junk sys] {
71             setup_xfail $sys
72             continue
73         }
74         if [regexp "cpparg *(\[^ \]*)" $line junk cppopt] {
75             set cpp_opts "--preprocessor-arg \"$cppopt\""
76             continue
77         }
78     }
79
80     verbose "$wr -J rc -O res $res tmpdir/$broot.res" 1
81     catch "exec $wr $cpp_opts -J rc -O res $res tmpdir/$broot.res" err
82
83     if ![string match "" $err] then {
84         send_log "$err\n"
85         verbose "$err" 1
86         if [string match "*windows.h: No such file*" $err] then {
87             unsupported "windres/$broot (parse)"
88         } else {
89             fail "windres/$broot (parse)"
90         }
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
114     verbose "$OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" 1
115     catch "exec $OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" err
116
117     if ![string match "" $err] then {
118         send_log "$err\n"
119         verbose "$err" 1
120         fail "windres/$broot (compare)"
121         continue
122     }
123
124     set pat [open "$sroot.rsd"]
125     set out [open "tmpdir/$broot.dump"]
126     set patline "foo"
127
128     while { ![string match $patline ""] } {
129         set patline [oneline $pat]
130         set outline [oneline $out]
131
132         if ![string match $patline $outline] {
133             send_log "< $patline\n"
134             send_log "> $outline\n"
135             fail "windres/$broot (compare)"
136             set done 1
137             break
138         }
139     }
140     if { $done == 0 } {
141         pass "windres/$broot (compare)"
142         file delete "tmpdir/$broot.res"
143         file delete "tmpdir/$broot.dump"
144     }
145 }
146
147 # Test objdump -p
148
149 if {[which $OBJDUMP] == 0} then {
150     unsupported "objdump -p"
151     return
152 }
153
154 verbose    "$wr $cpp_opts -J rc $srcdir/$subdir/version.rc tmpdir/version.o" 1
155 catch "exec $wr $cpp_opts -J rc $srcdir/$subdir/version.rc tmpdir/version.o" err
156
157 if ![string match "" $err] then {
158     send_log "$err\n"
159     verbose "$err" 1
160     if [string match "*windows.h: No such file*" $err] then {
161         unsupported "objdump -p (no header files found)"
162     } else {
163         fail "objdump -p (build)"
164     }
165     continue
166 }
167
168 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -p tmpdir/version.o"]
169
170 # FIXME: We should extend this regexp to check for more information.
171 set want ".*The .rsrc Resource Directory section.*Type Table:.*Entry: ID:.*Name Table:.*Entry: ID:.*Language Table:.*Entry: ID:.*"
172
173 if ![regexp $want $got] then {
174     fail "objdump -p"
175 } else {
176     pass "objdump -p"
177 }
178
179 # file delete "tmpdir/version.o"