chiark / gitweb /
stest: Support not running secnet ourselves
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 23 Nov 2019 00:38:01 +0000 (00:38 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 30 Dec 2019 13:15:49 +0000 (13:15 +0000)
Now the user can set SECNET_STEST_DIVERT_inside=1 (say) and instead of
actually running secnet, we print the rune we would run and ask the
user when they have started it.

A freshly started secnet (with this config, at least) just sits there
waiting for its first packet to deal with.  So if the user does this
for the 2nd secnet, that's fine - the first one will happily wait
until the test actually gets going.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
stest/common.tcl

index e368f117647b3de901adf24d3f708e9e97c8bbab..9dff1f05adf37a701303ea45f547ea48745588b6 100644 (file)
@@ -117,18 +117,37 @@ proc spawn-secnet {location site} {
     puts $ch [mkconf $location $site]
     close $ch
     set argl [list $builddir/secnet -dvnc $cf]
+    set divertk SECNET_STEST_DIVERT_$site
     puts -nonewline "spawn"
     foreach k [array names env] {
        switch -glob $k {
+           SECNET_STEST_DIVERT_* -
            SECNET_TEST_BUILDDIR { }
            *SECNET* -
            *PRELOAD* { puts -nonewline " $k=$env($k)" }
        }
     }
     puts " $argl"
-    set pid [fork]
-    if {!$pid} {
-       execl [lindex $argl 0] [lrange $argl 1 end]
+    if {[info exists env($divertk)]} {
+       switch -glob $env($divertk) {
+           i {
+               puts -nonewline "run ^ command, hit return "
+               flush stdout
+               gets stdin
+               set argl {}
+           }
+           0 - "" {
+           }
+           * {
+               set argl [split $env($divertk)]
+           }
+       }
+    }
+    if {[llength $argl]} { 
+       set pid [fork]
+       if {!$pid} {
+           execl [lindex $argl 0] [lrange $argl 1 end]
+       }
     }
     puts -nonewline $netlinkfh($site.t) [hbytes h2raw c0]
 }