📄 sanityn.sh
字号:
#!/bin/bashset -eONLY=${ONLY:-"$*"}# bug number for skipped test: 3192 12652 9977ALWAYS_EXCEPT=" 14b 14c 28 $SANITYN_EXCEPT"# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!# bug number for skipped test: 12652 12652grep -q 'Enterprise Server 10' /etc/SuSE-release && ALWAYS_EXCEPT="$ALWAYS_EXCEPT 11 14" || true# Tests that fail on uml[ "$UML" = "true" ] && EXCEPT="$EXCEPT 7"SRCDIR=`dirname $0`PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATHSIZE=${SIZE:-40960}CHECKSTAT=${CHECKSTAT:-"checkstat -v"}CREATETEST=${CREATETEST:-createtest}GETSTRIPE=${GETSTRIPE:-lfs getstripe}SETSTRIPE=${SETSTRIPE:-lstripe}MCREATE=${MCREATE:-mcreate}OPENFILE=${OPENFILE:-openfile}OPENUNLINK=${OPENUNLINK:-openunlink}TOEXCL=${TOEXCL:-toexcl}TRUNCATE=${TRUNCATE:-truncate}export TMP=${TMP:-/tmp}MOUNT_2=${MOUNT_2:-"yes"}CHECK_GRANT=${CHECK_GRANT:-"yes"}GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}SAVE_PWD=$PWDexport NAME=${NAME:-local}LUSTRE=${LUSTRE:-`dirname $0`/..}. $LUSTRE/tests/test-framework.shCLEANUP=${CLEANUP:-:}SETUP=${SETUP:-:}init_test_env $@. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}[ "$SLOW" = "no" ] && EXCEPT_SLOW="12 16"SANITYLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}FAIL_ON_ERROR=falseSETUP=${SETUP:-:}TRACE=${TRACE:-""}LPROC=/proc/fs/lustre[ "$SANITYLOG" ] && rm -f $SANITYLOG || truecheck_and_setup_lustreLPROC=/proc/fs/lustreLOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`rm -rf $DIR1/[df][0-9]* $DIR1/lnk# $RUNAS_ID may get set incorrectly somewhere else[ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"check_runas_id $RUNAS_ID $RUNASbuild_test_filtertest_1a() { touch $DIR1/f1 [ -f $DIR2/f1 ] || error}run_test 1a "check create on 2 mtpt's =========================="test_1b() { chmod 777 $DIR2/f1 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error chmod a-x $DIR2/f1}run_test 1b "check attribute updates on 2 mtpt's ==============="test_1c() { $CHECKSTAT -t file -p 0666 $DIR1/f1 || error}run_test 1c "check after remount attribute updates on 2 mtpt's ="test_1d() { rm $DIR2/f1 $CHECKSTAT -a $DIR1/f1 || error}run_test 1d "unlink on one mountpoint removes file on other ===="test_2a() { touch $DIR1/f2a ls -l $DIR2/f2a chmod 777 $DIR2/f2a $CHECKSTAT -t file -p 0777 $DIR1/f2a || error}run_test 2a "check cached attribute updates on 2 mtpt's ========"test_2b() { touch $DIR1/f2b ls -l $DIR2/f2b chmod 777 $DIR1/f2b $CHECKSTAT -t file -p 0777 $DIR2/f2b || error}run_test 2b "check cached attribute updates on 2 mtpt's ========"# NEED TO SAVE ROOT DIR MODEtest_2c() { chmod 777 $DIR1 $CHECKSTAT -t dir -p 0777 $DIR2 || error}run_test 2c "check cached attribute updates on 2 mtpt's root ==="test_2d() { chmod 755 $DIR1 $CHECKSTAT -t dir -p 0755 $DIR2 || error}run_test 2d "check cached attribute updates on 2 mtpt's root ==="test_2e() { chmod 755 $DIR1 ls -l $DIR1 ls -l $DIR2 chmod 777 $DIR1 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error}run_test 2e "check chmod on root is propagated to others"test_3() { ( cd $DIR1 ; ln -s this/is/good lnk ) [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/lnk'");'`" ] || \ error}run_test 3 "symlink on one mtpt, readlink on another ==========="test_4() { multifstat $DIR1/f4 $DIR2/f4}run_test 4 "fstat validation on multiple mount points =========="test_5() { mcreate $DIR1/f5 truncate $DIR2/f5 100 $CHECKSTAT -t file -s 100 $DIR1/f5 || error rm $DIR1/f5}run_test 5 "create a file on one mount, truncate it on the other"test_6() { openunlink $DIR1/$tfile $DIR2/$tfile || \ error "openunlink $DIR1/$tfile $DIR2/$tfile"}run_test 6 "remove of open file on other node =================="test_7() { # run_one creates uniq $tdir (bug 13798) # opendirunlink failes if it exists rmdir $DIR1/$tdir || true opendirunlink $DIR1/$tdir $DIR2/$tdir || \ error "opendirunlink $DIR1/$tdir $DIR2/$tdir"}run_test 7 "remove of open directory on other node ============="test_8() { opendevunlink $DIR1/$tfile $DIR2/$tfile || \ error "opendevunlink $DIR1/$tfile $DIR2/$tfile"}run_test 8 "remove of open special file on other node =========="test_9() { MTPT=1 > $DIR2/f9 for C in a b c d e f g h i j k l; do DIR=`eval echo \\$DIR$MTPT` echo -n $C >> $DIR/f9 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1 done [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \ error "`od -a $DIR1/f9` != abcdefghijkl"}run_test 9 "append of file with sub-page size on multiple mounts"test_10a() { MTPT=1 OFFSET=0 > $DIR2/f10 for C in a b c d e f g h i j k l; do DIR=`eval echo \\$DIR$MTPT` echo -n $C | dd of=$DIR/f10 bs=1 seek=$OFFSET count=1 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1 OFFSET=`expr $OFFSET + 1` done [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \ error "`od -a $DIR1/f10` != abcdefghijkl"}run_test 10a "write of file with sub-page size on multiple mounts "test_10b() { yes "R" | dd of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1" truncate $DIR1/f10b 4096 || error "truncate 4096" dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2" # create a test file locally to compare yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random" truncate $TMP/f10b 4096 || error "truncate 4096" cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare" rm $TMP/f10b $TMP/f10b-lustre}run_test 10b "write of file with sub-page size on multiple mounts "test_11() { mkdir $DIR1/d11 multiop_bg_pause $DIR1/d11/f O_c || return 1 MULTIPID=$! cp -p /bin/ls $DIR1/d11/f $DIR2/d11/f RC=$? kill -USR1 $MULTIPID wait $MULTIPID || error [ $RC -eq 0 ] && error || true}run_test 11 "execution of file opened for write should return error ===="test_12() { DIR=$DIR DIR2=$DIR2 sh lockorder.sh}run_test 12 "test lock ordering (link, stat, unlink) ==========="test_13() { # bug 2451 - directory coherency rm -rf $DIR1/d13 mkdir $DIR1/d13 || error cd $DIR1/d13 || error ls ( touch $DIR1/d13/f13 ) # needs to be a separate shell ls rm -f $DIR2/d13/f13 || error ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true # need to run it twice ( touch $DIR1/d13/f13 ) # needs to be a separate shell ls rm -f $DIR2/d13/f13 || error ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true}run_test 13 "test directory page revocation ===================="test_14() { mkdir $DIR1/d14 cp -p /bin/ls $DIR1/d14/ls exec 100>> $DIR1/d14/ls $DIR2/d14/ls && error || true exec 100<&-}run_test 14 "execution of file open for write returns -ETXTBSY ="test_14a() { mkdir -p $DIR1/d14 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed" MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1 MULTIOP_PID=$! multiop $DIR2/d14/multiop Oc && error "expected error, got success" kill -USR1 $MULTIOP_PID || return 2 wait $MULTIOP_PID || return 3 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"}run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="test_14b() { # bug 3192, 7040 mkdir -p $DIR1/d14 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed" MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1 MULTIOP_PID=$! truncate $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \ error "expected truncate error, got success" kill -USR1 $MULTIOP_PID || return 2 wait $MULTIOP_PID || return 3 cmp `which multiop` $DIR1/d14/multiop || error "binary changed" rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"}run_test 14b "truncate of executing file returns -ETXTBSY ======"test_14c() { # bug 3430, 7040 mkdir -p $DIR1/d14 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed" MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1 MULTIOP_PID=$! cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success" kill -USR1 $MULTIOP_PID || return 2 wait $MULTIOP_PID || return 3 cmp `which multiop` $DIR1/d14/multiop || error "binary changed" rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"}run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -