From 82bd987dc9068d3facbff0d6541e6eb306b2d94b Mon Sep 17 00:00:00 2001 From: "Artyom V. Poptsov" Date: Mon, 4 Jul 2016 03:06:45 +0400 Subject: tests/tunnel.scm (call-with-forward-channel): New proc * tests/tunnel.scm (call-with-forward-channel): New procedure. Use it instead of 'make-channel/pf-test'. ('make-channel/pf-test): Remove. --- tests/tunnel.scm | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/tests/tunnel.scm b/tests/tunnel.scm index 1f60761..f68f5f0 100644 --- a/tests/tunnel.scm +++ b/tests/tunnel.scm @@ -46,16 +46,20 @@ (userauth-none! session) (proc session)))) -(define (make-channel/pf-test session) +(define (call-with-forward-channel session proc) (let ((channel (make-channel session))) - (case (channel-open-forward channel - #:source-host "localhost" - #:local-port (get-unused-port) - #:remote-host "localhost" - #:remote-port (1+ (get-unused-port))) - ((ok) - channel) - (else => (cut error "Could not open forward" <>))))) + (dynamic-wind + (const #f) + (lambda () + (case (channel-open-forward channel + #:source-host "localhost" + #:local-port (get-unused-port) + #:remote-host "localhost" + #:remote-port (1+ (get-unused-port))) + ((ok) + (proc channel)) + (else => (cut error "Could not open forward" <>)))) + (lambda () (close channel))))) (test-equal-with-log "port forwarding, direct" @@ -70,12 +74,11 @@ (lambda () (call-with-connected-session/tunnel (lambda (session) - (let ((channel (make-channel/pf-test session))) - (write-line %test-string channel) - (while (not (char-ready? channel))) - (let ((line (read-line channel))) - (close channel) - line))))))) + (call-with-forward-channel session + (lambda (channel) + (write-line %test-string channel) + (while (not (char-ready? channel))) + (read-line channel)))))))) ;; Create a tunnel, check the result. (test-assert-with-log "make-tunnel" -- cgit v1.2.3