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
This commit is contained in:
Janis Johnson 2012-06-15 19:45:54 +00:00 committed by Janis Johnson
parent 165b955b34
commit b616eb029b
2 changed files with 41 additions and 26 deletions

View File

@ -1,5 +1,11 @@
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
alignment torture options with usual torture options.

View File

@ -34,12 +34,14 @@ proc clean-gcov { testcase } {
#
# 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 @@ proc verify-lines { testcase file } {
}
}
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 @@ proc verify-lines { testcase file } {
#
# 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 @@ proc verify-lines { testcase file } {
# 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 @@ proc verify-branches { testcase file } {
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 @@ proc verify-branches { testcase file } {
} 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 @@ proc verify-branches { testcase file } {
} 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 @@ proc verify-branches { testcase file } {
}
# 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 @@ proc verify-branches { testcase file } {
#
# 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 @@ proc verify-branches { testcase file } {
# 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 @@ proc verify-calls { testcase file } {
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 @@ proc verify-calls { testcase file } {
} 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 @@ proc verify-calls { testcase file } {
} 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 @@ proc verify-calls { testcase file } {
}
# 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 @@ 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]
verbose "Running $GCOV $testcase" 2
@ -269,7 +278,7 @@ proc run-gcov { args } {
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 @@ proc run-gcov { args } {
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 @@ proc run-gcov { args } {
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
}
}