Whamcloud - gitweb
LU-5068 mdt: check default LMV EA when set reply EA size
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 849b125..433c330 100644 (file)
@@ -38,6 +38,7 @@ export PATH=$PATH:/sbin
 
 TMP=${TMP:-/tmp}
 
+CC=${CC:-cc}
 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
 CREATETEST=${CREATETEST:-createtest}
 LFS=${LFS:-lfs}
@@ -69,6 +70,7 @@ CLEANUP=${CLEANUP:-:}
 SETUP=${SETUP:-:}
 TRACE=${TRACE:-""}
 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
+LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
@@ -1197,16 +1199,71 @@ test_24A() { # LU-3182
        rm -rf $DIR/$tdir
        mkdir -p $DIR/$tdir
        createmany -m $DIR/$tdir/$tfile $NFILES
-       local t=`ls $DIR/$tdir | wc -l`
-       local u=`ls $DIR/$tdir | sort -u | wc -l`
-       if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
-               error "Expected $NFILES files, got $t ($u unique)"
+       local t=$(ls $DIR/$tdir | wc -l)
+       local u=$(ls $DIR/$tdir | sort -u | wc -l)
+       local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
+       if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
+               error "Expected $NFILES files, got $t ($u unique $v .&..)"
        fi
 
        rm -rf $DIR/$tdir || error "Can not delete directories"
 }
 run_test 24A "readdir() returns correct number of entries."
 
