On 10.10.19 20:18, Eric Blake wrote: > 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?
I would have used mkdir -p, but I saw we used this construct for TEST_DIR, so I thought I‘d just go for the same. > 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. Well, the same applies to TEST_DIR. And technically, as long as we don’t use mkdir -p for either, not catching the error at least helps circumvent the potential race. O:-) (I’ll convert both to mkdir -p with error handling.) Max > Otherwise looks good.
Description: OpenPGP digital signature