Index: lib/gcov.exp
===================================================================
--- lib/gcov.exp	(revision 188622)
+++ lib/gcov.exp	(working copy)
@@ -34,12 +34,14 @@
 #
 # verify-lines -- check that line counts are as expected
 #
-# TESTCASE is the name of the test.
+# TESTNAME is the name of the test, including unique flags.
+# TESTCASE is the name of the test file.
 # FILE is the name of the gcov output file.
 #
-proc verify-lines { testcase file } {
+proc verify-lines { testname testcase file } {
     #send_user "verify-lines\n"
     global subdir
+
     set failed 0
     set fd [open $file r]
     while { [gets $fd line] >= 0 } {
@@ -54,13 +56,13 @@
 		}
 	    }
 	    if { $is == "" } {
-		fail "$subdir/$testcase:$n:no data available for this line"
+		fail "$testname line $n: no data available"
 		incr failed
 	    } elseif { $is != $shouldbe } {
-		fail "$subdir/$testcase:$n:is $is:should be $shouldbe"
+		fail "$testname line $n: is $is:should be $shouldbe"
 		incr failed
 	    } else {
-		pass "$subdir/$testcase:$n line count"
+		pass "$testname count for line $n"
 	    }
 	}
     }
@@ -71,7 +73,8 @@
 #
 # verify-branches -- check that branch percentages are as expected
 #
-# TESTCASE is the name of the test.
+# TESTNAME is the name of the test, including unique flags.
+# TESTCASE is the name of the test file.
 # FILE is the name of the gcov output file.
 #
 # Checks are based on comments in the source file.  This means to look for
@@ -86,8 +89,9 @@
 # branch instructions.  Don't check for branches that might be
 # optimized away or replaced with predicated instructions.
 #
