3 # Script which does some basic tests to ensure we haven't regressed.
4 # Probably a good idea to run this before doing any checkins.
5 # In the future this can become more fancy, but it's OK for now.
7 LUSTRE=${LUSTRE:-`dirname $0`/..}
9 export PATH=/sbin:/usr/sbin:$SRCDIR:$SRCDIR/../utils:$PATH
11 . $LUSTRE/tests/test-framework.sh
13 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
15 SETUP=${SETUP:-setupall}
16 FORMAT=${FORMAT:-formatall}
17 CLEANUP=${CLEANUP:-stopall}
21 [ $2 ] && RC=$2 || RC=1
33 [ "$COUNT" ] || COUNT=1000
35 [ "$MCREATE" ] || MCREATE=mcreate
37 [ "$MKDIRMANY" ] || MKDIRMANY="createmany -d"
41 *.xml) export NAME=`echo $1 | sed "s/.xml//"` ;;
47 EXISTING_MOUNT=`awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts`
48 if [ -z "$EXISTING_MOUNT" ]; then
51 EXISTING_MOUNT=`awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts`
52 [ -z "$EXISTING_MOUNT" ] && fail "no lustre filesystem mounted" 1
57 OSCTMP=`echo $MOUNT | tr "/" "."`
58 USED=`df | awk "/$OSCTMP/ { print \\$3 }" | tail -n 1`
59 USED=`expr $USED + 16` # Some space for the status file
61 # let's start slowly here...
63 log "touching $MOUNT at `date`"
64 touch $MOUNT || fail "can't touch $MOUNT" 2
67 if [ $COUNT -gt 10 -o $COUNT -eq 0 ]; then
68 # this will cause the following cp to trigger bug #620096
69 log "create an empty file $HOSTS"
71 log "copying /etc/hosts to $HOSTS"
72 cp /etc/hosts $HOSTS || fail "can't cp /etc/hosts to $HOSTS" 3
73 log "comparing /etc/hosts and $HOSTS"
74 diff -u /etc/hosts $HOSTS || fail "$HOSTS different" 4
75 log "renaming $HOSTS to $HOSTS.ren"
76 mv $HOSTS $HOSTS.ren || fail "can't rename $HOSTS to $HOSTS.ren" 5
77 log "copying /etc/hosts to $HOSTS again"
78 cp /etc/hosts $HOSTS || fail "can't cp /etc/hosts to $HOSTS again" 6
79 log "truncating $HOSTS"
80 > $HOSTS || fail "can't truncate $HOSTS" 8
82 rm $HOSTS || fail "can't remove $HOSTS" 9
86 # let's start slowly here...
88 mkdir $DST || fail "can't mkdir $DST" 10
90 # ok, that hopefully worked, so let's do a little more, with files that
91 # haven't changed in the last day (hopefully they don't change during test)
92 FILES=`find $SRC -type f -mtime +1 -ctime +1 | head -n $COUNT`
93 log "copying files from $SRC to $DST$SRC at `date`"
94 tar cf - $FILES | tar xvf - -C $DST > /dev/null || fail "copying $SRC" 11
96 log "comparing newly copied files at `date`"
98 [ $V ] && log "verifying $DST/$f"
99 diff -q $f $DST/$f || ERROR=11
102 [ "$ERROR" ] && fail "old and new files are different" $ERROR
103 log "finished at `date` ($(($(date +%s) - START)))"
108 log "comparing previously copied files"
110 [ $V ] && log "verifying $DST/$f"
111 diff -q $f $DST/$f || ERROR=22
114 [ "$ERROR" ] && fail "old and new files are different on second diff" $ERROR
120 rm -r $V $DST || fail "can't remove $DST" 37
122 if [ $COUNT -gt 10 -o $COUNT -eq 0 ]; then
123 log "renaming $HOSTS.ren to $HOSTS"
124 mv $HOSTS.ren $HOSTS || fail "can't rename $HOSTS.ren to $HOSTS" 32
125 log "truncating $HOSTS"
126 > $HOSTS || fail "can't truncate $HOSTS" 34
127 log "removing $HOSTS"
128 rm $HOSTS || fail "can't remove $HOSTS again" 36
131 # mkdirmany test (bug 589)
132 log "running $MKDIRMANY $MOUNT/base$$ 100"
133 $MKDIRMANY $MOUNT/base$$ 100 || fail "mkdirmany failed"
134 log "removing mkdirmany directories"
135 rmdir $MOUNT/base$$* || fail "mkdirmany cleanup failed"
139 NOWUSED=`df | awk "/$OSCTMP/ { print \\$3 }" | tail -n 1`
140 if [ `expr $NOWUSED - $USED` -gt 1024 ]; then
141 echo "Space not all freed: now ${NOWUSED}kB, was ${USED}kB." 1>&2
144 if [ "$I_MOUNTED" = "yes" ]; then
145 sync && sleep 2 && sync # wait for delete thread