TEST: Maximum description length is limited in more recent kernels

The maximum description size (maxdesclen) in the upstream kernel has been
limited to 4095 plus a NUL char from v3.18 onwards and now this has been
backported to RHEL-6 from kernel release 589 and onwards.

Limit the maxdesc string when an appropriate kernel is detected.

Signed-off-by: David Howells <dhowells@redhat.com>
diff --git a/tests/toolbox.inc.sh b/tests/toolbox.inc.sh
index 88608a3..e1ec033 100644
--- a/tests/toolbox.inc.sh
+++ b/tests/toolbox.inc.sh
@@ -29,9 +29,21 @@
 maxtype=`for ((i=0; i<$((maxtypelen)); i++)); do echo -n a; done`
 
 PAGE_SIZE=`getconf PAGESIZE`
-maxdesclen=$((PAGE_SIZE - 1))
-maxdesc=`for ((i=0; i<$((maxdesclen)); i++)); do echo -n a; done`
-maxcall=$maxdesc
+pagelen=$((PAGE_SIZE - 1))
+fullpage=`for ((i=0; i<$((pagelen)); i++)); do echo -n a; done`
+string4095=`for ((i=0; i<4095; i++)); do echo -n a; done`
+
+if kernel_at_or_later_than 3.18
+then
+    maxdesc=$string4095
+elif [ $OSDIST = RHEL ] && kernel_at_or_later_than 2.6.32-589.el6
+then
+    maxdesc=$string4095
+else
+    maxdesc=$fullpage
+fi
+
+maxcall=$fullpage
 
 maxsquota=`grep '^ *0': /proc/key-users | sed s@.*/@@`