chiark / gitweb /
changelog: work on documentation of changes since ea31544cc33a
[secnet.git] / stest / common.tcl
index 6ab275ecadbfef231f77980ef0c3f9d5fb34392d..8897bd90da340a99b4529b65e736691673c7cbb9 100644 (file)
@@ -99,6 +99,12 @@ exec cat
                key-cache priv-cache({
                    privkeys \"$builddir/${privkey}priv.\";
                 });
+"
+       }
+       {load-private *} {
+           set sitesconf sites-nonego.conf
+           append cfg "
+               local-key load-private(\"[lindex $privkey 1]\",\"$builddir/[lindex $privkey 2]\");
 "
        }
        * {
@@ -171,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_* -
@@ -180,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"
            }
        }
     }
@@ -343,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
 }