diff --git a/tests/support/server.tcl b/tests/support/server.tcl index 0afe89f7c..14e59e55c 100644 --- a/tests/support/server.tcl +++ b/tests/support/server.tcl @@ -301,6 +301,13 @@ proc start_server {options {code undefined}} { set stdout [format "%s/%s" [dict get $config "dir"] "stdout"] set stderr [format "%s/%s" [dict get $config "dir"] "stderr"] + # if we're inside a test, write the test name to the server log file + if {[info exists ::cur_test]} { + set fd [open $stdout "a+"] + puts $fd "### Starting server for test $::cur_test" + close $fd + } + # We need a loop here to retry with different ports. set server_started 0 while {$server_started == 0} { @@ -443,6 +450,13 @@ proc restart_server {level wait_ready} { set stderr [dict get $srv "stderr"] set config_file [dict get $srv "config_file"] + # if we're inside a test, write the test name to the server log file + if {[info exists ::cur_test]} { + set fd [open $stdout "a+"] + puts $fd "### Restarting server for test $::cur_test" + close $fd + } + set prev_ready_count [exec grep -i "Ready to accept" | wc -l < $stdout] set pid [spawn_server $config_file $stdout $stderr] diff --git a/tests/support/test.tcl b/tests/support/test.tcl index a5573f583..d266eba41 100644 --- a/tests/support/test.tcl +++ b/tests/support/test.tcl @@ -143,6 +143,18 @@ proc test {name code {okpattern undefined}} { set details {} lappend details "$name in $::curfile" + # set a cur_test global to be logged into new servers that are spown + # and log the test name in all existing servers + set ::cur_test "$name in $::curfile" + if {!$::external} { + foreach srv $::servers { + set stdout [dict get $srv stdout] + set fd [open $stdout "a+"] + puts $fd "### Starting test $::cur_test" + close $fd + } + } + send_data_packet $::test_server_fd testing $name if {[catch {set retval [uplevel 1 $code]} error]} { @@ -183,4 +195,5 @@ proc test {name code {okpattern undefined}} { send_data_packet $::test_server_fd err "Detected a memory leak in test '$name': $output" } } + unset ::cur_test } diff --git a/tests/support/util.tcl b/tests/support/util.tcl index 14b17f4e7..bf590d402 100644 --- a/tests/support/util.tcl +++ b/tests/support/util.tcl @@ -138,6 +138,14 @@ proc wait_for_log_messages {srv_idx patterns from_line maxtries delay} { } } +# write line to server log file +proc write_log_line {srv_idx msg} { + set logfile [srv $srv_idx stdout] + set fd [open $logfile "a+"] + puts $fd "### $msg" + close $fd +} + # Random integer between 0 and max (excluded). proc randomInt {max} { expr {int(rand()*$max)}