summaryrefslogtreecommitdiff
path: root/gnu/tests/ssh.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-06-12 23:21:24 +0200
committerLudovic Courtès <ludo@gnu.org>2017-06-12 23:34:14 +0200
commit5fa7cc5335d64a790d7f0f784a11b25b040cc443 (patch)
tree420f5a363b12c2a4c6f3c6e703e59b559f800117 /gnu/tests/ssh.scm
parentd782de172c68119499202ddac03fdce53ad89a35 (diff)
marionette: Factorize 'wait-for-file'.
* gnu/build/marionette.scm (wait-for-file): New procedure. * gnu/tests/base.scm (run-mcron-test)[test](wait-for-file): Remove. Pass second argument in 'wait-for-file' calls. * gnu/tests/ssh.scm (run-ssh-test)[test](wait-for-file): Remove. Pass second argument in 'wait-for-file' calls. * gnu/tests/messaging.scm (run-xmpp-test)[test](guest-wait-for-file): Remove. Use 'wait-for-file' instead, with second argument.
Diffstat (limited to 'gnu/tests/ssh.scm')
-rw-r--r--gnu/tests/ssh.scm18
1 files changed, 2 insertions, 16 deletions
diff --git a/gnu/tests/ssh.scm b/gnu/tests/ssh.scm
index 5f061510818..9c83a9cd481 100644
--- a/gnu/tests/ssh.scm
+++ b/gnu/tests/ssh.scm
@@ -69,20 +69,6 @@ When SFTP? is true, run an SFTP server test."
69 (make-marionette (list #$command "-net" 69 (make-marionette (list #$command "-net"
70 "user,hostfwd=tcp::2222-:22"))) 70 "user,hostfwd=tcp::2222-:22")))
71 71
72 (define (wait-for-file file)
73 ;; Wait until FILE exists in the guest; 'read' its content and
74 ;; return it.
75 (marionette-eval
76 `(let loop ((i 10))
77 (cond ((file-exists? ,file)
78 (call-with-input-file ,file read))
79 ((> i 0)
80 (sleep 1)
81 (loop (- i 1)))
82 (else
83 (error "file didn't show up" ,file))))
84 marionette))
85
86 (define (make-session-for-test) 72 (define (make-session-for-test)
87 "Make a session with predefined parameters for a test." 73 "Make a session with predefined parameters for a test."
88 (make-session #:user "root" 74 (make-session #:user "root"
@@ -141,7 +127,7 @@ root with an empty password."
141 127
142 ;; Check sshd's PID file. 128 ;; Check sshd's PID file.
143 (test-equal "sshd PID" 129 (test-equal "sshd PID"
144 (wait-for-file #$pid-file) 130 (wait-for-file #$pid-file marionette)
145 (marionette-eval 131 (marionette-eval
146 '(begin 132 '(begin
147 (use-modules (gnu services herd) 133 (use-modules (gnu services herd)
@@ -166,7 +152,7 @@ root with an empty password."
166 (channel-open-session channel) 152 (channel-open-session channel)
167 (channel-request-exec channel "echo hello > /root/witness") 153 (channel-request-exec channel "echo hello > /root/witness")
168 (and (zero? (channel-get-exit-status channel)) 154 (and (zero? (channel-get-exit-status channel))
169 (wait-for-file "/root/witness")))))) 155 (wait-for-file "/root/witness" marionette))))))
170 156
171 ;; Connect to the guest over SFTP. Make sure we can write and 157 ;; Connect to the guest over SFTP. Make sure we can write and
172 ;; read a file there. 158 ;; read a file there.