diff --git a/src/server/testsuite/config/unix.exp b/src/server/testsuite/config/unix.exp index c9070cef40fdf7526bb27c0ebf442c6347c46b95..10510f6a5aa10f05964dc62d77687a1d8e6c4cff 100644 --- a/src/server/testsuite/config/unix.exp +++ b/src/server/testsuite/config/unix.exp @@ -93,7 +93,7 @@ proc l2g_start {} { global valgrind if {$valgrind != ""} { - spawn ./valgrind.wrap --num-callers=40 --leak-check=yes --logfile-fd=25 $l2g + spawn ./valgrind.wrap valgrind-l2g.log --suppressions=lyskomd.supp --num-callers=40 --leak-check=yes --logfile-fd=25 --show-reachable=yes $l2g } else { spawn $l2g } @@ -134,7 +134,7 @@ proc l2g_stop {} { simple_expect "test-l2g quitting" wait close - check_valgrind {} + check_valgrind valgrind-l2g.log 1 1 {} } proc l2g_send {str} { @@ -319,17 +319,20 @@ proc unanchored_expect {regex testname} { unset test } -proc spawn_lyskomd {arg} { +proc spawn_lyskomd {logfile arg} { global valgrind global spawn_id set cmd "spawn" if {$valgrind != ""} { set cmd "$cmd ./valgrind.wrap" + set cmd "$cmd $logfile" # set cmd "$cmd -v" set cmd "$cmd --num-callers=40" + set cmd "$cmd --suppressions=lyskomd.supp" set cmd "$cmd --leak-check=yes" set cmd "$cmd --logfile-fd=25" + set cmd "$cmd --show-reachable=yes" } set cmd "$cmd ../lyskomd" if { $arg == "" } { @@ -395,7 +398,7 @@ proc lyskomd_start {{aux_item_conf_file ""} \ puts $cf $extra_config close $cf - set pid [spawn_lyskomd $args] + set pid [spawn_lyskomd valgrind-lyskomd.log $args] set lyskomd_pid $pid set server_id $spawn_id @@ -495,7 +498,7 @@ proc lyskomd_fail_start {{aux_item_conf_file "" } puts $cf $extra_config close $cf - set pid [spawn_lyskomd $args] + set pid [spawn_lyskomd valgrind-lyskomdfail.log $args] set lyskomd_pid $pid set server_id $spawn_id @@ -529,7 +532,7 @@ proc lyskomd_fail_start {{aux_item_conf_file "" } timeout { fail "$test (timeout)" } eof { pass "$test"; wait } } - check_valgrind {} + check_valgrind valgrind-lyskomdfail.log 0 0 {} } proc check_memory_usage {} { @@ -570,7 +573,7 @@ proc parse_valgrind_leak {f} { return 998 } -proc check_valgrind {expected_leaks} { +proc check_valgrind {logfile need_leaks need_errs expected_leaks} { # The "expected_leaks" argument should be a such as: # # {"Bug 99 & Bug 93" 4 3 9} @@ -590,13 +593,23 @@ proc check_valgrind {expected_leaks} { set memfound 0 set errcount 0 set leakcount 0 - set tracefile "valgrind.log" - set f [open $tracefile] + # Rename the file. $saved holds the new name. + while {[file exists "valgrind-$valgrindix.log"]} { + set valgrindix [expr $valgrindix + 1] + } + set saved "valgrind-$valgrindix.log" + system "mv $logfile $saved" + + # Should the log file be kept? + set keep 0 + + set f [open $saved] while {[gets $f line] >= 0} { if {[regexp "ERROR SUMMARY: (\[0-9\]*) errors" $line match errs]} { if {$errfound} { - fail "check_valgrind logic error" + fail "check_valgrind logic error due to $saved" + set keep 1 } else { set errfound 1 set errcount $errs @@ -638,38 +651,36 @@ proc check_valgrind {expected_leaks} { } } close $f - if {$errfound == 0} { - fail "no error summary in valgrind output" + if {$errfound == 0 && $need_errs == 1} { + fail "no error summary in valgrind output $saved" + set keep 1 } - if {$memfound == 0} { - fail "no malloc summary in valgrind output" + if {$memfound == 0 && $need_leaks == 1} { + fail "no malloc summary in valgrind output $saved" + set keep 1 } - if {$errcount + $leakcount > 0} { - while {[file exists "valgrind-$valgrindix.log"]} { - set valgrindix [expr $valgrindix + 1] - } - set saved "valgrind-$valgrindix.log" - system "mv $tracefile $saved" - } - if {$errcount == 0} { pass "valgrind found no errors" } else { fail "valgrind found $errcount error(s). See $saved." + set keep 1 } if {$leakcount == 0} { pass "valgrind found no leaks" } else { if {$definite} { fail "valgrind found $definite definite leaks. See $saved." + set keep 1 } if {$possible} { fail "valgrind found $possible possible leaks. See $saved." + set keep 1 } if {$reachable} { fail "valgrind found $reachable reachable blocks. See $saved." + set keep 1 } } } @@ -692,7 +703,7 @@ proc lyskomd_death {{expected_leaks {}}} { } system "cat etc/memory-usage >> usage.all" check_memory_usage - check_valgrind $expected_leaks + check_valgrind valgrind-lyskomd.log 1 1 $expected_leaks dbck_run } @@ -704,7 +715,7 @@ proc dbck_run {} { global valgrind if {$valgrind != ""} { - spawn ./valgrind.wrap --num-callers=40 --leak-check=yes --logfile-fd=25 ../dbck -d config/lyskomd-config + spawn ./valgrind.wrap valgrind-dbck.log --suppressions=lyskomd.supp --num-callers=40 --logfile-fd=25 --show-reachable=yes ../dbck -d config/lyskomd-config } else { spawn ../dbck -d config/lyskomd-config } @@ -742,7 +753,7 @@ proc dbck_run {} { eof { pass "$test"; wait } } unset test - check_valgrind {} + check_valgrind valgrind-dbck.log 0 1 {} } proc client_start {nr} {