public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Hans-Peter Nilsson <hans-peter.nilsson@axis.com>
To: ian@airs.com
Cc: hans-peter.nilsson@axis.com, binutils@sources.redhat.com
Subject: Re: [RFA:] ld/testsuite/ld-lib.exp: support run_dump_test directive "warning".
Date: Mon, 07 Feb 2005 16:05:00 -0000	[thread overview]
Message-ID: <200502070229.j172TpFa018391@ignucius.se.axis.com> (raw)
In-Reply-To: <m3y8e1lqpr.fsf@gossamer.airs.com> (message from Ian Lance Taylor on 06 Feb 2005 09:15:28 -0500)

> 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

  reply	other threads:[~2005-02-07  2:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-06 14:20 Hans-Peter Nilsson
2005-02-06 16:52 ` Ian Lance Taylor
2005-02-07 16:05   ` Hans-Peter Nilsson [this message]
2005-02-21 15:52     ` Alan Modra
2005-02-21 16:36       ` Alan Modra
2005-02-21 17:43       ` Hans-Peter Nilsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200502070229.j172TpFa018391@ignucius.se.axis.com \
    --to=hans-peter.nilsson@axis.com \
    --cc=binutils@sources.redhat.com \
    --cc=ian@airs.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).