summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArtyom V. Poptsov <poptsov.artyom@gmail.com>2016-07-15 23:08:21 +0300
committerArtyom V. Poptsov <poptsov.artyom@gmail.com>2016-07-15 23:08:21 +0300
commitb42a143f044c9944c01baffb638d1576fc1d1c46 (patch)
treed9d46ae18e8b15d8b35a88f1c7a652deb099bc21 /tests
parenttests/tunnel.scm: Update copyright dates (diff)
downloadguile-ssh-b42a143f044c9944c01baffb638d1576fc1d1c46.tar.gz
tests/common.scm (call-with-connected-session): Ensure that session is connected
* tests/common.scm (call-with-connected-session): Ensure that session is connected. * tests/tunnel.scm ("make-tunnel"): Improve test case: start server process before testing of the client part.
Diffstat (limited to 'tests')
-rw-r--r--tests/common.scm5
-rw-r--r--tests/tunnel.scm33
2 files changed, 24 insertions, 14 deletions
diff --git a/tests/common.scm b/tests/common.scm
index 83318d6..77034ea 100644
--- a/tests/common.scm
+++ b/tests/common.scm
@@ -171,7 +171,10 @@ SSH session object, return the result of the procedure call. The session is
disconnected when the PROC is finished."
(let ((session (make-session-for-test)))
(dynamic-wind
- (lambda () (connect! session))
+ (lambda ()
+ (let ((result (connect! session)))
+ (unless (equal? result 'ok)
+ (error "Could not connect to a server" session result))))
(lambda () (proc session))
(lambda () (disconnect! session)))))
diff --git a/tests/tunnel.scm b/tests/tunnel.scm
index 55a5fd3..68f0436 100644
--- a/tests/tunnel.scm
+++ b/tests/tunnel.scm
@@ -82,19 +82,26 @@
;; Create a tunnel, check the result.
(test-assert-with-log "make-tunnel"
- (call-with-connected-session/tunnel
- (lambda (session)
- (let* ((local-port (get-unused-port))
- (remote-host "www.example.org")
- (tunnel (make-tunnel session
- #:port local-port
- #:host remote-host)))
- (and (eq? (tunnel-session tunnel) session)
- (string=? (tunnel-bind-address tunnel) "127.0.0.1")
- (eq? (tunnel-port tunnel) local-port)
- (eq? (tunnel-host-port tunnel) local-port)
- (eq? (tunnel-host tunnel) remote-host)
- (eq? (tunnel-reverse? tunnel) #f))))))
+ (run-client-test
+ ;; server
+ (lambda (server)
+ (start-server/dt-test server
+ (lambda (channel)
+ (write-line (read-line channel) channel))))
+ (lambda ()
+ (call-with-connected-session/tunnel
+ (lambda (session)
+ (let* ((local-port (get-unused-port))
+ (remote-host "www.example.org")
+ (tunnel (make-tunnel session
+ #:port local-port
+ #:host remote-host)))
+ (and (eq? (tunnel-session tunnel) session)
+ (string=? (tunnel-bind-address tunnel) "127.0.0.1")
+ (eq? (tunnel-port tunnel) local-port)
+ (eq? (tunnel-host-port tunnel) local-port)
+ (eq? (tunnel-host tunnel) remote-host)
+ (eq? (tunnel-reverse? tunnel) #f))))))))
;; Client calls 'call-with-ssh-forward' with a procedure which sends a string