summaryrefslogtreecommitdiff
path: root/binutils/testsuite/binutils-all/windres/windres.exp
blob: 858ce98e6bde8be4469272dbaa9087f53a622f60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Copyright 2001 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

# Please email any bugs, comments, and/or additions to this file to:
# bug-dejagnu@prep.ai.mit.edu

# Written by DJ Delorie <dj@redhat.com>

if {![istarget "i*86-*-*"]} {
    return
}

if {![istarget "i*86-*-*pe*"] \
    && ![istarget "i*86-*-cygwin*"] \
    && ![istarget "i*86-*-mingw32*"] } {
    set target_xfail "yes"
} else {
    set target_xfail "no"
}

if {![info exists WINDRES]} then {
    return
}

if {[which $WINDRES] == 0} then {
    return
}

set wr "$WINDRES --include-dir $srcdir/$subdir"

if [file exists "$srcdir/../../winsup/w32api/include"] {
    set wr "$wr --include-dir $srcdir/../../winsup/w32api/include"
    set target_xfail "no"
} else {
    send_log "\nWarning: Assuming windres can find the win32 headers\n\n"
}

set res_list [lsort [glob -nocomplain $srcdir/$subdir/*.rc]]

proc oneline { file } {
    while { 1 } {
	if { [gets $file line] == -1 } {
	    return ""
	}
	if [regexp "^ \[0-9a-z\]\[0-9a-z\]* " $line] {
	    return $line
	}
    }
}

foreach res $res_list {
    set sroot [file rootname $res]
    set broot [file tail $sroot]
    set done 0

    set rc [open $res]
    while { [gets $rc line] != -1 } {
	if ![regexp "^(//|/\*|#)" $line] {
	    break
	}
	if [regexp "\[xp\]fail *(\[^ \]*)" $line junk sys] {
	    setup_xfail $sys
	    continue;
	}
    }

    if { "$broot" != "bmpalign" && "$target_xfail" == "yes" } {
	setup_xfail *-*
    }

    verbose "$wr -I rc -O res $res tmpdir/$broot.res" 1
    catch "exec $wr -I rc -O res $res tmpdir/$broot.res" err

    if ![string match "" $err] then {
	send_log "$err\n"
	verbose "$err" 1
	fail "windres/$broot (parse)"
	continue;
    }
    pass "windres/$broot (parse)"

    set rc [open $res]
    while { [gets $rc line] != -1 } {
	if ![regexp "^(//|/\*|#)" $line] {
	    break
	}
	if [regexp "parse-only" $line] {
	    file delete "tmpdir/$broot.res"
	    set done 1
	    break;
	}
	if [regexp "\[xc\]fail *(\[^ \]*)" $line junk sys] {
	    setup_xfail $sys
	    continue;
	}
    }
    if { $done != 0 } {
	continue;
    }

    if { "$broot" != "bmpalign" && "$target_xfail" == "yes" } {
	setup_xfail *-*
    }

    verbose "$OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" 1
    catch "exec $OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" err

    if ![string match "" $err] then {
	send_log "$err\n"
	verbose "$err" 1
	fail "windres/$broot (compare)"
	continue;
    }

    set pat [open "$sroot.rsd"]
    set out [open "tmpdir/$broot.dump"]
    set patline "foo"

    while { ![string match $patline ""] } {
	set patline [oneline $pat]
	set outline [oneline $out]

	if ![string match $patline $outline] {
	    send_log "< $patline\n";
	    send_log "> $outline\n";
	    fail "windres/$broot (compare)";
	    set done 1
	    break;
	}
    }
    if { $done == 0 } {
	pass "windres/$broot (compare)"
	file delete "tmpdir/$broot.res"
	file delete "tmpdir/$broot.dump"
    }
}