testsuite
[platform/upstream/binutils.git] / binutils / testsuite / binutils-all / windres / windres.exp
index 3578835..6b284d1 100644 (file)
@@ -1,8 +1,8 @@
-# Copyright 2001 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 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
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 # 
 # This program is distributed in the hope that it will be useful,
 # 
 # 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.
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, 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-*-*"]} {
+if {![istarget "i*86-*-*"] && ![istarget "x86_64-*-mingw*"] && ![istarget "x86_64-*-cygwin"] } {
+    verbose "Not a Cygwin/Mingw target" 1
     return
 }
 
 if {![info exists WINDRES]} then {
+    verbose "WINDRES not defined" 1
     return
 }
 
 if {[which $WINDRES] == 0} then {
+    verbose "$WINDRES not found" 1
     return
 }
 
@@ -36,6 +39,7 @@ set wr "$WINDRES --include-dir $srcdir/$subdir"
 if [file exists "$srcdir/../../winsup/w32api/include"] {
     set wr "$wr --include-dir $srcdir/../../winsup/w32api/include"
 } else {
+    return
     send_log "\nWarning: Assuming windres can find the win32 headers\n\n"
 }
 
@@ -56,6 +60,7 @@ foreach res $res_list {
     set sroot [file rootname $res]
     set broot [file tail $sroot]
     set done 0
+    set cpp_opts ""
 
     set rc [open $res]
     while { [gets $rc line] != -1 } {
@@ -64,18 +69,26 @@ foreach res $res_list {
        }
        if [regexp "\[xp\]fail *(\[^ \]*)" $line junk sys] {
            setup_xfail $sys
-           continue;
+           continue
+       }
+       if [regexp "cpparg *(\[^ \]*)" $line junk cppopt] {
+           set cpp_opts "--preprocessor-arg \"$cppopt\""
+           continue
        }
     }
 
-    verbose "$wr -I rc -O res $res tmpdir/$broot.res" 1
-    catch "exec $wr -I rc -O res $res tmpdir/$broot.res" err
+    verbose "$wr -J rc -O res $res tmpdir/$broot.res" 1
+    catch "exec $wr $cpp_opts -J 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;
+       if [string match "*windows.h: No such file*" $err] then {
+           unsupported "windres/$broot (parse)"
+       } else {
+           fail "windres/$broot (parse)"
+       }
+       continue
     }
     pass "windres/$broot (parse)"
 
@@ -87,15 +100,15 @@ foreach res $res_list {
        if [regexp "parse-only" $line] {
            file delete "tmpdir/$broot.res"
            set done 1
-           break;
+           break
        }
        if [regexp "\[xc\]fail *(\[^ \]*)" $line junk sys] {
            setup_xfail $sys
-           continue;
+           continue
        }
     }
     if { $done != 0 } {
-       continue;
+       continue
     }
 
     verbose "$OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" 1
@@ -105,7 +118,7 @@ foreach res $res_list {
        send_log "$err\n"
        verbose "$err" 1
        fail "windres/$broot (compare)"
-       continue;
+       continue
     }
 
     set pat [open "$sroot.rsd"]
@@ -117,11 +130,11 @@ foreach res $res_list {
        set outline [oneline $out]
 
        if ![string match $patline $outline] {
-           send_log "< $patline\n";
-           send_log "> $outline\n";
-           fail "windres/$broot (compare)";
+           send_log "< $patline\n"
+           send_log "> $outline\n"
+           fail "windres/$broot (compare)"
            set done 1
-           break;
+           break
        }
     }
     if { $done == 0 } {
@@ -130,3 +143,37 @@ foreach res $res_list {
        file delete "tmpdir/$broot.dump"
     }
 }
+
+# Test objdump -p
+
+if {[which $OBJDUMP] == 0} then {
+    unsupported "objdump -p"
+    return
+}
+
+verbose    "$wr $cpp_opts -J rc $srcdir/$subdir/version.rc tmpdir/version.o" 1
+catch "exec $wr $cpp_opts -J rc $srcdir/$subdir/version.rc tmpdir/version.o" err
+
+if ![string match "" $err] then {
+    send_log "$err\n"
+    verbose "$err" 1
+    if [string match "*windows.h: No such file*" $err] then {
+       unsupported "objdump -p (no header files found)"
+    } else {
+       fail "objdump -p (build)"
+    }
+    continue
+}
+
+set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -p tmpdir/version.o"]
+
+# FIXME: We should extend this regexp to check for more information.
+set want ".*The .rsrc Resource Directory section.*Type Table:.*Entry: ID:.*Name Table:.*Entry: ID:.*Language Table:.*Entry: ID:.*"
+
+if ![regexp $want $got] then {
+    fail "objdump -p"
+} else {
+    pass "objdump -p"
+}
+
+# file delete "tmpdir/version.o"