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]

Re: [RFA:] ld/testsuite/ld-lib.exp: support run_dump_test directive "warning".


>	* 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


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