From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fl7Ut-0000M1-BB for guix-patches@gnu.org; Thu, 02 Aug 2018 02:54:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fl7Uq-0005ev-9h for guix-patches@gnu.org; Thu, 02 Aug 2018 02:54:07 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:33170) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fl7Uq-0005ed-4X for guix-patches@gnu.org; Thu, 02 Aug 2018 02:54:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fl7Up-0005BU-TW for guix-patches@gnu.org; Thu, 02 Aug 2018 02:54:03 -0400 Subject: [bug#32346] [PATCH 4/6] marionette: Add wait-for-unix-socket. Resent-Message-ID: From: Chris Marusich Date: Wed, 1 Aug 2018 23:51:57 -0700 Message-Id: <20180802065159.20413-4-cmmarusich@gmail.com> In-Reply-To: <20180802065159.20413-1-cmmarusich@gmail.com> References: <20180802064520.20273-1-cmmarusich@gmail.com> <20180802065159.20413-1-cmmarusich@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 32346@debbugs.gnu.org Cc: Chris Marusich * gnu/build/marionette.scm (wait-for-unix-socket): New variable. --- gnu/build/marionette.scm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/gnu/build/marionette.scm b/gnu/build/marionette.scm index 61284b898..3588bcbe6 100644 --- a/gnu/build/marionette.scm +++ b/gnu/build/marionette.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016, 2017, 2018 Ludovic Courtès +;;; Copyright © 2018 Chris Marusich ;;; ;;; This file is part of GNU Guix. ;;; @@ -27,6 +28,7 @@ marionette-eval wait-for-file wait-for-tcp-port + wait-for-unix-socket marionette-control marionette-screen-text wait-for-screen-text @@ -214,6 +216,29 @@ MARIONETTE. Raise an error on failure." ('failure (error "nobody's listening on port" port)))) +(define* (wait-for-unix-socket path marionette + #:key (timeout 20)) + "Wait for up to TIMEOUT seconds for PATH, a Unix domain socket, to accept +connections in MARIONETTE. Raise an error on failure." + (match (marionette-eval + `(begin + (let ((sock (socket PF_UNIX SOCK_STREAM 0))) + (let loop ((i 0)) + (catch 'system-error + (lambda () + (connect sock AF_UNIX ,path) + 'success) + (lambda args + (if (< i ,timeout) + (begin + (sleep 1) + (loop (+ 1 i))) + 'failure)))))) + marionette) + ('success #t) + ('failure + (error "nobody's listening on unix domain socket" path)))) + (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) -- 2.18.0