public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [RFA:] ld/testsuite/ld-lib.exp: support run_dump_test directive "warning".
@ 2005-02-06 14:20 Hans-Peter Nilsson
  2005-02-06 16:52 ` Ian Lance Taylor
  0 siblings, 1 reply; 6+ messages in thread
From: Hans-Peter Nilsson @ 2005-02-06 14:20 UTC (permalink / raw)
  To: binutils

This patch enables support for a new ld run_dump_test directive:
"warning", to match warnings from the linker.  Upcoming tests
use the new machinery.  BTW, the warning supposed is also a
disguised bugfix for whether ld actually exited with an error.
Thanks to this I noticed a bug in the ld-cris/libdso-13.d
test-case (a victim of the Tcl write-to-stderr-causes-exec-error
bogosity now worked around); the supposed error is a warning.
Will take separate action.

Ok to commit?

testsuite:
	* lib/ld-lib.exp: Support new directive "warning".


--- ld-lib.exp~	Mon Nov  8 09:29:45 2004
+++ ld-lib.exp	Fri Feb  4 18:51:49 2005
@@ -587,6 +587,10 @@ proc simple_diff { file_1 file_2 } {
 #	to pass.  The PROG, objdump, nm and objcopy options have no
 #	meaning and need not supplied if this is present.
 #
+#   warning: REGEX
+#	Expect a linker warning matching REGEX.  It is an error to issue
+#	both "error" and "warning".
+#
 # Each option may occur at most once unless otherwise mentioned.
 #
 # After the option lines come regexp lines.  `run_dump_test' calls
