Commit ba40ad5e authored by Per Cederqvist's avatar Per Cederqvist

(hollerith): New constant.

(maxint): New constant.
(clientport): New constant.
(muxport): New constant.
(unanchored_expect): Continue with the expect if an unexpected line is
	detected.
(lyskomd_start): New proc.
(lyskomd_death): New proc.
(client_start): New proc.
(talk_to): New proc.
(holl): New proc.
parent a443dcc1
set nl "\r?\n"
set any "\[ -\]"
set deep_any "\\\[ -\\\]"
set hollerith "\[0-9\]*H$any*"
set maxint 2147483647
# These magic numbers are also present in the file
# src/server/testsuite/config/Makefile.am
set clientport 53262
set muxport 53263
set stty_init "-echo -onlcr -ocrnl -istrip"
......@@ -63,6 +71,7 @@ proc unanchored_expect {regex testname} {
eof {fail "$test (eof)"; wait}
-re "($any*)$nl" {
fail "$test (unexpected line '$expect_out(1,string)' waiting for '$regex')"
exp_continue
}
-re "($any*)l2g>" {
fail "$test (unexpected incomplete line '$expect_out(1,string)' waiting for '$regex')"
......@@ -70,3 +79,85 @@ proc unanchored_expect {regex testname} {
}
unset test
}
proc lyskomd_start {} {
global spawn_id
global server_id
global test
global nl
spawn ../lyskomd -d config/lyskomd-config
set server_id $spawn_id
set expect_active($server_id) ""
set expect_always($server_id) ""
talk_to lyskomd
set test "server started"
expect {
-re "MSG: garb ready. 0 texts deleted.$nl" {pass "$test"}
timeout {fail "$test (timeout)"}
buffer_full {fail "$test (buffer_full)"}
eof {fail "$test (eof)"; wait}
}
}
proc lyskomd_death {} {
global spawn_id
global server_id
global test
global nl
talk_to lyskomd
set test "server died"
expect {
-re "..*" { exp_continue }
timeout { fail "$test (timeout)" }
eof { pass "$test"; wait }
}
}
proc client_start {nr} {
global client_id
global clientport
global spawn_id
global test
global nl
spawn tcpconnect -rv localhost $clientport
set client_id($nr) $spawn_id
talk_to client $nr
set test "client $nr started"
expect {
-re ".Connected to..*port $clientport.$nl" {pass "$test"}
timeout {fail "$test (timeout)"}
eof {fail "$test (eof)"}
buffer_full {fail "$test (buffer_full)"}
}
}
proc talk_to {what {nr ""}} {
global spawn_id
global server_id
global client_id
switch $what {
lyskomd {
set spawn_id $server_id
}
client {
set spawn_id $client_id($nr)
}
default {
error "attempting to talk to $what"
}
}
verbose "TALKING TO $spawn_id $what $nr"
}
proc holl {str} {
return "[string length $str]H$str"
}
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