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

(maxint): Unused constant removed.

(lyskomd_expect): New proc.
(spawn_lyskomd): Use -f, not -d.
(lyskomd_start): Check all output from lyskomd.
(lyskomd_fail_start): Ditto.
(lyskomd_death): New argument: reason. Check all output from lyskomd.
(talk_to): Set current_talk_what and current_talk_nr, so that
	lyskomd_expect can restore the old settings.  Set proper
	line_leader for lyskomd.
parent 087c2094
......@@ -52,8 +52,6 @@ set hollerith "\[0-9\]*H$any*"
set any_time "\[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]*"
set any_num "\[0-9\]\[0-9\]*"
set maxint 2147483647
# The port that is used for Protocol A connections by the test suite.
set clientport 53262
......@@ -297,6 +295,18 @@ proc simple_expect {regex {testname ""} {is_meta ""}} {
unset test
}
proc lyskomd_expect {regex} {
global current_talk_what
global current_talk_nr
set what $current_talk_what
set nr $current_talk_nr
talk_to lyskomd
simple_expect "$regex"
talk_to $what $nr
}
proc good_bad_expect {good_regex bad_regex {xreason ""}} {
global test
global any
......@@ -422,7 +432,7 @@ proc spawn_lyskomd {logfile arg} {
}
set cmd "$cmd ../lyskomd"
if { $arg == "" } {
set cmd "$cmd -d config/lyskomd-config"
set cmd "$cmd -f config/lyskomd-config"
} else {
set cmd "$cmd $arg"
}
......@@ -439,6 +449,7 @@ proc lyskomd_start {{aux_item_conf_file ""} \
global spawn_id
global server_id
global test
global deep_any
global nl
global attach
global timeout
......@@ -452,6 +463,8 @@ proc lyskomd_start {{aux_item_conf_file ""} \
global debug_calls
global mem_trace
global MEMTRACE
global line_leader
global any
obtain_lock
......@@ -491,7 +504,7 @@ proc lyskomd_start {{aux_item_conf_file ""} \
set server_id $spawn_id
set expect_active($server_id) \
" -i $server_id eof { fail \"\$test (eof on lyskomd)\"; wait }"
" -i $server_id -re \"($deep_any*)$nl\" { fail \"\$test (unexpected line from lyskomd: \$expect_out(1,string))\"; exp_continue } -i $server_id eof { fail \"\$test (eof on lyskomd)\"; wait }"
set expect_always($server_id) \
" -i $server_id buffer_full { fail \"\$test (buffer_full on lyskomd)\" } -i $server_id eof { fail \"\$test (eof on lyskomd)\" }"
......@@ -503,7 +516,7 @@ proc lyskomd_start {{aux_item_conf_file ""} \
set mem_trace 0
set unattached $attach
expect {
-re "Where does the trace want to go today. .stderr." {
-re "^Where does the trace want to go today. .stderr." {
pass "Tracing is activated ($MEMTRACE)"
if {$unattached} {
send_user "Please attach to lyskomd pid $pid and hit RETURN\n"
......@@ -519,17 +532,41 @@ proc lyskomd_start {{aux_item_conf_file ""} \
set mem_trace 1
exp_continue
}
-re "WARNING: This server was compiled with --with-debug-calls" {
-re "^${line_leader}... Version $any* .process $any*. started.$nl" {
}
timeout {fail "$test (timeout)"}
buffer_full {fail "$test (buffer_full)"}
eof {fail "$test (eof)"; wait}
}
set test "Lock created"
expect {
-re "^${line_leader}WARNING: This server was compiled with --with-debug-calls$nl" {
expect -re "^${line_leader}It isn.t safe to use in a production environment.$nl"
pass "debug calls are enabled"
set debug_calls 1
exp_continue
}
-re "MSG: garb ready. 0 texts deleted.$nl" {pass "$test"}
-re "^${line_leader}Created lock ($any*)$nl" {
pass "$test (lock file $expect_out(1,string)"
}
timeout {fail "$test (timeout)"}
buffer_full {fail "$test (buffer_full)"}
eof {fail "$test (eof)"; wait}
}
}
set timeout $t
unset test
simple_expect "Listening for clients on $clientport."
simple_expect "Database = [pwd]/db/lyskomd-data"
simple_expect "Backup = [pwd]/db/lyskomd-backup"
simple_expect "2nd Backup = [pwd]/db/lyskomd-backup-prev"
simple_expect "Lock File = [pwd]/db/lyskomd-lock"
simple_expect "MSG: init_cache: using datafile."
simple_expect "Database saved on $any*"
simple_expect "Read 6 confs/persons and 1 texts"
simple_expect "MSG: garb started."
simple_expect "MSG: garb ready. 0 texts deleted."
if {$unattached} {
send_user "Please attach to lyskomd process $pid and press RETURN\n"
......@@ -541,14 +578,18 @@ proc lyskomd_start {{aux_item_conf_file ""} \
}
}
proc lyskomd_fail_start {{aux_item_conf_file "" }
proc lyskomd_fail_start {log_messages
{aux_item_conf_file "" }
{extra_config ""}
{base_config ""}
{args ""}} {
global spawn_id
global server_id
global test
global deep_any
global any
global nl
global line_leader
global timeout
global expect_active
global expect_always
......@@ -592,9 +633,9 @@ proc lyskomd_fail_start {{aux_item_conf_file "" }
set server_id $spawn_id
set expect_active($server_id) \
" -i $server_id eof { fail \"\$test (eof on lyskomd)\"; wait }"
" -i $server_id -re \"($deep_any*)$nl\" { fail \"\$test (unexpected line from lyskomd: \$expect_out(1,string))\"; exp_continue } -i $server_id eof { fail \"\$test (eof on lyskomd)\"; wait }"
set expect_always($server_id) \
" -i $server_id buffer_full { fail \"\$test (buffer_full on lyskomd)\" }"
" -i $server_id buffer_full { fail \"\$test (buffer_full on lyskomd)\" } -i $server_id eof { fail \"\$test (eof on lyskomd)\" }"
talk_to lyskomd
set test "server start failed"
......@@ -602,22 +643,28 @@ proc lyskomd_fail_start {{aux_item_conf_file "" }
set timeout [expr {2 * $timeout}]
expect {
-re "Where does the trace want to go today. .stderr." {
-re "^Where does the trace want to go today. .stderr." {
pass "Tracing is activated ($MEMTRACE)"
send "$MEMTRACE\n"
exp_continue
}
-re "Search for the core" { pass "$test" }
-re "^${line_leader}... Version $any* .process $any*. started.$nl" {
}
timeout {fail "$test (timeout)" }
buffer_full {fail "$test (buffer_full)" }
eof {fail "$test (eof)"; wait}
}
foreach logmsg $log_messages {
simple_expect "$logmsg"
}
simple_expect "Previous message is fatal. Will dump core now."
simple_expect "Search for the core in [pwd]"
set timeout $t
set test "server died"
expect {
-re "..*" { exp_continue }
timeout { fail "$test (timeout)" }
eof { pass "$test"; wait }
}
......@@ -780,19 +827,25 @@ proc check_valgrind {logfile need_leaks need_errs expected_leaks} {
}
}
proc lyskomd_death {{expected_leaks {}}} {
proc lyskomd_death {{expected_leaks {}} {reason 5}} {
# See check_valgrind for a description of "expected_leaks".
global spawn_id
global server_id
global test
global any
global nl
talk_to lyskomd
simple_expect ".*Press enter to terminate lyskomd"
if {$reason == "signal"} {
simple_expect "Signal HUP received. Shutting down server."
} else {
simple_expect "shutdown initiated by person $reason $any*"
}
simple_expect "../lyskomd terminated normally."
simple_expect "Press enter to terminate lyskomd"
send "\n"
set test "server died"
expect {
-re "..*" { exp_continue }
timeout { fail "$test (timeout)" }
eof { pass "$test"; wait }
}
......@@ -1017,7 +1070,9 @@ proc talk_to {what {nr ""}} {
global l2g_id
global line_leader
global meta_line_leader
global current_client_nr
global current_talk_what
global current_talk_nr
global any_num
set line_leader ""
set meta_line_leader ""
......@@ -1025,6 +1080,7 @@ proc talk_to {what {nr ""}} {
switch $what {
lyskomd {
set spawn_id $server_id
set line_leader "\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\] \[0-9\]\[0-9\]:\[0-9\]\[0-9\]:\[0-9\]\[0-9\] $any_num "
}
client {
set spawn_id $client_id($nr)
......@@ -1038,7 +1094,10 @@ proc talk_to {what {nr ""}} {
}
}
if {$line_leader != ""} {
set current_talk_what $what
set current_talk_nr $nr
if {$line_leader != "" && $what != "lyskomd"} {
set meta_line_leader "${line_leader}meta: "
set line_leader "${line_leader}: "
}
......
Supports Markdown
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