@@ -634,6 +638,7 @@ proc run_dump_test { name } {
     set opts(PROG) {}
     set opts(source) {}
     set opts(error) {}
+    set opts(warning) {}
     set opts(objcopy_linked_file) {}
     set asflags(${file}.s) {}
 
@@ -800,6 +805,15 @@ proc run_dump_test { name } {
     # Perhaps link the file(s).
     if { $run_ld } {
 	set objfile "tmpdir/dump"
+	set expmsg $opts(error)
+
+	if { $opts(warning) != "" } {
+	    if { $expmsg != "" } {
+		perror "$testname: mixing error and warning test-directives"
+		return
+	    }
+	    set expmsg $opts(warning)
+	}
 
 	# Add -L$srcdir/$subdir so that the linker command can use
 	# linker scripts in the source directory.
@@ -810,18 +824,36 @@ proc run_dump_test { name } {
 	set cmdret [catch "exec $cmd" comp_output]
 	set comp_output [prune_warnings $comp_output]
 
-	if { $cmdret != 0 || ![string match "" $comp_output] } then {
-	    verbose -log "failed with: <$comp_output>, expected: <$opts(error)>"
+	if { $cmdret != 0 || $comp_output != "" || $expmsg != "" } then {
+	    # If the executed program writes to stderr and stderr is not
+	    # redirected, exec *always* returns failure, regardless of the
+	    # program exit code.  Thankfully, we can retrieve the true
+	    # return status from a special variable.  Redirection would
+	    # cause a tcl-specific message to be appended, and we'd rather
+	    # not deal with that if we can help it.
+	    global errorCode
+	    if { $cmdret != 0 && [lindex $errorCode 0] == "NONE" } {
+		set cmdret 0
+	    }
+
+	    set exitstat "succeeded"
+	    if { $cmdret != 0 } { set exitstat "failed" }
+	    verbose -log "$exitstat with: <$comp_output>, expected: <$expmsg>"
 	    send_log "$comp_output\n"
 	    verbose "$comp_output" 3
-	    if { $opts(error) != "" && $run_objcopy == 0 } {
-		if [regexp $opts(error) $comp_output] {
+	    if { $expmsg != "" && $run_objcopy == 0 \
+		    && [regexp $expmsg $comp_output] \
+		    && (($cmdret == 0) == ($opts(warning) != "")) } {
+		# Only "pass" and return here if we expected (and got)
+		# an error.
+		if { $opts(error) != "" } {
 		    pass $testname
 		    return
 		}
+	    } {
+		fail $testname
+		return
 	    }
-	    fail $testname
-	    return
 	}
 
 	if { $run_objcopy } {

brgds, H-P

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA:] ld/testsuite/ld-lib.exp: support run_dump_test directive "warning".
  2005-02-06 14:20 [RFA:] ld/testsuite/ld-lib.exp: support run_dump_test directive "warning" Hans-Peter Nilsson
@ 2005-02-06 16:52 ` Ian Lance Taylor
  2005-02-07 16:05   ` Hans-Peter Nilsson
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Lance Taylor @ 2005-02-06 16:52 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: binutils

Hans-Peter Nilsson <hans-peter.nilsson@axis.com> writes:

> This patch enables support for a new ld run_dump_test directive:
> "warning", to match warnings from the linker.  Upcoming tests
> use the new machinery.  BTW, the warning supposed is also a
> disguised bugfix for whether ld actually exited with an error.
> Thanks to this I noticed a bug in the ld-cris/libdso-13.d
> test-case (a victim of the Tcl write-to-stderr-causes-exec-error
> bogosity now worked around); the supposed error is a warning.
> Will take separate action.
> 
> Ok to commit?
> 
> testsuite:
> 	* lib/ld-lib.exp: Support new directive "warning".

This is OK if you make the corresponding change to the gas testsuite
as well.  Thanks.

Ian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA:] ld/testsuite/ld-lib.exp: support run_dump_test directive "warning".
  2005-02-06 16:52 ` Ian Lance Taylor
@ 2005-02-07 16:05   ` Hans-Peter Nilsson
  2005-02-21 15:52     ` Alan Modra
  0 siblings, 1 reply; 6+ messages in thread
From: Hans-Peter Nilsson @ 2005-02-07 16:05 UTC (permalink / raw)
  To: ian; +Cc: hans-peter.nilsson, binutils

> From: Ian Lance Taylor <ian@airs.com>
> Date: 06 Feb 2005 09:15:28 -0500

> Hans-Peter Nilsson <hans-peter.nilsson@axis.com> writes:
> > testsuite:
> > 	* lib/ld-lib.exp: Support new directive "warning".
> 
> This is OK if you make the corresponding change to the gas testsuite
> as well.  Thanks.

Ok.  That's mostly for symmetry, as the dg-* support is superior
for testing warnings (but for the record can't be used for ld as
it doesn't in general have the necessary source context where
the linker warning can be marked).

Committed as follows.  I only tested that existing tests still
pass for cris-elf binutils; I haven't tested "warning:" itself.
I see there's a "stderr:" directive that isn't documented nor
synced with the ld run_dump_test.  I ran a regression test for
mips-elf make to sure its usage didn't regress.

For the record, for gas I suggest new tests *not* to use
"stderr:", but instead a separate dg-* test and a run_dump_test
with a "warning: .*".

	* lib/gas-defs.exp: Support new directive "warning".

Index: gas-defs.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/lib/gas-defs.exp,v
retrieving revision 1.18
diff -c -p -r1.18 gas-defs.exp
*** gas-defs.exp	12 May 2004 03:06:10 -0000	1.18
--- gas-defs.exp	7 Feb 2005 02:20:27 -0000
*************** proc is_elf_format {} {
*** 297,302 ****
--- 297,306 ----
  #	to pass.  The PROG, objdump, nm and objcopy options have no
  #	meaning and need not supplied if this is present.
  #
+ #   warning: REGEX
+ #	Expect a gas warning matching REGEX.  It is an error to issue
+ #	both "error" and "warning".
+ #
  # Each option may occur at most once.
  #
  # After the option lines come regexp lines.  `run_dump_test' calls
*************** proc run_dump_test { name {extra_options
*** 333,338 ****
--- 337,343 ----
      set opts(source) {}
      set opts(stderr) {}
      set opts(error) {}
+     set opts(warning) {}
  
      foreach i $opt_array {
  	set opt_name [lindex $i 0]
*************** proc run_dump_test { name {extra_options
*** 406,411 ****
--- 411,426 ----
  	}
      }
  
+     set expmsg $opts(error)
+     if { $opts(warning) != "" } {
+ 	set expmsg $opts(warning)
+     }
+     if { (($opts(warning) != "") && ($opts(error) != "")) \
+ 	 || (($opts(warning) != "") && ($opts(stderr) != "")) } {
+ 	perror "$testname: bad mix of stderr, error and warning test-directives"
+ 	return
+     }
+ 
      set progopts1 $opts($program)
      eval set progopts \$[string toupper $program]FLAGS
      eval set binary \$[string toupper $program]
*************** proc run_dump_test { name {extra_options
*** 421,444 ****
  	set sourcefile $srcdir/$subdir/$opts(source)
      }
  
!     send_log "$AS $ASFLAGS $opts(as) -o dump.o $sourcefile\n"
!     catch "exec $srcdir/lib/run $AS $ASFLAGS $opts(as) -o dump.o $sourcefile" comp_output
      set comp_output [prune_warnings $comp_output]
  
!     if { ![string match "" $comp_output] || $opts(stderr) != "" } then {
  	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 {
  	    catch {write_file dump.stderr "$comp_output"} write_output
  	    if ![string match "" $write_output] then {
--- 436,480 ----
  	set sourcefile $srcdir/$subdir/$opts(source)
      }
  
!     set cmd "$srcdir/lib/run $AS $ASFLAGS $opts(as) -o dump.o $sourcefile"
!     send_log "$cmd\n"
!     set cmdret [catch "exec $cmd" comp_output]
      set comp_output [prune_warnings $comp_output]
  
!     if { $cmdret != 0 || $comp_output != "" || $opts(stderr) != "" } then {
! 	# If the executed program writes to stderr and stderr is not
! 	# redirected, exec *always* returns failure, regardless of the
! 	# program exit code.  Thankfully, we can retrieve the true
! 	# return status from a special variable.  Redirection would
! 	# cause a tcl-specific message to be appended, and we'd rather
! 	# not deal with that if we can help it.
! 	global errorCode
! 	if { $cmdret != 0 && [lindex $errorCode 0] == "NONE" } {
! 	    set cmdret 0
! 	}
! 
! 	set exitstat "succeeded"
! 	if { $cmdret != 0 } { set exitstat "failed" }
! 
  	if { $opts(stderr) == "" }  then {
  	    send_log "$comp_output\n"
  	    verbose "$comp_output" 3
  
! 	    if { $expmsg != "" \
! 		    && [regexp $expmsg $comp_output] \
! 		    && (($cmdret == 0) == ($opts(warning) != "")) } {
! 		verbose -log "$exitstat with: <$comp_output>, expected: <$expmsg>"
! 
! 		# Only "pass" and return here if we expected (and got)
! 		# an error.
! 		if { $opts(error) != "" } {
  		    pass $testname
  		    return
  		}
+ 	    } {
+ 		fail $testname
+ 		return
  	    }
  	} else {
  	    catch {write_file dump.stderr "$comp_output"} write_output
  	    if ![string match "" $write_output] then {
*************** proc run_dump_test { name {extra_options
*** 454,460 ****
  	    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
--- 490,496 ----
  	    verbose "wrote pruned stderr to dump.stderr" 3
  	    if { [regexp_diff "dump.stderr" "$stderrfile"] } then {
  		if { $opts(error) != "" } {
! 		    verbose -log "$exitstat with: <$comp_output>, expected: <$opts(error)>"
  		    if [regexp $opts(error) $comp_output] {
  			pass $testname
  			return

brgds, H-P

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA:] ld/testsuite/ld-lib.exp: support run_dump_test directive "warning".
  2005-02-07 16:05   ` Hans-Peter Nilsson
@ 2005-02-21 15:52     ` Alan Modra
  2005-02-21 16:36       ` Alan Modra
  2005-02-21 17:43       ` Hans-Peter Nilsson
  0 siblings, 2 replies; 6+ messages in thread
From: Alan Modra @ 2005-02-21 15:52 UTC (permalink / raw)
  To: binutils

On Mon, Feb 07, 2005 at 03:29:51AM +0100, Hans-Peter Nilsson wrote:
> 	* lib/gas-defs.exp: Support new directive "warning".

This change introduced spurious failures in the d10v gas testsuite,
which was using #error to detect gas warnings.

gas/testsuite/
	* gas/d10v/instruction_packing-005.d: Adjust.
	* gas/d10v/instruction_packing-008.d: Ignore disassembled stabs.
	* gas/d10v/instruction_packing-009.d: Likewise.
	* gas/d10v/instruction_packing-010.d: Likewise.
	* gas/d10v/warning-001.d: Use #warning instead of #error.
	* gas/d10v/warning-002.d: Likewise.
	* gas/d10v/warning-003.d: Likewise.
	* gas/d10v/warning-004.d: Likewise.
	* gas/d10v/warning-005.d: Likewise.
	* gas/d10v/warning-006.d: Likewise.
	* gas/d10v/warning-007.d: Likewise.
	* gas/d10v/warning-008.d: Likewise.
	* gas/d10v/warning-009.d: Likewise.
	* gas/d10v/warning-010.d: Likewise.
	* gas/d10v/warning-011.d: Likewise.
	* gas/d10v/warning-012.d: Likewise.
	* gas/d10v/warning-013.d: Likewise.
	* gas/d10v/warning-015.d: Likewise.
	* gas/d10v/warning-016.d: Likewise.
	* gas/d10v/warning-017.d: Likewise.
	* gas/d10v/warning-018.d: Likewise.
	* gas/d10v/warning-019.d: Likewise.
	* lib/gas-defs.exp (run_dump_test): Don't require a dump program if
	#warning given.  Rearrange to allow $program to remain unset.
	Fail the test if warning not found when expected.  Conversely fail
	the test if assembler errors or warnings given when not expected.

Index: gas/testsuite/gas/d10v/instruction_packing-005.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/instruction_packing-005.d,v
retrieving revision 1.1
diff -u -p -r1.1 instruction_packing-005.d
--- gas/testsuite/gas/d10v/instruction_packing-005.d	30 May 2002 16:12:21 -0000	1.1
+++ gas/testsuite/gas/d10v/instruction_packing-005.d	21 Feb 2005 03:05:33 -0000
@@ -25,5 +25,5 @@ Disassembly of section .text:
 Disassembly of section .data:
 
 00000000 <in_data>:
-   0:	Address 0x0 is out of bounds.
+   0:	Address 0x0+ is out of bounds.
 
Index: gas/testsuite/gas/d10v/instruction_packing-008.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/instruction_packing-008.d,v
retrieving revision 1.2
diff -u -p -r1.2 instruction_packing-008.d
--- gas/testsuite/gas/d10v/instruction_packing-008.d	2 Aug 2003 11:34:30 -0000	1.2
+++ gas/testsuite/gas/d10v/instruction_packing-008.d	21 Feb 2005 03:05:33 -0000
@@ -12,3 +12,4 @@ Disassembly of section .text:
    8:	60 22 c0 67 	ldi.s	r2, 0x2	->	ldi.s	r3, 0x3
    c:	e0 40 40 00 	ldi.l	r4, 0x4000
   10:	60 55 cc 1a 	ldi.s	r5, 0x5	->	jmp	r13
+#pass
Index: gas/testsuite/gas/d10v/instruction_packing-009.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/instruction_packing-009.d,v
retrieving revision 1.2
diff -u -p -r1.2 instruction_packing-009.d
--- gas/testsuite/gas/d10v/instruction_packing-009.d	2 Aug 2003 11:34:30 -0000	1.2
+++ gas/testsuite/gas/d10v/instruction_packing-009.d	21 Feb 2005 03:05:33 -0000
@@ -14,3 +14,4 @@ Disassembly of section .text:
   10:	e0 40 40 00 	ldi.l	r4, 0x4000
   14:	20 55 de 00 	ldi.s	r5, 0x5	||	nop	
   18:	26 0d 5e 00 	jmp	r13	||	nop	
+#pass
Index: gas/testsuite/gas/d10v/instruction_packing-010.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/instruction_packing-010.d,v
retrieving revision 1.2
diff -u -p -r1.2 instruction_packing-010.d
--- gas/testsuite/gas/d10v/instruction_packing-010.d	2 Aug 2003 11:34:30 -0000	1.2
+++ gas/testsuite/gas/d10v/instruction_packing-010.d	21 Feb 2005 03:05:33 -0000
@@ -12,3 +12,4 @@ Disassembly of section .text:
    8:	60 22 c0 67 	ldi.s	r2, 0x2	->	ldi.s	r3, 0x3
    c:	e0 40 40 00 	ldi.l	r4, 0x4000
   10:	60 55 cc 1a 	ldi.s	r5, 0x5	->	jmp	r13
+#pass
Index: gas/testsuite/gas/d10v/warning-001.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-001.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-001.d
--- gas/testsuite/gas/d10v/warning-001.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-001.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-001.s
-#error : cr6 is a reserved control register
+#warning : cr6 is a reserved control register
Index: gas/testsuite/gas/d10v/warning-002.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-002.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-002.d
--- gas/testsuite/gas/d10v/warning-002.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-002.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-002.s
-#error : cr6 is a reserved control register
+#warning : cr6 is a reserved control register
Index: gas/testsuite/gas/d10v/warning-003.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-003.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-003.d
--- gas/testsuite/gas/d10v/warning-003.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-003.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-003.s
-#error : cr12 is a reserved control register
+#warning : cr12 is a reserved control register
Index: gas/testsuite/gas/d10v/warning-004.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-004.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-004.d
--- gas/testsuite/gas/d10v/warning-004.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-004.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-004.s
-#error : cr12 is a reserved control register
+#warning : cr12 is a reserved control register
Index: gas/testsuite/gas/d10v/warning-005.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-005.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-005.d
--- gas/testsuite/gas/d10v/warning-005.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-005.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-005.s
-#error : Warning: cr13 is a reserved control register
+#warning : Warning: cr13 is a reserved control register
Index: gas/testsuite/gas/d10v/warning-006.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-006.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-006.d
--- gas/testsuite/gas/d10v/warning-006.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-006.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-006.s
-#error : cr13 is a reserved control register
+#warning : cr13 is a reserved control register
Index: gas/testsuite/gas/d10v/warning-007.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-007.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-007.d
--- gas/testsuite/gas/d10v/warning-007.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-007.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-007.s
-#error : Warning: cr13 is a reserved control register
+#warning : Warning: cr13 is a reserved control register
Index: gas/testsuite/gas/d10v/warning-008.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-008.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-008.d
--- gas/testsuite/gas/d10v/warning-008.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-008.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-008.s
-#error : cr15 is a reserved control register
+#warning : cr15 is a reserved control register
Index: gas/testsuite/gas/d10v/warning-009.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-009.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-009.d
--- gas/testsuite/gas/d10v/warning-009.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-009.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-009.s
-#error : cr15 is a reserved control register
+#warning : cr15 is a reserved control register
Index: gas/testsuite/gas/d10v/warning-010.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-010.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-010.d
--- gas/testsuite/gas/d10v/warning-010.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-010.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-010.s
-#error : cr4 is a reserved control register
+#warning : cr4 is a reserved control register
Index: gas/testsuite/gas/d10v/warning-011.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-011.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-011.d
--- gas/testsuite/gas/d10v/warning-011.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-011.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-011.s
-#error : cr4 is a reserved control register
+#warning : cr4 is a reserved control register
Index: gas/testsuite/gas/d10v/warning-012.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-012.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-012.d
--- gas/testsuite/gas/d10v/warning-012.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-012.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-012.s
-#error : cr5 is a reserved control register
+#warning : cr5 is a reserved control register
Index: gas/testsuite/gas/d10v/warning-013.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-013.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-013.d
--- gas/testsuite/gas/d10v/warning-013.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-013.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-013.s
-#error : cr5 is a reserved control register
+#warning : cr5 is a reserved control register
Index: gas/testsuite/gas/d10v/warning-015.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-015.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-015.d
--- gas/testsuite/gas/d10v/warning-015.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-015.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: instruction_packing-002.s
-#error : Warning: resource conflict \(C flag\)
+#warning : Warning: resource conflict \(C flag\)
Index: gas/testsuite/gas/d10v/warning-016.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-016.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-016.d
--- gas/testsuite/gas/d10v/warning-016.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-016.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-016.s
-#error : Warning: resource conflict \(F flag\)
+#warning : Warning: resource conflict \(F flag\)
Index: gas/testsuite/gas/d10v/warning-017.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-017.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-017.d
--- gas/testsuite/gas/d10v/warning-017.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-017.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-017.s
-#error : Warning: resource conflict \(C flag\)
+#warning : Warning: resource conflict \(C flag\)
Index: gas/testsuite/gas/d10v/warning-018.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-018.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-018.d
--- gas/testsuite/gas/d10v/warning-018.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-018.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-018.s
-#error : Warning: resource conflict \(C flag\)
+#warning : Warning: resource conflict \(C flag\)
Index: gas/testsuite/gas/d10v/warning-019.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/d10v/warning-019.d,v
retrieving revision 1.1
diff -u -p -r1.1 warning-019.d
--- gas/testsuite/gas/d10v/warning-019.d	30 May 2002 16:12:22 -0000	1.1
+++ gas/testsuite/gas/d10v/warning-019.d	21 Feb 2005 03:05:33 -0000
@@ -1,2 +1,2 @@
 #source: warning-019.s
-#error : Warning: resource conflict \(R0\)
+#warning : Warning: resource conflict \(R0\)
Index: gas/testsuite/lib/gas-defs.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/lib/gas-defs.exp,v
retrieving revision 1.19
diff -u -p -r1.19 gas-defs.exp
--- gas/testsuite/lib/gas-defs.exp	7 Feb 2005 02:29:11 -0000	1.19
+++ gas/testsuite/lib/gas-defs.exp	21 Feb 2005 03:05:33 -0000
@@ -371,59 +371,48 @@ proc run_dump_test { name {extra_options
 	append opts($opt_name) $opt_val
     }
 
-    if {$opts(PROG) != ""} {
-	switch -- $opts(PROG) {
-	    objdump
-		{ set program objdump }
-	    nm
-		{ set program nm }
-	    objcopy
-		{ set program objcopy }
-	    readelf
-		{ set program readelf }
-	    default
-		{ perror "unrecognized program option $opts(PROG) in $file.d"
-		  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 ""
-	foreach p {objdump objcopy nm readelf} {
-	    if {$opts($p) != ""} {
-		if {$program != ""} {
-		    perror "ambiguous dump program in $file.d"
+    if { (($opts(warning) != "") && ($opts(error) != "")) \
+	 || (($opts(warning) != "") && ($opts(stderr) != "")) } {
+	perror "$testname: bad mix of stderr, error and warning test-directives"
+	return
+    }
+
+    set program ""
+    # It's meaningless to require an output-testing method when we
+    # expect an error.
+    if { $opts(error) == "" } {
+	if {$opts(PROG) != ""} {
+	    switch -- $opts(PROG) {
+		objdump	{ set program objdump }
+		nm	{ set program nm }
+		objcopy	{ set program objcopy }
+		readelf	{ set program readelf }
+		default	{
+		    perror "unrecognized program option $opts(PROG) in $file.d"
 		    unresolved $subdir/$name
-		    return
-		} else {o
-		    set program $p
+		    return }
+	    }
+	} else {
+	    # Guess which program to run, by seeing which option was specified.
+	    foreach p {objdump objcopy nm readelf} {
+		if {$opts($p) != ""} {
+		    if {$program != ""} {
+			perror "ambiguous dump program in $file.d"
+			unresolved $subdir/$name
+			return
+		    } else {
+			set program $p
+		    }
 		}
 	    }
 	}
-	if {$program == ""} {
+	if { $program == "" && $opts(warning) == "" } {
 	    perror "dump program unspecified in $file.d"
 	    unresolved $subdir/$name
 	    return
 	}
     }
 
-    set expmsg $opts(error)
-    if { $opts(warning) != "" } {
-	set expmsg $opts(warning)
-    }
-    if { (($opts(warning) != "") && ($opts(error) != "")) \
-	 || (($opts(warning) != "") && ($opts(stderr) != "")) } {
-	perror "$testname: bad mix of stderr, error and warning test-directives"
-	return
-    }
-
-    set progopts1 $opts($program)
-    eval set progopts \$[string toupper $program]FLAGS
-    eval set binary \$[string toupper $program]
     if { $opts(name) == "" } {
 	set testname "$subdir/$name"
     } else {
@@ -441,7 +430,11 @@ proc run_dump_test { name {extra_options
     set cmdret [catch "exec $cmd" comp_output]
     set comp_output [prune_warnings $comp_output]
 
-    if { $cmdret != 0 || $comp_output != "" || $opts(stderr) != "" } then {
+    set expmsg $opts(error)
+    if { $opts(warning) != "" } {
+	set expmsg $opts(warning)
+    }
+    if { $cmdret != 0 || $comp_output != "" || $expmsg != "" } then {
 	# If the executed program writes to stderr and stderr is not
 	# redirected, exec *always* returns failure, regardless of the
 	# program exit code.  Thankfully, we can retrieve the true
@@ -460,18 +453,17 @@ proc run_dump_test { name {extra_options
 	    send_log "$comp_output\n"
 	    verbose "$comp_output" 3
 
-	    if { $expmsg != "" \
-		    && [regexp $expmsg $comp_output] \
+	    if { [regexp $expmsg $comp_output] \
 		    && (($cmdret == 0) == ($opts(warning) != "")) } {
-		verbose -log "$exitstat with: <$comp_output>, expected: <$expmsg>"
-
-		# Only "pass" and return here if we expected (and got)
-		# an error.
-		if { $opts(error) != "" } {
+		# We have the expected output from gas.
+		# Return if there's nothing more to do.
+		if { $opts(error) != "" || $program == "" } {
 		    pass $testname
 		    return
 		}
-	    } {
+	    } else {
+		verbose -log "$exitstat with: <$comp_output>, expected: <$expmsg>"
+
 		fail $testname
 		return
 	    }
@@ -503,6 +495,13 @@ proc run_dump_test { name {extra_options
 	}
     }
 
+    if { $program == "" } {
+	return
+    }
+    set progopts1 $opts($program)
+    eval set progopts \$[string toupper $program]FLAGS
+    eval set binary \$[string toupper $program]
+
     if { [which $binary] == 0 } {
 	untested $testname
 	return

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA:] ld/testsuite/ld-lib.exp: support run_dump_test directive "warning".
  2005-02-21 15:52     ` Alan Modra
@ 2005-02-21 16:36       ` Alan Modra
  2005-02-21 17:43       ` Hans-Peter Nilsson
  1 sibling, 0 replies; 6+ messages in thread
From: Alan Modra @ 2005-02-21 16:36 UTC (permalink / raw)
  To: binutils

>	* lib/ld-lib.exp: Support new directive "warning".

This one broke the mmix testsuite.  The following makes similar changes
to those I made to the gas version, and a few more as detailed in the
ChangLog entry.

ld/testsuite/
	* lib/ld-lib.exp (run_dump_test): Don't require a dump program if
	#warning given.  Rearrange to allow $program to remain unset.
	Don't allow gas errors.  Append objcopy_as_link output to that
	from the linker before testing against expected output.  Fail the
	test if warning not found when expected.  Conversely fail the
	test if ld errors or warnings given when not expected.

Index: ld/testsuite/lib/ld-lib.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/lib/ld-lib.exp,v
retrieving revision 1.29
diff -u -p -r1.29 ld-lib.exp
--- ld/testsuite/lib/ld-lib.exp	7 Feb 2005 02:38:43 -0000	1.29
+++ ld/testsuite/lib/ld-lib.exp	21 Feb 2005 06:14:14 -0000
@@ -704,49 +734,42 @@ proc run_dump_test { name } {
 	}
     }
 
-    if {$opts(PROG) != ""} {
-	switch -- $opts(PROG) {
-	    objdump
-		{ set program objdump }
-	    nm
-		{ set program nm }
-	    objcopy
-		{ set program objcopy }
-	    readelf
-		{ set program readelf }
-	    default
+    set program ""
+    # It's meaningless to require an output-testing method when we
+    # expect an error.
+    if { $opts(error) == "" } {
+	if {$opts(PROG) != ""} {
+	    switch -- $opts(PROG) {
+		objdump	{ set program objdump }
+		nm	{ set program nm }
+		objcopy	{ set program objcopy }
+		readelf	{ set program readelf }
+		default
 		{ perror "unrecognized program option $opts(PROG) in $file.d"
 		  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 {
+	    }
+	} else {
 	# Guess which program to run, by seeing which option was specified.
-	set program ""
-	foreach p {objdump objcopy nm readelf} {
-	    if {$opts($p) != ""} {
-		if {$program != ""} {
-		    perror "ambiguous dump program in $file.d"
-		    unresolved $subdir/$name
-		    return
-		} else {
-		    set program $p
+	    foreach p {objdump objcopy nm readelf} {
+		if {$opts($p) != ""} {
+		    if {$program != ""} {
+			perror "ambiguous dump program in $file.d"
+			unresolved $subdir/$name
+			return
+		    } else {
+			set program $p
+		    }
 		}
 	    }
 	}
-	if {$program == ""} {
+	if { $program == "" && $opts(warning) == "" } {
 	    perror "dump program unspecified in $file.d"
 	    unresolved $subdir/$name
 	    return
 	}
     }
 
-    set progopts1 $opts($program)
-    eval set progopts \$[string toupper $program]FLAGS
-    eval set binary \$[string toupper $program]
     if { $opts(name) == "" } {
 	set testname "$subdir/$name"
     } else {
@@ -760,7 +783,7 @@ proc run_dump_test { name } {
 	foreach sf $opts(source) {
 	    if { [string match "/*" $sf] } {
 		lappend sourcefiles "$sf"
-	    } {
+	    } else {
 		lappend sourcefiles "$srcdir/$subdir/$sf"
 	    }
 	    # Must have asflags indexed on source name.
@@ -786,34 +809,30 @@ proc run_dump_test { name } {
 	set cmdret [catch "exec $cmd" comp_output]
 	set comp_output [prune_warnings $comp_output]
 
-	# We accept errors at assembly stage too, unless we're supposed to
-	# link something.
 	if { $cmdret != 0 || ![string match "" $comp_output] } then {
 	    send_log "$comp_output\n"
 	    verbose "$comp_output" 3
-	    if { $opts(error) != "" && $run_ld == 0 } {
-		if [regexp $opts(error) $comp_output] {
-		    pass $testname
-		    return
-		}
-	    }
+
+	    set exitstat "succeeded"
+	    if { $cmdret != 0 } { set exitstat "failed" }
+	    verbose -log "$exitstat with: <$comp_output>"
 	    fail $testname
 	    return
 	}
     }
 
+    set expmsg $opts(error)
+    if { $opts(warning) != "" } {
+	if { $expmsg != "" } {
+	    perror "$testname: mixing error and warning test-directives"
+	    return
+	}
+	set expmsg $opts(warning)
+    }
+
     # Perhaps link the file(s).
     if { $run_ld } {
 	set objfile "tmpdir/dump"
-	set expmsg $opts(error)
-
-	if { $opts(warning) != "" } {
-	    if { $expmsg != "" } {
-		perror "$testname: mixing error and warning test-directives"
-		return
-	    }
-	    set expmsg $opts(warning)
-	}
 
 	# Add -L$srcdir/$subdir so that the linker command can use
 	# linker scripts in the source directory.
@@ -824,7 +843,7 @@ proc run_dump_test { name } {
 	set cmdret [catch "exec $cmd" comp_output]
 	set comp_output [prune_warnings $comp_output]
 
-	if { $cmdret != 0 || $comp_output != "" || $expmsg != "" } then {
+	if { $cmdret != 0 } then {
 	    # If the executed program writes to stderr and stderr is not
 	    # redirected, exec *always* returns failure, regardless of the
 	    # program exit code.  Thankfully, we can retrieve the true
@@ -832,31 +851,12 @@ proc run_dump_test { name } {
 	    # cause a tcl-specific message to be appended, and we'd rather
 	    # not deal with that if we can help it.
 	    global errorCode
-	    if { $cmdret != 0 && [lindex $errorCode 0] == "NONE" } {
+	    if { [lindex $errorCode 0] == "NONE" } {
 		set cmdret 0
 	    }
-
-	    set exitstat "succeeded"
-	    if { $cmdret != 0 } { set exitstat "failed" }
-	    verbose -log "$exitstat with: <$comp_output>, expected: <$expmsg>"
-	    send_log "$comp_output\n"
-	    verbose "$comp_output" 3
-	    if { $expmsg != "" && $run_objcopy == 0 \
-		    && [regexp $expmsg $comp_output] \
-		    && (($cmdret == 0) == ($opts(warning) != "")) } {
-		# Only "pass" and return here if we expected (and got)
-		# an error.
-		if { $opts(error) != "" } {
-		    pass $testname
-		    return
-		}
-	    } {
-		fail $testname
-		return
-	    }
 	}
 
-	if { $run_objcopy } {
+	if { $cmdret == 0 && $run_objcopy } {
 	    set infile $objfile
 	    set objfile "tmpdir/dump1"
 
@@ -866,18 +866,32 @@ proc run_dump_test { name } {
 
 	    send_log "$cmd\n"
 	    set cmdret [catch "exec $cmd" comp_output]
-	    set comp_output [prune_warnings $comp_output]
+	    append comp_output [prune_warnings $comp_output]
 
-	    if { $cmdret != 0 || ![string match "" $comp_output] } then {
-		verbose -log "failed with: <$comp_output>, expected: <$opts(error)>"
-		send_log "$comp_output\n"
-		verbose "$comp_output" 3
-		if { $opts(error) != "" } {
-		    if [regexp $opts(error) $comp_output] {
-			pass $testname
-			return
-		    }
+	    if { $cmdret != 0 } then {
+		global errorCode
+		if { [lindex $errorCode 0] == "NONE" } {
+		    set cmdret 0
+		}
+	    }
+	}
+
+	if { $cmdret != 0 || $comp_output != "" || $expmsg != "" } then {
+	    set exitstat "succeeded"
+	    if { $cmdret != 0 } { set exitstat "failed" }
+	    verbose -log "$exitstat with: <$comp_output>, expected: <$expmsg>"
+	    send_log "$comp_output\n"
+	    verbose "$comp_output" 3
+
+	    if { [regexp $expmsg $comp_output] \
+		    && (($cmdret == 0) == ($opts(warning) != "")) } {
+		# We have the expected output from ld.
+		if { $opts(error) != "" || $program == "" } {
+		    pass $testname
+		    return
 		}
+	    } else {
+		verbose -log "$exitstat with: <$comp_output>, expected: <$expmsg>"
 		fail $testname
 		return
 	    }
@@ -892,6 +906,10 @@ proc run_dump_test { name } {
 	return
     }
 
+    set progopts1 $opts($program)
+    eval set progopts \$[string toupper $program]FLAGS
+    eval set binary \$[string toupper $program]
+
     if { [which $binary] == 0 } {
 	untested $testname
 	return

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA:] ld/testsuite/ld-lib.exp: support run_dump_test directive "warning".
  2005-02-21 15:52     ` Alan Modra
  2005-02-21 16:36       ` Alan Modra
@ 2005-02-21 17:43       ` Hans-Peter Nilsson
  1 sibling, 0 replies; 6+ messages in thread
From: Hans-Peter Nilsson @ 2005-02-21 17:43 UTC (permalink / raw)
  To: binutils

On Mon, 21 Feb 2005, Alan Modra wrote:
> On Mon, Feb 07, 2005 at 03:29:51AM +0100, Hans-Peter Nilsson wrote:
> > 	* lib/gas-defs.exp: Support new directive "warning".
>
> This change introduced spurious failures in the d10v gas testsuite,
> which was using #error to detect gas warnings.

Sorry, and thanks for cleaning up this and the ld-lib.exp
fallout.  (I must confess I knew about the MMIX failures; I
wanted to see how long it took for someone else to notice!)

brgds, H-P

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-02-21 11:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-06 14:20 [RFA:] ld/testsuite/ld-lib.exp: support run_dump_test directive "warning" Hans-Peter Nilsson
2005-02-06 16:52 ` Ian Lance Taylor
2005-02-07 16:05   ` Hans-Peter Nilsson
2005-02-21 15:52     ` Alan Modra
2005-02-21 16:36       ` Alan Modra
2005-02-21 17:43       ` Hans-Peter Nilsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).