Commit b616eb02 by Janis Johnson Committed by Janis Johnson

gcov.exp (verify-lines, [...]): Use testname that includes flags, passed in as…

gcov.exp (verify-lines, [...]): Use testname that includes flags, passed in as new argument, in pass/fail messages.

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

From-SVN: r188681
parent 165b955b
2012-06-15 Janis Johnson <janosjo@codesourcery.com> 2012-06-15 Janis Johnson <janosjo@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.
* g++.dg/torture/stackalign/stackalign.exp: Combine stack * g++.dg/torture/stackalign/stackalign.exp: Combine stack
alignment torture options with usual torture options. alignment torture options with usual torture options.
......
...@@ -34,12 +34,14 @@ proc clean-gcov { testcase } { ...@@ -34,12 +34,14 @@ proc clean-gcov { testcase } {
# #
# verify-lines -- check that line counts are as expected # 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. # 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" #send_user "verify-lines\n"
global subdir global subdir
set failed 0 set failed 0
set fd [open $file r] set fd [open $file r]
while { [gets $fd line] >= 0 } { while { [gets $fd line] >= 0 } {
...@@ -54,13 +56,13 @@ proc verify-lines { testcase file } { ...@@ -54,13 +56,13 @@ proc verify-lines { testcase file } {
} }
} }
if { $is == "" } { if { $is == "" } {
fail "$subdir/$testcase:$n:no data available for this line" fail "$testname line $n: no data available"
incr failed incr failed
} elseif { $is != $shouldbe } { } elseif { $is != $shouldbe } {
fail "$subdir/$testcase:$n:is $is:should be $shouldbe" fail "$testname line $n: is $is:should be $shouldbe"
incr failed incr failed
} else { } else {
pass "$subdir/$testcase:$n line count" pass "$testname count for line $n"
} }
} }
} }
...@@ -71,7 +73,8 @@ proc verify-lines { testcase file } { ...@@ -71,7 +73,8 @@ proc verify-lines { testcase file } {
# #
# verify-branches -- check that branch percentages are as expected # 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. # FILE is the name of the gcov output file.
# #
# Checks are based on comments in the source file. This means to look for # Checks are based on comments in the source file. This means to look for
...@@ -86,8 +89,9 @@ proc verify-lines { testcase file } { ...@@ -86,8 +89,9 @@ proc verify-lines { testcase file } {
# branch instructions. Don't check for branches that might be # branch instructions. Don't check for branches that might be
# optimized away or replaced with predicated instructions. # optimized away or replaced with predicated instructions.
# #
proc verify-branches { testcase file } { proc verify-branches { testname testcase file } {
#send_user "verify-branches\n" #send_user "verify-branches\n"
set failed 0 set failed 0
set shouldbe "" set shouldbe ""
set fd [open $file r] set fd [open $file r]
...@@ -99,7 +103,7 @@ proc verify-branches { testcase file } { ...@@ -99,7 +103,7 @@ proc verify-branches { testcase file } {
if [regexp "branch\\((\[0-9 \]+)\\)" "$line" all new_shouldbe] { if [regexp "branch\\((\[0-9 \]+)\\)" "$line" all new_shouldbe] {
# All percentages in the current list should have been seen. # All percentages in the current list should have been seen.
if {[llength $shouldbe] != 0} { if {[llength $shouldbe] != 0} {
fail "$n: expected branch percentages not found: $shouldbe" fail "$testname line $n: expected branch percentages not found: $shouldbe"
incr failed incr failed
set shouldbe "" set shouldbe ""
} }
...@@ -117,14 +121,14 @@ proc verify-branches { testcase file } { ...@@ -117,14 +121,14 @@ proc verify-branches { testcase file } {
} elseif [regexp "branch +\[0-9\]+ taken (-\[0-9\]+)%" "$line" \ } elseif [regexp "branch +\[0-9\]+ taken (-\[0-9\]+)%" "$line" \
all taken] { all taken] {
# Percentages should never be negative. # Percentages should never be negative.
fail "$n: negative percentage: $taken" fail "$testname line $n: negative percentage: $taken"
incr failed incr failed
} elseif [regexp "branch +\[0-9\]+ taken (\[0-9\]+)%" "$line" \ } elseif [regexp "branch +\[0-9\]+ taken (\[0-9\]+)%" "$line" \
all taken] { all taken] {
#send_user "$n: taken = $taken\n" #send_user "$n: taken = $taken\n"
# Percentages should never be greater than 100. # Percentages should never be greater than 100.
if {$taken > 100} { if {$taken > 100} {
fail "$n: percentage greater than 100: $taken" fail "$testname line $n: branch percentage greater than 100: $taken"
incr failed incr failed
} }
if {$taken > 50} { if {$taken > 50} {
...@@ -139,7 +143,7 @@ proc verify-branches { testcase file } { ...@@ -139,7 +143,7 @@ proc verify-branches { testcase file } {
} elseif [regexp "branch\\(end\\)" "$line"] { } elseif [regexp "branch\\(end\\)" "$line"] {
# All percentages in the list should have been seen by now. # All percentages in the list should have been seen by now.
if {[llength $shouldbe] != 0} { if {[llength $shouldbe] != 0} {
fail "$n: expected branch percentages not found: $shouldbe" fail "$testname line n: expected branch percentages not found: $shouldbe"
incr failed incr failed
} }
set shouldbe "" set shouldbe ""
...@@ -148,7 +152,7 @@ proc verify-branches { testcase file } { ...@@ -148,7 +152,7 @@ proc verify-branches { testcase file } {
} }
# All percentages in the list should have been seen. # All percentages in the list should have been seen.
if {[llength $shouldbe] != 0} { if {[llength $shouldbe] != 0} {
fail "$n: expected branch percentages not found: $shouldbe" fail "$testname line $n: expected branch percentages not found: $shouldbe"
incr failed incr failed
} }
close $fd close $fd
...@@ -158,7 +162,8 @@ proc verify-branches { testcase file } { ...@@ -158,7 +162,8 @@ proc verify-branches { testcase file } {
# #
# verify-calls -- check that call return percentages are as expected # 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. # FILE is the name of the gcov output file.
# #
# Checks are based on comments in the source file. This means to look for # Checks are based on comments in the source file. This means to look for
...@@ -173,8 +178,9 @@ proc verify-branches { testcase file } { ...@@ -173,8 +178,9 @@ proc verify-branches { testcase file } {
# call instructions. Don't check for calls that are inserted by the # call instructions. Don't check for calls that are inserted by the
# compiler or that might be inlined. # compiler or that might be inlined.
# #
proc verify-calls { testcase file } { proc verify-calls { testname testcase file } {
#send_user "verify-calls\n" #send_user "verify-calls\n"
set failed 0 set failed 0
set shouldbe "" set shouldbe ""
set fd [open $file r] set fd [open $file r]
...@@ -186,7 +192,7 @@ proc verify-calls { testcase file } { ...@@ -186,7 +192,7 @@ proc verify-calls { testcase file } {
if [regexp "returns\\((\[0-9 \]+)\\)" "$line" all new_shouldbe] { if [regexp "returns\\((\[0-9 \]+)\\)" "$line" all new_shouldbe] {
# All percentages in the current list should have been seen. # All percentages in the current list should have been seen.
if {[llength $shouldbe] != 0} { if {[llength $shouldbe] != 0} {
fail "$n: expected return percentages not found: $shouldbe" fail "$testname line $n: expected return percentages not found: $shouldbe"
incr failed incr failed
set shouldbe "" set shouldbe ""
} }
...@@ -195,7 +201,7 @@ proc verify-calls { testcase file } { ...@@ -195,7 +201,7 @@ proc verify-calls { testcase file } {
} elseif [regexp "call +\[0-9\]+ returned (-\[0-9\]+)%" "$line" \ } elseif [regexp "call +\[0-9\]+ returned (-\[0-9\]+)%" "$line" \
all returns] { all returns] {
# Percentages should never be negative. # Percentages should never be negative.
fail "$n: negative percentage: $returns" fail "$testname line $n: negative percentage: $returns"
incr failed incr failed
} elseif [regexp "call +\[0-9\]+ returned (\[0-9\]+)%" "$line" \ } elseif [regexp "call +\[0-9\]+ returned (\[0-9\]+)%" "$line" \
all returns] { all returns] {
...@@ -212,7 +218,7 @@ proc verify-calls { testcase file } { ...@@ -212,7 +218,7 @@ proc verify-calls { testcase file } {
} elseif [regexp "returns\\(end\\)" "$line"] { } elseif [regexp "returns\\(end\\)" "$line"] {
# All percentages in the list should have been seen by now. # All percentages in the list should have been seen by now.
if {[llength $shouldbe] != 0} { if {[llength $shouldbe] != 0} {
fail "$n: expected return percentages not found: $shouldbe" fail "$testname line $n: expected return percentages not found: $shouldbe"
incr failed incr failed
} }
set shouldbe "" set shouldbe ""
...@@ -221,7 +227,7 @@ proc verify-calls { testcase file } { ...@@ -221,7 +227,7 @@ proc verify-calls { testcase file } {
} }
# All percentages in the list should have been seen. # All percentages in the list should have been seen.
if {[llength $shouldbe] != 0} { if {[llength $shouldbe] != 0} {
fail "$n: expected return percentages not found: $shouldbe" fail "$testname line $n: expected return percentages not found: $shouldbe"
incr failed incr failed
} }
close $fd close $fd
...@@ -259,7 +265,10 @@ proc run-gcov { args } { ...@@ -259,7 +265,10 @@ proc run-gcov { args } {
} }
} }
# 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] set testcase [lindex $gcov_args end]
verbose "Running $GCOV $testcase" 2 verbose "Running $GCOV $testcase" 2
...@@ -269,7 +278,7 @@ proc run-gcov { args } { ...@@ -269,7 +278,7 @@ proc run-gcov { args } {
if { $xfailed } { if { $xfailed } {
setup_xfail "*-*-*" setup_xfail "*-*-*"
} }
fail "$subdir/$testcase gcov failed: [lindex $result 1]" fail "$testname gcov failed: [lindex $result 1]"
clean-gcov $testcase clean-gcov $testcase
return return
} }
...@@ -280,24 +289,24 @@ proc run-gcov { args } { ...@@ -280,24 +289,24 @@ proc run-gcov { args } {
if { $xfailed } { if { $xfailed } {
setup_xfail "*-*-*" setup_xfail "*-*-*"
} }
fail "$subdir/$testcase gcov failed: $testcase.gcov does not exist" fail "$testname gcov failed: $testcase.gov does not exist"
clean-gcov $testcase clean-gcov $testcase
return return
} }
remote_upload host $testcase.gcov $testcase.gcov remote_upload host $testcase.gcov $testcase.gcov
# Check that line execution counts are as expected. # 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 # If requested via the .x file, check that branch and call information
# is correct. # is correct.
if { $gcov_verify_branches } { if { $gcov_verify_branches } {
set bfailed [verify-branches $testcase $testcase.gcov] set bfailed [verify-branches $testname $testcase $testcase.gcov]
} else { } else {
set bfailed 0 set bfailed 0
} }
if { $gcov_verify_calls } { if { $gcov_verify_calls } {
set cfailed [verify-calls $testcase $testcase.gcov] set cfailed [verify-calls $testname $testcase $testcase.gcov]
} else { } else {
set cfailed 0 set cfailed 0
} }
...@@ -309,9 +318,9 @@ proc run-gcov { args } { ...@@ -309,9 +318,9 @@ proc run-gcov { args } {
setup_xfail "*-*-*" setup_xfail "*-*-*"
} }
if { $tfailed > 0 } { 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 { } else {
pass "$subdir/$testcase gcov" pass "$testname gcov"
clean-gcov $testcase clean-gcov $testcase
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment