Whamcloud - gitweb
LU-2405 tests: verify off-by-one symlink length fix
authorNathaniel Clark <nathaniel.l.clark@intel.com>
Thu, 29 Nov 2012 14:14:37 +0000 (09:14 -0500)
committerOleg Drokin <green@whamcloud.com>
Mon, 10 Dec 2012 21:39:42 +0000 (16:39 -0500)
Add regression test for off-by-one bug in symlink code. Ensures boundary
condition of 60 character symlinks are readable after creation.

original commit 6c3606b79a4c25946255a680f79ff2d58df66bbc

Whamcloud-bug-id: LU-2241
Signed-off-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Change-Id: I4264558a5b638e73e7631b988b05b92405d13288
Reviewed-on: http://review.whamcloud.com/4711
Tested-by: Hudson
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
lustre/tests/sanity.sh

index 6aa83f0..d393e5e 100644 (file)
@@ -457,13 +457,29 @@ test_17f() {
 }
 run_test 17f "symlinks: long and very long symlink name ========================"
 
+# str_repeat(S, N) generate a string that is string S repeated N times
+str_repeat() {
+       local s=$1
+       local n=$2
+       local ret=''
+       while [ $((n -= 1)) -ge 0 ]; do
+               ret=$ret$s
+       done
+       echo $ret
+}
+
+# Long symlinks and LU-2241
 test_17g() {
-        mkdir -p $DIR/$tdir
-        LONGSYMLINK="$(dd if=/dev/zero bs=4095 count=1 | tr '\0' 'x')"
-        ln -s $LONGSYMLINK $DIR/$tdir/$tfile
-        ls -l $DIR/$tdir
+       mkdir -p $DIR/$tdir
+       local TESTS="59 60 61 4094 4095"
+
+       for i in $TESTS; do
+               local SYMNAME=$(str_repeat 'x' $i)
+               ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
+               readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
+       done
 }
-run_test 17g "symlinks: really long symlink name ==============================="
+run_test 17g "symlinks: really long symlink name and inode boundaries"
 
 test_17h() { #bug 17378
         mkdir -p $DIR/$tdir