This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

patch, gas run_dump_test error feature


This patch merges the "error" feature from ld's run_dump_test to gas.

>From the dump file error-002.d,

#error: bad opcode or operands

Causing dejagnu to look for "bad opcode or operands" in the gas
output.   Passing the test when it does.

Ok to commit?
Tom

--
Tom Rix
GCC Engineer
trix@redhat.com


2002-05-24  Tom Rix  <trix@redhat.com>

	* lib/gas-defs.exp (run_dump_test): Add error option.
	* gas/d10v/d10v.exp: Add error tests.
	* gas/d10v/error-001.d - error-002.d : New tests.

diff -rupN -x *.rej -x *~ src-old/gas/testsuite/gas/d10v/d10v.exp src/gas/testsuite/gas/d10v/d10v.exp
--- src-old/gas/testsuite/gas/d10v/d10v.exp	Fri May 24 12:21:53 2002
+++ src/gas/testsuite/gas/d10v/d10v.exp	Fri May 24 12:27:13 2002
@@ -58,4 +58,6 @@ if {[istarget d10v-*-*]} {
     run_list_test "address-040" ""
     run_list_test "address-041" ""
     run_dump_test "instruction_packing"
+    run_dump_test "error-001"
+    run_dump_test "error-002"
 }
diff -rupN -x *.rej -x *~ src-old/gas/testsuite/gas/d10v/error-001.d src/gas/testsuite/gas/d10v/error-001.d
--- src-old/gas/testsuite/gas/d10v/error-001.d	Wed Dec 31 18:00:00 1969
+++ src/gas/testsuite/gas/d10v/error-001.d	Fri May 24 12:37:50 2002
@@ -0,0 +1,12 @@
+#objdump: -D
+#source: error-001.s
+
+# Test expect's dump_run_test baseline
+
+.*: +file format elf32-d10v
+
+Disassembly of section .text:
+
+00000000 <foo>:
+   0:	20 01 5e 00 	mv	r0, r1	||	nop	
+Disassembly of section .data:
diff -rupN -x *.rej -x *~ src-old/gas/testsuite/gas/d10v/error-001.s src/gas/testsuite/gas/d10v/error-001.s
--- src-old/gas/testsuite/gas/d10v/error-001.s	Wed Dec 31 18:00:00 1969
+++ src/gas/testsuite/gas/d10v/error-001.s	Fri May 24 12:37:50 2002
@@ -0,0 +1,9 @@
+	;;
+	;; error-001.s
+	;; Not really an error but a baseline for the expect function
+	;; run_dump_test
+
+	.text
+	.global foo
+foo:	
+	mv	r0,r1
diff -rupN -x *.rej -x *~ src-old/gas/testsuite/gas/d10v/error-002.d src/gas/testsuite/gas/d10v/error-002.d
--- src-old/gas/testsuite/gas/d10v/error-002.d	Wed Dec 31 18:00:00 1969
+++ src/gas/testsuite/gas/d10v/error-002.d	Fri May 24 12:54:32 2002
@@ -0,0 +1,4 @@
+#source: error-002.s
+#error: bad opcode or operands
+
+# Test expect's dump_run_test error option
diff -rupN -x *.rej -x *~ src-old/gas/testsuite/gas/d10v/error-002.s src/gas/testsuite/gas/d10v/error-002.s
--- src-old/gas/testsuite/gas/d10v/error-002.s	Wed Dec 31 18:00:00 1969
+++ src/gas/testsuite/gas/d10v/error-002.s	Fri May 24 12:37:50 2002
@@ -0,0 +1,9 @@
+	;;
+	;; error-002.s
+	;; Test new error feature of run_dump_test
+	;; run_dump_test
+
+	.text
+	.global foo
+foo:	
+	mv	r0,0
diff -rupN -x *.rej -x *~ src-old/gas/testsuite/lib/gas-defs.exp src/gas/testsuite/lib/gas-defs.exp
--- src-old/gas/testsuite/lib/gas-defs.exp	Fri May 24 12:22:10 2002
+++ src/gas/testsuite/lib/gas-defs.exp	Fri May 24 12:35:48 2002
@@ -233,6 +233,11 @@ proc gas_init { args } {
 #	Assemble the file SOURCE.s.  If omitted, this defaults to FILE.s.
 #       This is useful if several .d files want to share a .s file.
 #
+#   error: REGEX
+#	An error with message matching REGEX must be emitted for the test
+#	to pass.  The PROG, objdump, nm and objcopy options have no
+#	meaning and need not supplied if this is present.
+#
 # Each option may occur at most once.
 #
 # After the option lines come regexp lines.  `run_dump_test' calls
@@ -267,6 +272,7 @@ proc run_dump_test { name } {
     set opts(PROG) {}
     set opts(source) {}
     set opts(stderr) {}
+    set opts(error) {}
 
     foreach i $opt_array {
 	set opt_name [lindex $i 0]
@@ -299,6 +305,10 @@ proc run_dump_test { name } {
 		  unresolved $subdir/$name
 		  return }
 	}
+    } elseif { $opts(error) != "" } {
+	# It's meaningless to require an output-testing method when we
+	# expect an error.  For simplicity, we fake an arbitrary method.
+	set program "nm"
     } else {
 	# Guess which program to run, by seeing which option was specified.
 	set program ""
@@ -343,6 +353,14 @@ proc run_dump_test { name } {
 	if { $opts(stderr) == "" }  then {
 	    send_log "$comp_output\n"
 	    verbose "$comp_output" 3
+
+	    if { $opts(error) != "" } {
+		verbose -log "failed with: <$comp_output>, expected: <$opts(error)>"
+		if [regexp $opts(error) $comp_output] {
+		    pass $testname
+		    return
+		}
+	    }
 	    fail $testname
 	    return
 	} else {
@@ -359,6 +377,13 @@ proc run_dump_test { name } {
 	    send_log "wrote pruned stderr to dump.stderr\n"
 	    verbose "wrote pruned stderr to dump.stderr" 3
 	    if { [regexp_diff "dump.stderr" "$stderrfile"] } then {
+		if { $opts(error) != "" } {
+		    verbose -log "failed with: <$comp_output>, expected: <$opts(error)>"
+		    if [regexp $opts(error) $comp_output] {
+			pass $testname
+			return
+		    }
+		}
 		fail $testname
 		verbose "pruned stderr is [file_contents "dump.stderr"]" 2
 		return

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]