+test_24B() { # LU-4805
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       local count
+
+       mkdir $DIR/$tdir
+       $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
+               error "create striped dir failed"
+
+       count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
+       [ $count -eq 2 ] || error "Expected 2, got $count"
+
+       touch $DIR/$tdir/striped_dir/a
+
+       count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
+       [ $count -eq 3 ] || error "Expected 3, got $count"
+
+       touch $DIR/$tdir/striped_dir/.f
+
+       count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
+       [ $count -eq 4 ] || error "Expected 4, got $count"
+
+       rm -rf $DIR/$tdir || error "Can not delete directories"
+}
+run_test 24B "readdir for striped dir return correct number of entries"
+
+test_24C() {
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+
+       mkdir $DIR/$tdir
+       mkdir $DIR/$tdir/d0
+       mkdir $DIR/$tdir/d1
+
+       $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
+               error "create striped dir failed"
+
+       cd $DIR/$tdir/d0/striped_dir
+
+       local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
+       local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
+       local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
+
+       [ "$d0_ino" = "$parent_ino" ] ||
+               error ".. wrong, expect $d0_ino, get $parent_ino"
+
+       mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
+               error "mv striped dir failed"
+
+       parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
+
+       [ "$d1_ino" = "$parent_ino" ] ||
+               error ".. wrong after mv, expect $d1_ino, get $parent_ino"
+}
+run_test 24C "check .. in striped dir"
+
 test_25a() {
        echo '== symlink sanity ============================================='
 
@@ -4489,31 +4546,41 @@ test_56s() { # LU-611
        EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
        CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
        NUMS=$($CMD | wc -l)
-       [ $NUMS -eq $EXPECTED ] ||
+       [ $NUMS -eq $EXPECTED ] || {
+               $GETSTRIPE -R $TDIR
                error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+       }
 
        EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
        CMD="$LFIND -stripe-count +0 -type f $TDIR"
        NUMS=$($CMD | wc -l)
-       [ $NUMS -eq $EXPECTED ] ||
+       [ $NUMS -eq $EXPECTED ] || {
+               $GETSTRIPE -R $TDIR
                error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+       }
 
        EXPECTED=$ONESTRIPE
        CMD="$LFIND -stripe-count 1 -type f $TDIR"
        NUMS=$($CMD | wc -l)
-       [ $NUMS -eq $EXPECTED ] ||
+       [ $NUMS -eq $EXPECTED ] || {
+               $GETSTRIPE -R $TDIR
                error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+       }
 
        CMD="$LFIND -stripe-count -2 -type f $TDIR"
        NUMS=$($CMD | wc -l)
-       [ $NUMS -eq $EXPECTED ] ||
+       [ $NUMS -eq $EXPECTED ] || {
+               $GETSTRIPE -R $TDIR
                error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+       }
 
        EXPECTED=0
        CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
        NUMS=$($CMD | wc -l)
-       [ $NUMS -eq $EXPECTED ] ||
+       [ $NUMS -eq $EXPECTED ] || {
+               $GETSTRIPE -R $TDIR
                error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+       }
 }
 run_test 56s "check lfs find -stripe-count works"
 
@@ -6738,6 +6805,8 @@ test_103 () {
                run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
        fi
 
+       run_acl_subtest 4924 || error "LU-4924 test failed"
+
        cd $SAVE_PWD
        umask $SAVE_UMASK
 
@@ -9014,7 +9083,8 @@ test_133g() {
                -type f \
                -not -name force_lbug \
                -not -name changelog_mask \
-               -exec badarea_io '{}' \; > /dev/null
+               -exec badarea_io '{}' \; &> /dev/null ||
+               error "find $proc_dirs failed"
 
        [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
                skip "Too old lustre on MDS"
@@ -9027,7 +9097,8 @@ test_133g() {
                        -type f \
                        -not -name force_lbug \
                        -not -name changelog_mask \
-                       -exec badarea_io '{}' \\\; &> /dev/null
+                       -exec badarea_io '{}' \\\; &> /dev/null ||
+               error "$facet find $proc_dirs failed"
 
        done
 
@@ -10211,6 +10282,36 @@ test_162() {
 }
 run_test 162 "path lookup sanity"
 
+test_162b() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+
+       mkdir $DIR/$tdir
+       $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
+                               error "create striped dir failed"
+
+       local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
+                                       tail -n 1 | awk '{print $2}')
+       stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
+
+       touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
+       mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
+
+       # regular file
+       for ((i=0;i<5;i++)); do
+               FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
+                       error "get fid for f$i failed"
+               check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
+
+               FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
+                       error "get fid for d$i failed"
+               check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
+       done
+
+       return 0
+}
+run_test 162b "striped directory path lookup sanity"
+
 test_169() {
        # do directio so as not to populate the page cache
        log "creating a 10 Mb file"
@@ -12739,6 +12840,10 @@ test_300g() {
        $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
                error "set default stripe on striped dir error"
 
+       stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/striped_dir)
+       [ $stripe_count -eq $MDSCOUNT ] ||
+               error "default stripe wrong expect $MDSCOUNT get $stripe_count"
+
        mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
 
        for dir in $(find $DIR/$tdir/striped_dir/*); do
@@ -12770,6 +12875,63 @@ test_300g() {
 }
 run_test 300g "check default striped directory for striped directory"
 
+test_400a() { # LU-1606, was conf-sanity test_74
+       local extra_flags=''
+       local out=$TMP/$tfile
+       local prefix=/usr/include/lustre
+       local prog
+
+       if ! which $CC > /dev/null 2>&1; then
+               skip_env "$CC is not installed"
+               return 0
+       fi
+
+       if ! [[ -d $prefix ]]; then
+               # Assume we're running in tree and fixup the include path.
+               extra_flags+=" -I$LUSTRE/../libcfs/include"
+               extra_flags+=" -I$LUSTRE/include"
+               extra_flags+=" -L$LUSTRE/utils"
+       fi
+
+       for prog in $LUSTRE_TESTS_API_DIR/*.c; do
+               $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
+                       error "client api broken"
+       done
+}
+run_test 400a "Lustre client api program can compile and link"
+
+test_400b() { # LU-1606, LU-5011
+       local header
+       local out=$TMP/$tfile
+       local prefix=/usr/include/lustre
+
+       # We use a hard coded prefix so that this test will not fail
+       # when run in tree. There are headers in lustre/include/lustre/
+       # that are not packaged (like lustre_idl.h) and have more
+       # complicated include dependencies (like config.h and lnet/types.h).
+       # Since this test about correct packaging we just skip them when
+       # they don't exist (see below) rather than try to fixup cppflags.
+
+       if ! which $CC > /dev/null 2>&1; then
+               skip_env "$CC is not installed"
+               return 0
+       fi
+
+       for header in $prefix/*.h; do
+               if ! [[ -f "$header" ]]; then
+                       continue
+               fi
+
+               if [[ "$(basename $header)" == liblustreapi.h ]]; then
+                       continue # liblustreapi.h is deprecated.
+               fi
+
+               $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
+                       error "cannot compile '$header'"
+       done
+}
+run_test 400b "packaged headers can be compiled"
+
 #
 # tests that do cleanup/setup should be run at the end
 #