chiark / gitweb /
test: udp-preload: Proof of concept wrapping
[secnet.git] / test / invoke
index 7182d13336286ec8f93afd42c2feb66cc137859a..09b18a3154dd993458fb4de7832bead76c5b224f 100755 (executable)
@@ -25,11 +25,12 @@ set extra(inside) {
 set extra(outside) {}
 
 proc mkconf {which} {
+    global tmp
     global netlink
     global ports
     global extra
     global netlinkfh
-    set pipefp test/$which.netlink
+    set pipefp $tmp/$which.netlink
     foreach tr {t r} {
        file delete $pipefp.$tr
        exec mkfifo -m600 $pipefp.$tr
@@ -37,7 +38,7 @@ proc mkconf {which} {
        fconfigure $fh -blocking 0 -buffering none -translation binary
     }
     fileevent $netlinkfh($which.r) readable [list netlink-readable $which]
-    set fakeuf test/$which.fake-userv
+    set fakeuf $tmp/$which.fake-userv
     set fakeuh [open $fakeuf w 0755]
     puts $fakeuh "#!/bin/sh
 set -e
@@ -95,8 +96,9 @@ exec cat
 
 proc spawn-secnet {which} {
     global netlinkfh
+    global tmp
     upvar #0 pids($which) pid
-    set cf test/$which.conf
+    set cf $tmp/$which.conf
     set ch [open $cf w]
     puts $ch [mkconf $which]
     close $ch
@@ -113,12 +115,12 @@ proc netlink-readable {which} {
     upvar #0 netlinkfh($which.r) fh
     read $fh; # empty the buffer
     switch -exact $which {
-       outside {
+       inside {
            puts OK
            set ok 1; # what a bodge
            return
        }
-       inside {
+       outside {
            error "inside rx'd!"
        }
     }
@@ -153,10 +155,14 @@ proc sendpkt {} {
        [hbytes h2raw c0[join $p ""]c0]
 }
 
+file mkdir test/tmp
+set tmp test/tmp
+
 spawn-secnet inside
 spawn-secnet outside
 
 after 500 sendpkt
 after 1000 sendpkt
+after 5000 timed-out
 
 vwait ok