[Libguestfs] [PATCH nbdkit 2/2] tests: test-single: Fix a race between socat creating the socket and running qemu-img.

Richard W.M. Jones rjones at redhat.com
Thu Apr 12 17:43:32 UTC 2018


If socat is slow and qemu-img is fast then qemu-img opens the socket
before socat creates it, resulting in a test failure.
---
 tests/test-single.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tests/test-single.sh b/tests/test-single.sh
index 9dc462b..fdcfc62 100755
--- a/tests/test-single.sh
+++ b/tests/test-single.sh
@@ -65,4 +65,16 @@ cleanup ()
 }
 trap cleanup INT QUIT TERM EXIT ERR
 
+# Wait for socat to start up and create the socket.
+for i in `seq 1 10`; do
+    if test -S single.sock; then
+        break
+    fi
+    sleep 1
+done
+if ! test -S single.sock; then
+    echo "$0: socket was not created"
+    exit 1
+fi
+
 qemu-img info nbd:unix:single.sock
-- 
2.16.2




More information about the Libguestfs mailing list