Commit f36d1c06 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Use the "valgrind" variable from site.exp. It contains a the path

	name of the valgrind binary to use.
(spawn_lyskomd): Adjust accordingly.  Don't use -v.
(check_valgrind): New argument: expected_leaks.
(lyskomd_death): Pass the new optional argument "expected_leaks"
	to check_valgrind.
parent e72a5c52
......@@ -17,11 +17,6 @@ if { ![info exists EFENCE] } {
set EFENCE 0
}
if { ![info exists VALGRIND] } {
set VALGRIND 0
}
# The attach option
if { $ATTACH == "yes" } {
......@@ -37,13 +32,6 @@ if { $EFENCE == "yes" } {
set efence 0
}
# Set this to 1 if valgrind should be used.
if { $VALGRIND == "yes" } {
set valgrind 1
} else {
set valgrind 0
}
# Set MEMTRACE to the file where the trace should be sent.
# This is typically the tty where you are running the attached gdb.
......@@ -330,9 +318,9 @@ proc spawn_lyskomd {arg} {
global spawn_id
set cmd "spawn"
if {$valgrind} {
set cmd "$cmd sh -c \"valgrind"
set cmd "$cmd -v"
if {$valgrind != ""} {
set cmd "$cmd sh -c \"$valgrind"
# set cmd "$cmd -v"
set cmd "$cmd --num-callers=40"
set cmd "$cmd --leak-check=yes"
set cmd "$cmd --logfile-fd=25 25>valgrind.log"
......@@ -343,7 +331,7 @@ proc spawn_lyskomd {arg} {
} else {
set cmd "$cmd $arg"
}
if {$valgrind} {
if {$valgrind != ""} {
set cmd "$cmd\""
}
set pid [eval $cmd]
......@@ -583,11 +571,19 @@ proc parse_valgrind_leak {f} {
return 998
}
proc check_valgrind {} {
proc check_valgrind {expected_leaks} {
# The "expected_leaks" argument should be a such as:
#
# {"Bug 99 & Bug 93" 4 3 9}
#
# that indicates that due to Bug 99 and Bug 93 there will be 4
# definite leaks, 3 possible leaks, and 9 still reachable blocks.
global valgrindix
global valgrind
global test
if {$valgrind == 0} {
if {$valgrind == ""} {
return
}
......@@ -601,7 +597,7 @@ proc check_valgrind {} {
while {[gets $f line] >= 0} {
if {[regexp "ERROR SUMMARY: (\[0-9\]*) errors" $line match errs]} {
if {$errfound} {
fail "check_valgrind logic error 1"
fail "check_valgrind logic error"
} else {
set errfound 1
set errcount $errs
......@@ -611,6 +607,26 @@ proc check_valgrind {} {
set definite [parse_valgrind_leak $f]
set possible [parse_valgrind_leak $f]
set reachable [parse_valgrind_leak $f]
if {$expected_leaks != {}} {
set xreason [lindex $expected_leaks 0]
set exp_def [lindex $expected_leaks 1]
set exp_pos [lindex $expected_leaks 2]
set exp_rea [lindex $expected_leaks 3]
setup_xfail "*-*-*" $xreason
if {$exp_def == $definite
&& $exp_pos == $possible
&& $exp_rea == $reachable} {
fail "memory leaks: $definite definite, $possible possible"
set definite 0
set possible 0
set reachable 0
} else {
pass "wrong memory leak count found"
}
}
set leakcount [expr $definite + $possible]
# Ignore up to 10 reachable blocks. libc leaks some blocks...
if {$reachable > 10} {
......@@ -651,7 +667,8 @@ proc check_valgrind {} {
}
}
proc lyskomd_death {} {
proc lyskomd_death {{expected_leaks {}}} {
# See check_valgrind for a description of "expected_leaks".
global spawn_id
global server_id
global test
......@@ -668,7 +685,7 @@ proc lyskomd_death {} {
}
system "cat etc/memory-usage >> usage.all"
check_memory_usage
check_valgrind
check_valgrind $expected_leaks
dbck_run
}
......
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