On 10/10/19 10:24 AM, Max Reitz wrote:
Unix sockets generally have a maximum path length.  Depending on your
$TEST_DIR, it may be exceeded and then all tests that create and use
Unix sockets there may fail.

Circumvent this by adding a new scratch directory specifically for
Unix socket files.  It defaults to a temporary directory (mktemp -d)
that is completely removed after the iotests are done.

(By default, mktemp -d creates a /tmp/tmp.XXXXXXXXXX directory, which
should be short enough for our use cases.)

Signed-off-by: Max Reitz <mre...@redhat.com>
---
  tests/qemu-iotests/check | 17 +++++++++++++++++

+tmp_sock_dir=false
+if [ -z "$SOCK_DIR" ]; then
+    SOCK_DIR=$(mktemp -d)
+    tmp_sock_dir=true
+fi
+
+if [ ! -d "$SOCK_DIR" ]; then
+    mkdir "$SOCK_DIR"
+fi

Should this use mkdir -p, in case two parallel processes compete with the same SOCK_DIR?

What if SOCK_DIR is set to something that is not a directory (say a file), at which point mkdir fails, but you don't seem to be catching that failure.

Otherwise looks good.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Reply via email to