Commit 604bda54 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(lock_count): New variable.

(obtain_lock): New proc.
(release_lock): New proc.
(l2g_start): Get the lock.
(l2g_stop): Release it.
(lyskomd_start): Get the lock.
(lyskomd_fail_start): Get and release the lock.
(lyskomd_death): Release it.
(client_start_fail): Get and release the lock
parent 4a6d12ee
......@@ -72,6 +72,9 @@ set lyskomd_host [exec python -c "import socket\nprint socket.gethostbyaddr(\"12
# valgrind support
set valgrindix 0
# Recursive lock count.
set lock_count 0
proc efence_blurb {} {
global efence
......@@ -82,6 +85,81 @@ proc efence_blurb {} {
}
}
proc obtain_lock {} {
global lock_count
global nl
global spawn_id
global lock_id
global any
if {$lock_count == 0} {
set redo 1
while {$redo} {
spawn python locksuite.py
set lock_id $spawn_id
expect {
-re "^locking...$nl" {
exp_continue
}
-re "^waiting: socket (.*)$nl" {
warning "Test suite locked by socket $expect_out(1,string)" 0
exp_continue
}
-re "^waiting: file (.*)$nl" {
warning "Test suite locked by file $expect_out(1,string)" 0
exp_continue
}
-re "^failed: file ($any*) (\[a-zA-Z\]*):(\[0-9\]*)$nl" {
warning "failed to obtain lock due to $expect_out(1,string)"
warning "removing stale lock $expect_out(1,string)"
system "rm $expect_out(1,string)"
send "exit\n"
expect bye
expect eof
wait
}
-re "^locked$nl" {
set redo 0
}
timeout {
exp_continue
}
eof {
fail "obtaining lock failed"
wait
}
}
}
}
set lock_count [expr {$lock_count + 1}]
}
proc release_lock {} {
global lock_count
global nl
global spawn_id
global lock_id
if {$lock_count == 1} {
set spawn_id $lock_id
send "exit\n"
expect {
-re "queued: socket (.*)$nl" {
warning "Test suite blocked for $expect_out(1,string)" 0
exp_continue
}
-re "bye$nl"
}
expect eof
wait
}
if {$lock_count < 1} {
error "lock already unlocked"
} else {
set lock_count [expr {$lock_count - 1}]
}
}
proc l2g_start {} {
global spawn_id
global l2g
......@@ -95,6 +173,8 @@ proc l2g_start {} {
global MEMTRACE
global valgrind
obtain_lock
if {$valgrind != ""} {
spawn ./valgrind.wrap valgrind-l2g.log --suppressions=lyskomd.supp --num-callers=40 --leak-check=yes --logfile-fd=25 --show-reachable=yes $l2g
} else {
......@@ -138,6 +218,8 @@ proc l2g_stop {} {
wait
close
check_valgrind valgrind-l2g.log 1 1 {}
release_lock
}
proc l2g_send {str} {
......@@ -370,6 +452,8 @@ proc lyskomd_start {{aux_item_conf_file ""} \
global mem_trace
global MEMTRACE
obtain_lock
if { $aux_item_conf_file == "" } {
set aux_item_conf_file $aux_item_default_conf_file
}
......@@ -474,6 +558,8 @@ proc lyskomd_fail_start {{aux_item_conf_file "" }
global top_srcdir
global MEMTRACE
obtain_lock
if { $aux_item_conf_file == "" } {
set aux_item_conf_file $aux_item_default_conf_file
}
......@@ -535,6 +621,8 @@ proc lyskomd_fail_start {{aux_item_conf_file "" }
eof { pass "$test"; wait }
}
check_valgrind valgrind-lyskomdfail.log 0 0 {}
release_lock
}
proc check_memory_usage {} {
......@@ -711,6 +799,8 @@ proc lyskomd_death {{expected_leaks {}}} {
check_memory_usage
check_valgrind valgrind-lyskomd.log 1 1 $expected_leaks
dbck_run
release_lock
}
proc dbck_run {} {
......@@ -797,6 +887,8 @@ proc client_start_fail {nr {response ""}} {
global srcdir
global deep_any
obtain_lock
spawn python $srcdir/tcpconnect.py localhost $clientport MRK:client$nr
set client_id($nr) $spawn_id
set expect_active($client_id($nr)) " -i $client_id($nr) -re \"($deep_any*)$nl\" { fail \"\$test (unexpected line \$expect_out(1,string))\"; exp_continue } "
......@@ -826,6 +918,8 @@ proc client_start_fail {nr {response ""}} {
unset spawn_id
fix_expect_after
release_lock
}
proc kill_client {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