chiark / gitweb /
make-secnet-sites: Fix error handling if caller is in wrong group
[secnet.git] / stest / common.tcl
index 239179a375995183283ba6f5d52591d06257d434..8897bd90da340a99b4529b65e736691673c7cbb9 100644 (file)
@@ -177,7 +177,7 @@ proc spawn-secnet {location site} {
     }
     set argl [list $secnet -dvnc $cf]
     set divertk SECNET_STEST_DIVERT_$site
-    puts -nonewline "spawn"
+    puts "spawn:"
     foreach k [array names env] {
        switch -glob $k {
            SECNET_STEST_DIVERT_* -
@@ -186,19 +186,26 @@ proc spawn-secnet {location site} {
            *PRELOAD* { puts -nonewline " $k=$env($k)" }
        }
     }
-    puts " $argl"
     if {[info exists env($divertk)]} {
        switch -glob $env($divertk) {
-           i {
+           i - {i *} {
+               regsub {^i} $env($divertk) {} divert_prefix
+               puts "$divert_prefix $argl"
                puts -nonewline "run ^ command, hit return "
                flush stdout
                gets stdin
                set argl {}
            }
            0 - "" {
+               puts " $argl"
            }
-           * {
+           /* - ./* {
+               puts " $argl"
                set argl [split $env($divertk)]
+               puts "... $argl"
+           }
+           * {
+               error "$divertk not understood"
            }
        }
     }
@@ -349,14 +356,20 @@ proc udp-relay {data src sock args} {
     }
 }
 
+proc adj-after {timeout args} {
+    upvar #0 env(SECNET_STEST_TIMEOUT_MUL) mul
+    if {[info exists mul]} { set timeout [expr {$timeout * $mul}] }
+    eval after $timeout $args
+}
+
 proc test-kex {} {
     udp-proxy
     spawn-secnet in inside
     spawn-secnet out outside
 
-    after 500 sendpkt
-    after 1000 sendpkt
-    after 5000 timed-out
+    adj-after 500 sendpkt
+    adj-after 1000 sendpkt
+    adj-after 5000 timed-out
 
     vwait ok
 }