From 8bd5231485cdeb02078c4294badb3a1e7caa0fe0 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 27 Aug 2017 20:58:33 +0200 Subject: marionette: 'wait-for-file' really raises an error when a file is missing. * gnu/build/marionette.scm (wait-for-file): Arrange to call 'error' on the host, not in the guest. --- gnu/build/marionette.scm | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'gnu/build') diff --git a/gnu/build/marionette.scm b/gnu/build/marionette.scm index 424f2b671..789dab3ca 100644 --- a/gnu/build/marionette.scm +++ b/gnu/build/marionette.scm @@ -168,16 +168,20 @@ QEMU monitor and to the guest's backdoor 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)) + (match (marionette-eval + `(let loop ((i ,timeout)) + (cond ((file-exists? ,file) + (cons 'success (call-with-input-file ,file read))) + ((> i 0) + (sleep 1) + (loop (- i 1))) + (else + 'failure))) + marionette) + (('success . result) + result) + ('failure + (error "file didn't show up" file)))) (define (marionette-control command marionette) "Run COMMAND in the QEMU monitor of MARIONETTE. COMMAND is a string such as -- cgit v1.3 From 0a80981178ccf37a48474018929a8f338fb1cf4e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 27 Aug 2017 22:00:19 +0200 Subject: marionette: Fix typing of capital letters. Previously we'd use "sendkey P" instead of "sendkey shift-p", which had no effect. * gnu/build/marionette.scm (character->keystroke): New procedure. (string->keystroke-commands): Use it. --- gnu/build/marionette.scm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'gnu/build') diff --git a/gnu/build/marionette.scm b/gnu/build/marionette.scm index 789dab3ca..d93525abb 100644 --- a/gnu/build/marionette.scm +++ b/gnu/build/marionette.scm @@ -264,6 +264,14 @@ PREDICATE, whichever comes first. Raise an error when TIMEOUT is exceeded." (#\bs . "backspace") (#\tab . "tab"))) +(define (character->keystroke chr keystrokes) + "Return the keystroke for CHR according to the keyboard layout defined by +KEYSTROKES." + (if (char-set-contains? char-set:upper-case chr) + (string-append "shift-" (string (char-downcase chr))) + (or (assoc-ref keystrokes chr) + (string chr)))) + (define* (string->keystroke-commands str #:optional (keystrokes @@ -272,9 +280,9 @@ PREDICATE, whichever comes first. Raise an error when TIMEOUT is exceeded." to STR. KEYSTROKES is an alist specifying a mapping from characters to keystrokes." (string-fold-right (lambda (chr result) - (cons (string-append "sendkey " - (or (assoc-ref keystrokes chr) - (string chr))) + (cons (string-append + "sendkey " + (character->keystroke chr keystrokes)) result)) '() str)) -- cgit v1.3 From 06b8eae3d101b9c1f237de34f21091e085390e11 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 27 Aug 2017 22:01:22 +0200 Subject: marionette: Augment the set of keystrokes. * gnu/build/marionette.scm (%qwerty-us-keystrokes): Add ', ", and `. --- gnu/build/marionette.scm | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gnu/build') diff --git a/gnu/build/marionette.scm b/gnu/build/marionette.scm index d93525abb..f35f0fbca 100644 --- a/gnu/build/marionette.scm +++ b/gnu/build/marionette.scm @@ -261,6 +261,9 @@ PREDICATE, whichever comes first. Raise an error when TIMEOUT is exceeded." (#\. . "dot") (#\, . "comma") (#\; . "semicolon") + (#\' . "apostrophe") + (#\" . "shift-apostrophe") + (#\` . "grave_accent") (#\bs . "backspace") (#\tab . "tab"))) -- cgit v1.3