3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
10 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""}
11 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
13 [ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
16 export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
17 export SECURITY=${SECURITY:-"null"}
20 FSTYPE=${FSTYPE:-ext3}
21 NETTYPE=${NETTYPE:-tcp}
23 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
24 CREATETEST=${CREATETEST:-createtest}
26 LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
27 LFIND=${LFIND:-"$LFS find"}
28 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
30 MCREATE=${MCREATE:-mcreate}
31 OPENFILE=${OPENFILE:-openfile}
32 OPENUNLINK=${OPENUNLINK:-openunlink}
33 TOEXCL=${TOEXCL:-toexcl}
34 TRUNCATE=${TRUNCATE:-truncate}
35 MUNLINK=${MUNLINK:-munlink}
36 SOCKETSERVER=${SOCKETSERVER:-socketserver}
37 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
38 IOPENTEST1=${IOPENTEST1:-iopentest1}
39 IOPENTEST2=${IOPENTEST2:-iopentest2}
40 RUNAS=${RUNAS:-"runas"}
44 if [ $UID -ne 0 ]; then
45 echo "Must be run as root"
49 export NAME=${NAME:-local}
55 sh llmountcleanup.sh > /dev/null || exit 20
62 sh llrmount.sh > /dev/null || exit 10
70 lctl mark "$*" 2> /dev/null || true
75 strace -o $TMP/$1.strace -ttt $*
77 log "FINISHED: $*: rc $RC"
82 check_kernel_version() {
83 VERSION_FILE=/proc/fs/lustre/kernel_version
85 [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
86 GOT_VER=`cat $VERSION_FILE`
87 [ $GOT_VER -ge $WANT_VER ] && return 0
88 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
93 if ! cat /proc/mounts | grep -q $DIR; then
96 echo -1 >/proc/sys/portals/debug
98 export TESTNAME=test_$1
99 test_$1 || error "test_$1: exit with rc=$?"
106 build_test_filter() {
110 for E in $EXCEPT $ALWAYS_EXCEPT; do
111 eval EXCEPT_${E}=true
120 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
127 if [ ${!testname}x != x ]; then
132 if [ ${!testname}x != x ]; then
140 if [ ${!testname}x != x ]; then
141 echo "skipping excluded test $1"
144 testname=EXCEPT_$base
145 if [ ${!testname}x != x ]; then
146 echo "skipping excluded test $1 (base $base)"
153 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
157 if [ "$SANITYLOG" ]; then
158 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
168 MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
169 if [ -z "$MOUNT" ]; then
171 MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
172 [ -z "$MOUNT" ] && error "NAME=$NAME not mounted"
176 [ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
179 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
181 OSTCOUNT=`cat /proc/fs/lustre/llite/fs0/lov/numobd`
182 STRIPECOUNT=`cat /proc/fs/lustre/llite/fs0/lov/stripecount`
183 STRIPESIZE=`cat /proc/fs/lustre/llite/fs0/lov/stripesize`
189 $CHECKSTAT -t file $DIR/f || error
191 $CHECKSTAT -a $DIR/f || error
193 run_test 0 "touch .../f ; rm .../f ============================="
211 mdsnum=`mdsdevice|awk ' $3=="mds" {print $1}'`
212 if [ ! -z "$mdsnum" ];then
214 mkdir $DIR/test_0a_dir1
215 touch $DIR/test_0a_file1
216 ln -s $DIR/test_0a_file1 $DIR/test_0a_filelink1
224 mkdir $DIR/test_0a_dir2
225 touch $DIR/test_0a_file2
226 ln -s $DIR/test_0a_file2 $DIR/test_0a_filelink2
227 $CHECKSTAT -t dir -u 500 $DIR/test_0a_dir2 || error
228 $CHECKSTAT -t file -u 500 $DIR/test_0a_file2 || error
229 $CHECKSTAT -t link -u 500 $DIR/test_0a_filelink2 || error
232 root_squash 500:500 $mynid
236 mkdir $DIR/test_0a_dir3
237 touch $DIR/test_0a_file3
238 ln -s $DIR/test_0a_file3 $DIR/test_0a_filelink3
239 $CHECKSTAT -t dir -u root $DIR/test_0a_dir3 || error
240 $CHECKSTAT -t file -u root $DIR/test_0a_file3 || error
241 $CHECKSTAT -t link -u root $DIR/test_0a_filelink3 || error
244 root_squash root:root
248 mkdir $DIR/test_0a_dir4
249 touch $DIR/test_0a_file4
250 ln -s $DIR/test_0a_file4 $DIR/test_0a_filelink4
251 $CHECKSTAT -t dir -u root $DIR/test_0a_dir4 || error
252 $CHECKSTAT -t file -u root $DIR/test_0a_file4 || error
253 $CHECKSTAT -t link -u root $DIR/test_0a_filelink4 || error
259 run_test 1 "test root_squash ============================"
265 setfattr -n trusted.name1 -v value1 $DIR/f2 || error
266 [ "`getfattr -n trusted.name1 $DIR/f2 2> /dev/null | \
267 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
269 setfattr -n user.author1 -v author1 $DIR/f2 || error
270 [ "`getfattr -n user.author1 $DIR/f2 2> /dev/null | \
271 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
274 setfattr -n trusted.name2 -v value2 $DIR/f2 || error
275 setfattr -n trusted.name3 -v value3 $DIR/f2 || error
276 [ `getfattr -d -m "^trusted" $DIR/f2 2> /dev/null | \
277 grep "trusted" | wc -l` -eq 5 ] || error
280 setfattr -n user.author2 -v author2 $DIR/f2 || error
281 setfattr -n user.author3 -v author3 $DIR/f2 || error
282 [ `getfattr -d -m "^user" $DIR/f2 2> /dev/null | \
283 grep "user" | wc -l` -eq 3 ] || error
285 setfattr -x trusted.name1 $DIR/f2 2> /dev/null || error
286 getfattr -d -m trusted $DIR/f2 2> /dev/null | \
287 grep "trusted.name1" && error || true
289 setfattr -x user.author1 $DIR/f2 2> /dev/null || error
290 getfattr -d -m user $DIR/f2 2> /dev/null | \
291 grep "user.author1" && error || true
293 run_test 2 "set/get xattr test (trusted xattr only) ============"
297 $SAVE_PWD/acl/run $SAVE_PWD/acl/$1.test
302 # acl tests are using user "bin" and "daemon", which uid are 1 and 2
303 # in most distributions
304 if [ `using_krb5_sec $SECURITY` == 'y' ] ; then
305 $RUNAS -u 1 ./krb5_refresh_cache.sh || exit 20
306 $RUNAS -u 2 ./krb5_refresh_cache.sh || exit 21
312 run_acl_subtest cp || return 1
313 run_acl_subtest getfacl-noacl || return 2
314 run_acl_subtest misc || return 3
315 run_acl_subtest permissions || return 4
316 run_acl_subtest setfacl || return 5
318 # inheritance test got from HP
319 cp $SAVE_PWD/acl/make-tree . || return 6
320 chmod +x make-tree || return 7
321 run_acl_subtest inheritance || return 8
327 run_test 3 "==============acl test ============="
333 log "cleanup: ======================================================"
334 if [ "`mount | grep ^$NAME`" ]; then
335 rm -rf $DIR/[Rdfs][1-9]*
336 if [ "$I_MOUNTED" = "yes" ]; then
337 sh llmountcleanup.sh || error
341 echo '=========================== finished ==============================='
342 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true