summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArtyom V. Poptsov <poptsov.artyom@gmail.com>2016-07-04 03:06:45 +0400
committerArtyom V. Poptsov <poptsov.artyom@gmail.com>2016-07-04 03:06:45 +0400
commit82bd987dc9068d3facbff0d6541e6eb306b2d94b (patch)
treeeb7031b2617d3e4e899642e113b4134e2c785d65 /tests
parenttests/tunnel.scm: Use 'test-equal-with-log' (diff)
downloadguile-ssh-82bd987dc9068d3facbff0d6541e6eb306b2d94b.tar.gz
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/tunnel.scm33
1 files 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"