]> git.saurik.com Git - redis.git/blobdiff - tests/support/server.tcl
Suppress warnings compiling redis-cli with certain gcc versions.
[redis.git] / tests / support / server.tcl
index 5c5af37d94c8747b62331ace8f4c5dc035b6591e..948b5356ed17e8011e15bcff2b5d09ffb43c0897 100644 (file)
@@ -2,13 +2,14 @@ set ::global_overrides {}
 set ::tags {}
 set ::valgrind_errors {}
 
-proc error_and_quit {config_file error} {
-    puts "!!COULD NOT START REDIS-SERVER\n"
-    puts "CONFIGURATION:"
-    puts [exec cat $config_file]
-    puts "\nERROR:"
-    puts [string trim $error]
-    exit 1
+proc start_server_error {config_file error} {
+    set err {}
+    append err "Cant' start the Redis server\n"
+    append err "CONFIGURATION:"
+    append err [exec cat $config_file]
+    append err "\nERROR:"
+    append err [string trim $error]
+    send_data_packet $::test_server_fd err $err
 }
 
 proc check_valgrind_errors stderr {
@@ -19,10 +20,7 @@ proc check_valgrind_errors stderr {
     if {![regexp -- {ERROR SUMMARY: 0 errors} $buf] ||
         (![regexp -- {definitely lost: 0 bytes} $buf] &&
          ![regexp -- {no leaks are possible} $buf])} {
-        puts "*** VALGRIND ERRORS ***"
-        puts $buf
-        puts "-----------------------"
-        append ::valgrind_errors "$buf\n\n"
+        send_data_packet $::test_server_fd err "Valgrind error: $buf\n"
     }
 }
 
@@ -157,7 +155,8 @@ proc start_server {options {code undefined}} {
     dict set config dir [tmpdir server]
     
     # start every server on a different port
-    dict set config port [incr ::port]
+    set ::port [find_available_port [expr {$::port+1}]]
+    dict set config port $::port
 
     # apply overrides from global space and arguments
     foreach {directive arguments} [concat $::global_overrides $overrides] {
@@ -184,7 +183,7 @@ proc start_server {options {code undefined}} {
     
     # check that the server actually started
     # ugly but tries to be as fast as possible...
-    set retrynum 20
+    if {$::valgrind} {set retrynum 1000} else {set retrynum 100}
     set serverisup 0
 
     if {$::verbose} {
@@ -211,7 +210,10 @@ proc start_server {options {code undefined}} {
     }
 
     if {!$serverisup} {
-        error_and_quit $config_file [exec cat $stderr]
+        set err {}
+        append err [exec cat $stdout] "\n" [exec cat $stderr]
+        start_server_error $config_file $err
+        return
     }
     
     # find out the pid