diff mbox

[testsuite] gcov.exp: include flags in test summary lines

Message ID 4FDB79F4.6010304@mentor.com
State New
Headers show

Commit Message

Janis Johnson June 15, 2012, 6:07 p.m. UTC
GCOV tests for C++ are run for both std=gnu++98 and std=gnu++11.  Those
options are not reported by GCOV-specific lines in the test summary,
leading to non-unique lines.  This patch modifies the GCOV test support
to use a testname that includes the extra flags used for a set of tests
and also modifies the format of summary lines to better incorporate that
information.  For example, these lines:

  PASS: gcc.misc-tests/gcov-1.c:17 line count
  PASS: gcc.misc-tests/gcov-1.c gcov

  PASS: g++.dg/gcov/gcov-1.C:279 line count
  PASS: g++.dg/gcov/gcov-1.C gcov

are now:

  PASS: gcc.misc-tests/gcov-1.c count for line 17
  PASS: gcc.misc-tests/gcov-1.c gcov

  PASS: g++.dg/gcov/gcov-1.C -std=gnu++98 count for line 279
  PASS: g++.dg/gcov/gcov-1.C -std=gnu++98 gcov
  PASS: g++.dg/gcov/gcov-1.C -std=gnu++11 count for line 279
  PASS: g++.dg/gcov/gcov-1.C -std=gnu++11 gcov

Tested on i686-pc-linux-gnu and arm-eabi for gcc and g++ GCOV tests.
OK for mainline?

Janis
2012-06-15  Janis Johnson  <janisjo@codesourcery.com>

	* lib/gcov.exp (verify-lines, verify-branches, verify-calls): Use
	testname that includes flags, passed in as new argument, in
	pass/fail messages.
	(run_gcov): Get testname from dg-test, use it in pass/fail messages
	and pass it to verify-* procedures.

Comments

Mike Stump June 15, 2012, 7:32 p.m. UTC | #1
On Jun 15, 2012, at 11:07 AM, Janis Johnson wrote:
> GCOV tests for C++ are run for both std=gnu++98 and std=gnu++11.  Those
> options are not reported by GCOV-specific lines in the test summary,

> OK for mainline?

Ok.

It is scary that upvar is ever used....
Janis Johnson June 15, 2012, 7:49 p.m. UTC | #2
On 06/15/2012 12:32 PM, Mike Stump wrote:
> On Jun 15, 2012, at 11:07 AM, Janis Johnson wrote:
>> GCOV tests for C++ are run for both std=gnu++98 and std=gnu++11.  Those
>> options are not reported by GCOV-specific lines in the test summary,
> 
>> OK for mainline?
> 
> Ok.
> 
> It is scary that upvar is ever used....

Yes, it is.  I've sometimes thought that for testname it might be
just a little less scary to use a proc like current_compiler_flags
in target-supports-dg.exp, instead of using upvar in every single
place we need access to that particular variable from dg-test.

Janis
diff mbox

Patch

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