From b42a143f044c9944c01baffb638d1576fc1d1c46 Mon Sep 17 00:00:00 2001 From: "Artyom V. Poptsov" Date: Fri, 15 Jul 2016 23:08:21 +0300 Subject: 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. --- tests/common.scm | 5 ++++- tests/tunnel.scm | 33 ++++++++++++++++++++------------- 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 -- cgit v1.2.3