-proc verify-branches { testcase file } {
+proc verify-branches { testname testcase file } {
     #send_user "verify-branches\n"
+
     set failed 0
     set shouldbe ""
     set fd [open $file r]
@@ -99,7 +103,7 @@
 	    if [regexp "branch\\((\[0-9 \]+)\\)" "$line" all new_shouldbe] {
 		# All percentages in the current list should have been seen.
 		if {[llength $shouldbe] != 0} {
-		    fail "$n: expected branch percentages not found: $shouldbe"
+		    fail "$testname line $n: expected branch percentages not found: $shouldbe"
 		    incr failed
 		    set shouldbe ""
 		}
@@ -117,14 +121,14 @@
 	    } elseif [regexp "branch +\[0-9\]+ taken (-\[0-9\]+)%" "$line" \
 			all taken] {
 		# Percentages should never be negative.
-		fail "$n: negative percentage: $taken"
+		fail "$testname line $n: negative percentage: $taken"
 		incr failed
 	    } elseif [regexp "branch +\[0-9\]+ taken (\[0-9\]+)%" "$line" \
 			all taken] {
 		#send_user "$n: taken = $taken\n"
 		# Percentages should never be greater than 100.
 		if {$taken > 100} {
-		    fail "$n: percentage greater than 100: $taken"
+		    fail "$testname line $n: branch percentage greater than 100: $taken"
 		    incr failed
 		}
 		if {$taken > 50} {
@@ -139,7 +143,7 @@
 	    } elseif [regexp "branch\\(end\\)" "$line"] {
 		# All percentages in the list should have been seen by now.
 		if {[llength $shouldbe] != 0} {
-		    fail "$n: expected branch percentages not found: $shouldbe"
+		    fail "$testname line n: expected branch percentages not found: $shouldbe"
 		    incr failed
 		}
 		set shouldbe ""
@@ -148,7 +152,7 @@
     }
     # All percentages in the list should have been seen.
     if {[llength $shouldbe] != 0} {
-	fail "$n: expected branch percentages not found: $shouldbe"
+	fail "$testname line $n: expected branch percentages not found: $shouldbe"
 	incr failed
     }
     close $fd
@@ -158,7 +162,8 @@
 #
 # verify-calls -- check that call return percentages are as expected
 #
-# TESTCASE is the name of the test.
+# TESTNAME is the name of the test, including unique flags.
+# TESTCASE is the name of the test file.
 # FILE is the name of the gcov output file.
 #
 # Checks are based on comments in the source file.  This means to look for
@@ -173,8 +178,9 @@
 # call instructions.  Don't check for calls that are inserted by the
 # compiler or that might be inlined.
 #
-proc verify-calls { testcase file } {
+proc verify-calls { testname testcase file } {
     #send_user "verify-calls\n"
+
     set failed 0
     set shouldbe ""
     set fd [open $file r]
@@ -186,7 +192,7 @@
 	    if [regexp "returns\\((\[0-9 \]+)\\)" "$line" all new_shouldbe] {
 		# All percentages in the current list should have been seen.
 		if {[llength $shouldbe] != 0} {
-		    fail "$n: expected return percentages not found: $shouldbe"
+		    fail "$testname line $n: expected return percentages not found: $shouldbe"
 		    incr failed
 		    set shouldbe ""
 		}
@@ -195,7 +201,7 @@
 	    } elseif [regexp "call +\[0-9\]+ returned (-\[0-9\]+)%" "$line" \
 			all returns] {
 		# Percentages should never be negative.
-		fail "$n: negative percentage: $returns"
+		fail "$testname line $n: negative percentage: $returns"
 		incr failed
 	    } elseif [regexp "call +\[0-9\]+ returned (\[0-9\]+)%" "$line" \
 			all returns] {
@@ -212,7 +218,7 @@
 	    } elseif [regexp "returns\\(end\\)" "$line"] {
 		# All percentages in the list should have been seen by now.
 		if {[llength $shouldbe] != 0} {
-		    fail "$n: expected return percentages not found: $shouldbe"
+		    fail "$testname line $n: expected return percentages not found: $shouldbe"
 		    incr failed
 		}
 		set shouldbe ""
@@ -221,7 +227,7 @@
     }
     # All percentages in the list should have been seen.
     if {[llength $shouldbe] != 0} {
-	fail "$n: expected return percentages not found: $shouldbe"
+	fail "$testname line $n: expected return percentages not found: $shouldbe"
 	incr failed
     }
     close $fd
@@ -259,7 +265,10 @@
 	}
     }
 
-    # Extract the test name from the arguments.
+    # Get the test name, including options that make it unique, from gnu-test 2 levels up.
+    upvar 2 name testname
+
+    # Extract the test file name from the arguments.
     set testcase [lindex $gcov_args end]
 
     verbose "Running $GCOV $testcase" 2
@@ -269,7 +278,7 @@
 	if { $xfailed } {
 	    setup_xfail "*-*-*"
 	}
-	fail "$subdir/$testcase gcov failed: [lindex $result 1]"
+	fail "$testname gcov failed: [lindex $result 1]"
 	clean-gcov $testcase
 	return
     }
@@ -280,24 +289,24 @@
 	if { $xfailed } {
 	    setup_xfail "*-*-*"
 	}
-        fail "$subdir/$testcase gcov failed: $testcase.gcov does not exist"
+        fail "$testname gcov failed: $testcase.gov does not exist"
         clean-gcov $testcase
         return
     }
     remote_upload host $testcase.gcov $testcase.gcov
 
     # Check that line execution counts are as expected.
-    set lfailed [verify-lines $testcase $testcase.gcov]
+    set lfailed [verify-lines $testname $testcase $testcase.gcov]
 
     # If requested via the .x file, check that branch and call information
     # is correct.
     if { $gcov_verify_branches } {
-	set bfailed [verify-branches $testcase $testcase.gcov]
+	set bfailed [verify-branches $testname $testcase $testcase.gcov]
     } else {
 	set bfailed 0
     }
     if { $gcov_verify_calls } {
-	set cfailed [verify-calls $testcase $testcase.gcov]
+	set cfailed [verify-calls $testname $testcase $testcase.gcov]
     } else {
 	set cfailed 0
     }
@@ -309,9 +318,9 @@
 	setup_xfail "*-*-*"
     }
     if { $tfailed > 0 } {
-	fail "$subdir/$testcase gcov: $lfailed failures in line counts, $bfailed in branch percentages, $cfailed in return percentages"
+	fail "$testname gcov: $lfailed failures in line counts, $bfailed in branch percentages, $cfailed in return percentages"
     } else {
-	pass "$subdir/$testcase gcov"
+	pass "$testname gcov"
 	clean-gcov $testcase
     }
 }
