[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#32346] [PATCH 4/6] marionette: Add wait-for-unix-socket.
From: |
Chris Marusich |
Subject: |
[bug#32346] [PATCH 4/6] marionette: Add wait-for-unix-socket. |
Date: |
Wed, 1 Aug 2018 23:51:57 -0700 |
* 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 <address@hidden>
+;;; Copyright © 2018 Chris Marusich <address@hidden>
;;;
;;; 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
- [bug#32346] [PATCH 0/6] TOR via Unix domain SOCKS socket, Chris Marusich, 2018/08/02
- [bug#32346] [PATCH 1/6] services: tor: Add a system test., Chris Marusich, 2018/08/02
- [bug#32346] [PATCH 3/6] marionette: Add support for QEMU's "quit" command., Chris Marusich, 2018/08/02
- [bug#32346] [PATCH 2/6] services: tor: Rename activation procedure., Chris Marusich, 2018/08/02
- [bug#32346] [PATCH 5/6] tests: tor: Add more test cases., Chris Marusich, 2018/08/02
- [bug#32346] [PATCH 4/6] marionette: Add wait-for-unix-socket.,
Chris Marusich <=
- [bug#32346] [PATCH 6/6] services: tor: Make it easier to use UNIX sockets., Chris Marusich, 2018/08/02
- [bug#32346] [PATCH 1/6] services: tor: Add a system test., Ludovic Courtès, 2018/08/20
- [bug#32346] [PATCH 0/6] TOR via Unix domain SOCKS socket, Nils Gillmann, 2018/08/02
- [bug#32346] [PATCH 0/6] TOR via Unix domain SOCKS socket, Chris Marusich, 2018/08/04