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