Add addr2line, objcopy and strip tests for compressed debug sections.
[deliverable/binutils-gdb.git] / gas / testsuite / lib / gas-defs.exp
index 1e02847b0faf264c1c85a203db26d420bc573337..cfdecc41072ea1985ace901978ca86af993a02ee 100644 (file)
@@ -1,5 +1,5 @@
 # Copyright (C) 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-# 2004, 2005, 2007, 2009  Free Software Foundation, Inc.
+# 2004, 2005, 2007, 2008, 2009  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
@@ -116,6 +116,24 @@ proc gas_run { prog as_opts redir } {
     return [list $comp_output ""]
 }
 
+proc gas_run_stdin { prog as_opts redir } {
+    global AS
+    global ASFLAGS
+    global comp_output
+    global srcdir
+    global subdir
+    global host_triplet
+
+    set status [gas_host_run "$AS $ASFLAGS $as_opts < $srcdir/$subdir/$prog" "$redir"]
+    set comp_output [lindex $status 1]
+    if { [lindex $status 0] != 0 && [regexp "2>.*" $redir] } then {
+       append comp_output "child process exited abnormally"
+    }
+    set comp_output [prune_warnings $comp_output]
+    verbose "output was $comp_output"
+    return [list $comp_output ""]
+}
+
 proc all_ones { args } {
     foreach x $args { if [expr $x!=1] { return 0 } }
     return 1
@@ -222,14 +240,14 @@ proc gas_test_error { file as_opts testname } {
     global comp_output
 
     gas_run $file $as_opts ">/dev/null"
-    if ![string match "" $comp_output] then {
-       send_log "$comp_output\n"
-       verbose "$comp_output" 3
-    }
-    if [string match "" $comp_output] then {
-       fail "$testname"
-    } else {
+    send_log "$comp_output\n"
+    verbose "$comp_output" 3
+    if { ![string match "" $comp_output]
+        && ![string match "*Assertion failure*" $comp_output]
+        && ![string match "*Internal error*" $comp_output] } then {
        pass "$testname"
+    } else {
+       fail "$testname"
     }
 }
 
@@ -271,6 +289,7 @@ proc is_elf_format {} {
         && ![istarget hppa*64*-*-hpux*] \
         && ![istarget *-*-linux*] \
         && ![istarget frv-*-uclinux*] \
+        && ![istarget sh*-*-uclinux*] \
         && ![istarget *-*-irix5*] \
         && ![istarget *-*-irix6*] \
         && ![istarget *-*-netbsd*] \
@@ -310,6 +329,18 @@ proc is_elf_format {} {
     return 1
 }
 
+# True if the object format is known to be PE COFF.
+#
+proc is_pecoff_format {} {
+    if { ![istarget *-*-mingw*] \
+        && ![istarget *-*-cygwin*] \
+        && ![istarget *-*-pe*] } {
+       return 0
+    }
+
+    return 1
+}
+
 # run_dump_tests TESTCASES EXTRA_OPTIONS
 # Wrapper for run_dump_test, which is suitable for invoking as
 #   run_dump_tests [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
@@ -371,6 +402,7 @@ proc run_dump_tests { testcases {extra_options {}} } {
 #   as: FLAGS
 #      When assembling FILE.s, pass FLAGS to the assembler.
 #
+#   addr2line: FLAGS
 #   nm: FLAGS
 #   objcopy: FLAGS
 #   objdump: FLAGS
@@ -379,7 +411,7 @@ proc run_dump_tests { testcases {extra_options {}} } {
 #      FLAGS, in addition to the .o file name.  Note that they are run
 #      with LC_ALL=C in the environment to give consistent sorting
 #      of symbols.  If no FLAGS are needed then use:
-#        PROG: [nm objcopy objdump readelf]
+#        PROG: [nm objcopy objdump readelf addr2line]
 #       instead.
 #
 #   source: SOURCE
@@ -437,6 +469,7 @@ proc run_dump_test { name {extra_options {}} } {
     global subdir srcdir
     global OBJDUMP NM AS OBJCOPY READELF
     global OBJDUMPFLAGS NMFLAGS ASFLAGS OBJCOPYFLAGS READELFFLAGS
+    global ADDR2LINE ADDR2LINEFLAGS
     global host_triplet
     global env
 
@@ -452,6 +485,7 @@ proc run_dump_test { name {extra_options {}} } {
        unresolved $subdir/$name
        return
     }
+    set opts(addr2line) {}
     set opts(as) {}
     set opts(objdump) {}
     set opts(nm) {}
@@ -530,6 +564,7 @@ proc run_dump_test { name {extra_options {}} } {
     if { $opts(error) == "" && $opts(error-output) == "" } {
        if {$opts(PROG) != ""} {
            switch -- $opts(PROG) {
+               addr2line { set program addr2line }
                objdump { set program objdump }
                nm      { set program nm }
                objcopy { set program objcopy }
@@ -541,7 +576,7 @@ proc run_dump_test { name {extra_options {}} } {
            }
        } else {
            # Guess which program to run, by seeing which option was specified.
-           foreach p {objdump objcopy nm readelf} {
+           foreach p {objdump objcopy nm readelf addr2line} {
                if {$opts($p) != ""} {
                    if {$program != ""} {
                        perror "ambiguous dump program in $file.d"
@@ -759,7 +794,7 @@ proc slurp_options { file } {
     set nws {[^        ]*}
     # whitespace is ignored anywhere except within the options list;
     # option names are alphabetic plus dash
-    set pat "^#${ws}(\[a-zA-Z-\]*)$ws:${ws}(.*)$ws\$"
+    set pat "^#${ws}(\[a-zA-Z0-9-\]*)$ws:${ws}(.*)$ws\$"
     while { [gets $f line] != -1 } {
        set line [string trim $line]
        # Whitespace here is space-tab.
@@ -978,3 +1013,22 @@ proc run_list_test { name {opts {}} {testname {}} } {
     }
     pass $testname
 }
+
+# run_list_test_stdin NAME (optional): OPTS TESTNAME
+#
+# Similar to run_list_test, but use stdin as input.
+
+proc run_list_test_stdin { name {opts {}} {testname {}} } {
+    global srcdir subdir
+    if { [string length $testname] == 0 } then {
+       set testname "[file tail $subdir] $name"
+    }
+    set file $srcdir/$subdir/$name
+    gas_run_stdin ${name}.s $opts ">&dump.out"
+    if { [regexp_diff "dump.out" "${file}.l"] } then {
+       fail $testname
+       verbose "output is [file_contents "dump.out"]" 2
+       return
+    }
+    pass $testname
+}
This page took 0.041371 seconds and 4 git commands to generate.