[ovs-dev] [PATCH] tests : fix tests #46 and #48 failing on some filesystems

Zoltán Balogh zoltan.balogh at ericsson.com
Tue Feb 16 16:36:50 UTC 2016


Hi,

On my Ubuntu, my home folder is encrypted via ecryptfs. When I run 'make check', the unix socket tests with long pathnames do fail.
This happens because of ecryptfs allows to create files with filename lenght up to 143 characters and the tests try to create sockets with 150 character long names.
With the 'stat' command it is possible to retrieve the maximum length of filename on current filesystem. So I updated the test scripts to check if this length is lower than 150 and use the longest filename according to this length.  

---

diff --git a/tests/library.at b/tests/library.at
index d5dcb12..f03d127 100644
--- a/tests/library.at
+++ b/tests/library.at
@@ -147,8 +147,25 @@ dnl a directory fd using /proc/self/fd/<dirfd>.  We do not have a workaround
 dnl for other platforms, so we skip the test there.
 AT_SETUP([test unix socket, long pathname - C])
 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
-dnl Linux has a 108 byte limit; this is 150 bytes long.
-longname=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
+dnl Linux has a 108 byte limit; this is 150 bytes long.  If filesystem
+dnl supports shorter names then let use the maximum length.
+
+if test -f $(which stat)  && test $(stat --printf=%l -f ./) -lt 150; then
+  longname=""
+  max_length=$(stat --printf=%l -f ./)
+  while test $max_length -gt 0; do
+    for i in 0 1 2 3 4 5 6 7 8 9; do
+      longname=$longname$i
+      max_length=$((max_length-1))
+      if test $max_length -eq 0; then
+        break;
+      fi
+    done
+  done
+else
+  longname=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
+fi
+
 mkdir $longname
 cd $longname
 AT_CHECK([ovstest test-unix-socket ../$longname/socket socket])
@@ -166,8 +183,25 @@ dnl a directory fd using /proc/self/fd/<dirfd>.  We do not have a workaround
 dnl for other platforms, so we skip the test there.
 AT_SETUP([test unix socket, long pathname - Python])
 AT_SKIP_IF([test $HAVE_PYTHON = no || test "$IS_WIN32" = "yes"])
-dnl Linux has a 108 byte limit; this is 150 bytes long.
-longname=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
+dnl Linux has a 108 byte limit; this is 150 bytes long.  If filesystem
+dnl supports shorter names then let use the maximum length.
+
+if test -f $(which stat)  && test $(stat --printf=%l -f ./) -lt 150; then
+  longname=""
+  max_length=$(stat --printf=%l -f ./)
+  while test $max_length -gt 0; do
+    for i in 0 1 2 3 4 5 6 7 8 9; do
+      longname=$longname$i
+      max_length=$((max_length-1))
+      if test $max_length -eq 0; then
+        break;
+      fi
+    done
+  done
+else
+  longname=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
+fi
+
 mkdir $longname
 cd $longname
 AT_CHECK([$PYTHON $abs_srcdir/test-unix-socket.py ../$longname/socket socket])



More information about the dev mailing list