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

(l2g_start): Use valgrind.

(l2g_stop): Check valgrind output.
(lyskomd_fail_start): Use valgrind.
(check_valgrind): Ensure that the memory report is seen.
(dbck_run): Use valgrind.
parent bb1e6778
...@@ -90,8 +90,13 @@ proc l2g_start {} { ...@@ -90,8 +90,13 @@ proc l2g_start {} {
global expect_always global expect_always
global test global test
global MEMTRACE global MEMTRACE
global valgrind
if {$valgrind != ""} {
spawn ./valgrind.wrap --num-callers=40 --leak-check=yes --logfile-fd=25 $l2g
} else {
spawn $l2g spawn $l2g
}
set l2g_id $spawn_id set l2g_id $spawn_id
set expect_active($l2g_id) \ set expect_active($l2g_id) \
" -i $l2g_id eof { fail \"\$test (eof on l2g); wait\" } -re \"^($deep_any*)$nl\" { fail \"\$test (unexpected line '\$expect_out(1,string)')\" } -re \"($deep_any*)l2g> \" { fail \"\$test (unexpected incomplete line '\$expect_out(1,string)')\" } " " -i $l2g_id eof { fail \"\$test (eof on l2g); wait\" } -re \"^($deep_any*)$nl\" { fail \"\$test (unexpected line '\$expect_out(1,string)')\" } -re \"($deep_any*)l2g> \" { fail \"\$test (unexpected incomplete line '\$expect_out(1,string)')\" } "
...@@ -127,8 +132,9 @@ proc l2g_stop {} { ...@@ -127,8 +132,9 @@ proc l2g_stop {} {
l2g_send "q" l2g_send "q"
simple_expect "test-l2g quitting" simple_expect "test-l2g quitting"
close
wait wait
close
check_valgrind {}
} }
proc l2g_send {str} { proc l2g_send {str} {
...@@ -489,12 +495,7 @@ proc lyskomd_fail_start {{aux_item_conf_file "" } ...@@ -489,12 +495,7 @@ proc lyskomd_fail_start {{aux_item_conf_file "" }
puts $cf $extra_config puts $cf $extra_config
close $cf close $cf
if { $args == "" } { set pid [spawn_lyskomd $args]
set pid [spawn ../lyskomd -d config/lyskomd-config]
} else {
set pid [spawn ../lyskomd $args]
}
set lyskomd_pid $pid set lyskomd_pid $pid
set server_id $spawn_id set server_id $spawn_id
...@@ -528,6 +529,7 @@ proc lyskomd_fail_start {{aux_item_conf_file "" } ...@@ -528,6 +529,7 @@ proc lyskomd_fail_start {{aux_item_conf_file "" }
timeout { fail "$test (timeout)" } timeout { fail "$test (timeout)" }
eof { pass "$test"; wait } eof { pass "$test"; wait }
} }
check_valgrind {}
} }
proc check_memory_usage {} { proc check_memory_usage {} {
...@@ -601,6 +603,7 @@ proc check_valgrind {expected_leaks} { ...@@ -601,6 +603,7 @@ proc check_valgrind {expected_leaks} {
} }
} }
if {[regexp "LEAK SUMMARY:" $line]} { if {[regexp "LEAK SUMMARY:" $line]} {
set memfound 1
set definite [parse_valgrind_leak $f] set definite [parse_valgrind_leak $f]
set possible [parse_valgrind_leak $f] set possible [parse_valgrind_leak $f]
set reachable [parse_valgrind_leak $f] set reachable [parse_valgrind_leak $f]
...@@ -630,12 +633,19 @@ proc check_valgrind {expected_leaks} { ...@@ -630,12 +633,19 @@ proc check_valgrind {expected_leaks} {
set leakcount "$reachable" set leakcount "$reachable"
} }
} }
if {[regexp "No malloc'd blocks -- no leaks are possible" $line]} {
set memfound 1
}
} }
close $f close $f
if {$errfound == 0} { if {$errfound == 0} {
fail "no error summary in valgrind output" fail "no error summary in valgrind output"
} }
if {$memfound == 0} {
fail "no malloc summary in valgrind output"
}
if {$errcount + $leakcount > 0} { if {$errcount + $leakcount > 0} {
while {[file exists "valgrind-$valgrindix.log"]} { while {[file exists "valgrind-$valgrindix.log"]} {
set valgrindix [expr $valgrindix + 1] set valgrindix [expr $valgrindix + 1]
...@@ -691,8 +701,13 @@ proc dbck_run {} { ...@@ -691,8 +701,13 @@ proc dbck_run {} {
global test global test
global any_num global any_num
global DBCK_MEMTRACE global DBCK_MEMTRACE
global valgrind
if {$valgrind != ""} {
spawn ./valgrind.wrap --num-callers=40 --leak-check=yes --logfile-fd=25 ../dbck -d config/lyskomd-config
} else {
spawn ../dbck -d config/lyskomd-config spawn ../dbck -d config/lyskomd-config
}
set test "dbck started" set test "dbck started"
expect_after { expect_after {
timeout { fail "$test (timeout)" } timeout { fail "$test (timeout)" }
...@@ -727,6 +742,7 @@ proc dbck_run {} { ...@@ -727,6 +742,7 @@ proc dbck_run {} {
eof { pass "$test"; wait } eof { pass "$test"; wait }
} }
unset test unset test
check_valgrind {}
} }
proc client_start {nr} { proc client_start {nr} {
......
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