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
68 if [ $COUNT -gt 10 -o $COUNT -eq 0 ]; then
69 # this will cause the following cp to trigger bug #620096
70 log "create an empty file $HOSTS"
72 log "copying /etc/hosts to $HOSTS"
73 cp /etc/hosts $HOSTS || fail "can't cp /etc/hosts to $HOSTS" 3
74 log "comparing /etc/hosts and $HOSTS"
75 diff -u /etc/hosts $HOSTS || fail "$HOSTS different" 4
76 log "renaming $HOSTS to $HOSTS.ren"
77 mv $HOSTS $HOSTS.ren || fail "can't rename $HOSTS to $HOSTS.ren" 5
78 log "copying /etc/hosts to $HOSTS again"
79 cp /etc/hosts $HOSTS || fail "can't cp /etc/hosts to $HOSTS again" 6
80 log "truncating $HOSTS"
81 > $HOSTS || fail "can't truncate $HOSTS" 8
83 rm $HOSTS || fail "can't remove $HOSTS" 9
84 cp /etc/hosts $HOSTS.2 || fail "can't cp /etc/hosts to $HOSTS.2" 7
85 log "truncating $HOSTS.2 to $TRUNCSIZE bytes"
86 truncate $HOSTS.2 $TRUNCSIZE
90 # let's start slowly here...
92 mkdir $DST || fail "can't mkdir $DST" 10
94 # ok, that hopefully worked, so let's do a little more, with files that
95 # haven't changed in the last day (hopefully they don't change during test)
96 FILES=`find $SRC -type f -mtime +1 -ctime +1 | head -n $COUNT`
97 log "copying files from $SRC to $DST$SRC at `date`"
98 tar cf - $FILES | tar xvf - -C $DST > /dev/null || fail "copying $SRC" 11
100 log "comparing newly copied files at `date`"
102 [ $V ] && log "verifying $DST/$f"
103 diff -q $f $DST/$f || ERROR=11
106 [ "$ERROR" ] && fail "old and new files are different" $ERROR
107 log "finished at `date` ($(($(date +%s) - START)))"
112 log "comparing previously copied files"
114 [ $V ] && log "verifying $DST/$f"
115 diff -q $f $DST/$f || ERROR=22
118 [ "$ERROR" ] && fail "old and new files are different on second diff" $ERROR
124 rm -r $V $DST || fail "can't remove $DST" 37
126 if [ $COUNT -gt 10 -o $COUNT -eq 0 ]; then
127 log "renaming $HOSTS.ren to $HOSTS"
128 mv $HOSTS.ren $HOSTS || fail "can't rename $HOSTS.ren to $HOSTS" 32
129 log "truncating $HOSTS"
130 > $HOSTS || fail "can't truncate $HOSTS" 34
131 log "removing $HOSTS"
132 rm $HOSTS || fail "can't remove $HOSTS again" 36
133 log "verifying $HOSTS.2 is $TRUNCSIZE bytes"
134 checkstat -s $TRUNCSIZE $HOSTS.2 || \
135 fail "$HOSTS.2 isn't $TRUNCSIZE bytes" 37
136 rm $HOSTS.2 || fail "can't remove $HOSTS.2" 38
139 # mkdirmany test (bug 589)
140 log "running $MKDIRMANY $MOUNT/base$$ 100"
141 $MKDIRMANY $MOUNT/base$$ 100 || fail "mkdirmany failed"
142 log "removing mkdirmany directories"
143 rmdir $MOUNT/base$$* || fail "mkdirmany cleanup failed"
147 NOWUSED=`df | awk "/$OSCTMP/ { print \\$3 }" | tail -n 1`
148 if [ `expr $NOWUSED - $USED` -gt 1024 ]; then
149 echo "Space not all freed: now ${NOWUSED}kB, was ${USED}kB." 1>&2
152 if [ "$I_MOUNTED" = "yes" ]; then
153 sync && sleep 2 && sync # wait for delete thread