aboutsummaryrefslogtreecommitdiff
path: root/gnu/build
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/build
parentd782de172c68119499202ddac03fdce53ad89a35 (diff)
downloadpatches-5fa7cc5335d64a790d7f0f784a11b25b040cc443.tar
patches-5fa7cc5335d64a790d7f0f784a11b25b040cc443.tar.gz
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/build')
-rw-r--r--gnu/build/marionette.scm17
1 files changed, 16 insertions, 1 deletions
diff --git a/gnu/build/marionette.scm b/gnu/build/marionette.scm
index 506d6da420..424f2b6713 100644
--- a/gnu/build/marionette.scm
+++ b/gnu/build/marionette.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -25,6 +25,7 @@
#:export (marionette?
make-marionette
marionette-eval
+ wait-for-file
marionette-control
marionette-screen-text
wait-for-screen-text
@@ -164,6 +165,20 @@ QEMU monitor and to the guest's backdoor REPL."
(newline repl)
(read repl))))
+(define* (wait-for-file file marionette #:key (timeout 10))
+ "Wait until FILE exists in MARIONETTE; 'read' its content and return it. If
+FILE has not shown up after TIMEOUT seconds, raise an error."
+ (marionette-eval
+ `(let loop ((i ,timeout))
+ (cond ((file-exists? ,file)
+ (call-with-input-file ,file read))
+ ((> i 0)
+ (sleep 1)
+ (loop (- i 1)))
+ (else
+ (error "file didn't show up" ,file))))
+ marionette))
+
(define (marionette-control command marionette)
"Run COMMAND in the QEMU monitor of MARIONETTE. COMMAND is a string such as
\"sendkey ctrl-alt-f1\" or \"screendump foo.ppm\" (info \"(qemu-doc)