[libvirt] [PATCH] tests: Skip daemon-conf test if dir exceeds UNIX_PATH_MAX

The max path length for unix sockets is pretty small (108, see man 7 unix). If 'make check' is run from a directory that exceeds this, one of the tests will fail, and in such a way that requires manually editting the test to determine why. There are certainly other ways to handle this, but I've chosen just to skip the offending test if we will exceed the length limitation. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/daemon-conf | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/daemon-conf b/tests/daemon-conf index 10c1628..8eed4c4 100755 --- a/tests/daemon-conf +++ b/tests/daemon-conf @@ -76,16 +76,22 @@ sed 's,^log_outputs.*,log_outputs="3:file:'"$(pwd)/log"'",' tmp.conf > k \ || fail=1 mv k tmp.conf || fail=1 -$abs_top_builddir/daemon/libvirtd --pid-file=pid-file --config=tmp.conf > log 2>&1 & pid=$! -sleep $sleep_secs -kill $pid +# Unix socket max path size is 108 on linux. If the generated sock path +# exceeds this, the test will fail, so skip it if CWD is too long +SOCKPATH=`pwd`/libvirt-sock +if test ${#SOCKPATH} -lt 108 ; then -RET=0 -# Expect an orderly shut-down and successful exit. -wait $pid || RET=1 + $abs_top_builddir/daemon/libvirtd --pid-file=pid-file --config=tmp.conf > log 2>&1 & pid=$! + sleep $sleep_secs + kill $pid -test_result $i "valid config file (sleeping $sleep_secs seconds)" $RET -test $RET = 0 || fail=1 + RET=0 + # Expect an orderly shut-down and successful exit. + wait $pid || RET=1 + + test_result $i "valid config file (sleeping $sleep_secs seconds)" $RET + test $RET = 0 || fail=1 +fi test_final $i $fail -- 1.6.6.1

On 05/17/2010 11:06 AM, Cole Robinson wrote:
The max path length for unix sockets is pretty small (108, see man 7 unix). If 'make check' is run from a directory that exceeds this, one of the tests will fail, and in such a way that requires manually editting the test to determine why.
There are certainly other ways to handle this, but I've chosen just to skip the offending test if we will exceed the length limitation.
Skipping, with a stderr message of why, sounds reasonable to me.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/daemon-conf | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/tests/daemon-conf b/tests/daemon-conf index 10c1628..8eed4c4 100755 --- a/tests/daemon-conf +++ b/tests/daemon-conf @@ -76,16 +76,22 @@ sed 's,^log_outputs.*,log_outputs="3:file:'"$(pwd)/log"'",' tmp.conf > k \ || fail=1 mv k tmp.conf || fail=1
-$abs_top_builddir/daemon/libvirtd --pid-file=pid-file --config=tmp.conf > log 2>&1 & pid=$! -sleep $sleep_secs -kill $pid +# Unix socket max path size is 108 on linux. If the generated sock path +# exceeds this, the test will fail, so skip it if CWD is too long +SOCKPATH=`pwd`/libvirt-sock +if test ${#SOCKPATH} -lt 108 ; then
Bash-ism. To be portable, you'd have to use something like: if test `echo "$SOCKPATH" | wc -c` -lt 108; then And for that matter, instead of a positive test and re-indenting the rest of the script, it might be nicer to do a negative test and early exit, to leave the rest of the script untouched: if test 108 -lt `...`; then skip_test_ "CWD too long" fi -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 05/17/2010 01:29 PM, Eric Blake wrote:
On 05/17/2010 11:06 AM, Cole Robinson wrote:
The max path length for unix sockets is pretty small (108, see man 7 unix). If 'make check' is run from a directory that exceeds this, one of the tests will fail, and in such a way that requires manually editting the test to determine why.
There are certainly other ways to handle this, but I've chosen just to skip the offending test if we will exceed the length limitation.
Skipping, with a stderr message of why, sounds reasonable to me.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/daemon-conf | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/tests/daemon-conf b/tests/daemon-conf index 10c1628..8eed4c4 100755 --- a/tests/daemon-conf +++ b/tests/daemon-conf @@ -76,16 +76,22 @@ sed 's,^log_outputs.*,log_outputs="3:file:'"$(pwd)/log"'",' tmp.conf > k \ || fail=1 mv k tmp.conf || fail=1
-$abs_top_builddir/daemon/libvirtd --pid-file=pid-file --config=tmp.conf > log 2>&1 & pid=$! -sleep $sleep_secs -kill $pid +# Unix socket max path size is 108 on linux. If the generated sock path +# exceeds this, the test will fail, so skip it if CWD is too long +SOCKPATH=`pwd`/libvirt-sock +if test ${#SOCKPATH} -lt 108 ; then
Bash-ism. To be portable, you'd have to use something like:
if test `echo "$SOCKPATH" | wc -c` -lt 108; then
And for that matter, instead of a positive test and re-indenting the rest of the script, it might be nicer to do a negative test and early exit, to leave the rest of the script untouched:
if test 108 -lt `...`; then skip_test_ "CWD too long" fi
Thanks for the review, I've sent a new patch with your recommended changes. - Cole

On 05/17/2010 11:29 AM, Eric Blake wrote:
+if test ${#SOCKPATH} -lt 108 ; then
Bash-ism. To be portable, you'd have to use something like:
if test `echo "$SOCKPATH" | wc -c` -lt 108; then
Huh, I stand (partially) corrected. POSIX requires support for ${#foo}. If we were to use gnulib's init.sh, we would then have the guarantee that we have enough of a POSIX environment to rely on that particular construct. But right now, test-lib.sh doesn't quite guarantee everything provided in gnulib. Jim, is it time to modify test-lib.sh to borrow more ideas from gnulib's init.sh? -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Eric Blake wrote:
On 05/17/2010 11:29 AM, Eric Blake wrote:
+if test ${#SOCKPATH} -lt 108 ; then
Bash-ism. To be portable, you'd have to use something like:
if test `echo "$SOCKPATH" | wc -c` -lt 108; then
Huh, I stand (partially) corrected. POSIX requires support for ${#foo}. If we were to use gnulib's init.sh, we would then have the guarantee that we have enough of a POSIX environment to rely on that particular construct. But right now, test-lib.sh doesn't quite guarantee everything provided in gnulib.
Jim, is it time to modify test-lib.sh to borrow more ideas from gnulib's init.sh?
Sure. init.sh seems to have stabilized, and should be an improvement over test-lib.sh.
participants (3)
-
Cole Robinson
-
Eric Blake
-
Jim Meyering