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 export NAME=${NAME:-local}
13 . $LUSTRE/tests/test-framework.sh
15 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
17 SETUP=${SETUP:-setupall}
18 FORMAT=${FORMAT:-formatall}
19 CLEANUP=${CLEANUP:-stopall}
23 [ $2 ] && RC=$2 || RC=1
29 [ "$COUNT" ] || COUNT=1000
31 [ "$MCREATE" ] || MCREATE=mcreate
33 [ "$MKDIRMANY" ] || MKDIRMANY="createmany -d"
37 *.xml) export NAME=`echo $1 | sed "s/.xml//"` ;;
43 mounted_lustre_filesystems() {
44 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
47 MOUNTED="`mounted_lustre_filesystems`"
48 if [ -z "$MOUNTED" ]; then
51 MOUNTED="`mounted_lustre_filesystems`"
52 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
58 OSCTMP=`echo $MOUNT | tr "/" "."`
59 USED=`df | awk "/$OSCTMP/ { print \\$3 }" | tail -n 1`
60 USED=`expr $USED + 16` # Some space for the status file
62 # let's start slowly here...
64 log "touching $MOUNT at `date`"
65 touch $MOUNT || fail "can't touch $MOUNT" 2
69 if [ $COUNT -gt 10 -o $COUNT -eq 0 ]; then
70 # this will cause the following cp to trigger bug #620096
71 log "create an empty file $HOSTS"
73 log "copying /etc/hosts to $HOSTS"
74 cp /etc/hosts $HOSTS || fail "can't cp /etc/hosts to $HOSTS" 3
75 log "comparing /etc/hosts and $HOSTS"
76 diff -u /etc/hosts $HOSTS || fail "$HOSTS different" 4
77 log "renaming $HOSTS to $HOSTS.ren"
78 mv $HOSTS $HOSTS.ren || fail "can't rename $HOSTS to $HOSTS.ren" 5
79 log "copying /etc/hosts to $HOSTS again"
80 cp /etc/hosts $HOSTS || fail "can't cp /etc/hosts to $HOSTS again" 6
81 log "truncating $HOSTS"
82 > $HOSTS || fail "can't truncate $HOSTS" 8
84 rm $HOSTS || fail "can't remove $HOSTS" 9
85 cp /etc/hosts $HOSTS.2 || fail "can't cp /etc/hosts to $HOSTS.2" 7
86 log "truncating $HOSTS.2 to $TRUNCSIZE bytes"
87 truncate $HOSTS.2 $TRUNCSIZE
91 # let's start slowly here...
93 mkdir $DST || fail "can't mkdir $DST" 10
95 # ok, that hopefully worked, so let's do a little more, with files that
96 # haven't changed in the last day (hopefully they don't change during test)
97 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
98 [ -z "$FILES" ] && fail "No unchanged files - is $SRC a new dir?"
100 log "copying files from $SRC to $DST$SRC at `date`"
101 tar cf - $FILES | tar xvf - -C $DST > /dev/null || fail "copying $SRC" 11
103 log "comparing newly copied files at `date`"
105 [ $V ] && log "verifying $DST/$f"
106 diff -q $f $DST/$f || ERROR=11
109 [ "$ERROR" ] && fail "old and new files are different" $ERROR
110 log "finished at `date` ($(($(date +%s) - START)))"
115 log "comparing previously copied files"
117 [ $V ] && log "verifying $DST/$f"
118 diff -q $f $DST/$f || ERROR=22
121 [ "$ERROR" ] && fail "old and new files are different on second diff" $ERROR
127 rm -r $V $DST || fail "can't remove $DST" 37
129 if [ $COUNT -gt 10 -o $COUNT -eq 0 ]; then
130 log "renaming $HOSTS.ren to $HOSTS"
131 mv $HOSTS.ren $HOSTS || fail "can't rename $HOSTS.ren to $HOSTS" 32
132 log "truncating $HOSTS"
133 > $HOSTS || fail "can't truncate $HOSTS" 34
134 log "removing $HOSTS"
135 rm $HOSTS || fail "can't remove $HOSTS again" 36
136 log "verifying $HOSTS.2 is $TRUNCSIZE bytes"
137 checkstat -s $TRUNCSIZE $HOSTS.2 || \
138 fail "$HOSTS.2 isn't $TRUNCSIZE bytes" 37
139 rm $HOSTS.2 || fail "can't remove $HOSTS.2" 38
142 # mkdirmany test (bug 589)
143 log "running $MKDIRMANY $MOUNT/base$$ 100"
144 $MKDIRMANY $MOUNT/base$$ 100 || fail "mkdirmany failed"
145 log "removing mkdirmany directories"
146 rmdir $MOUNT/base$$* || fail "mkdirmany cleanup failed"
150 NOWUSED=`df | awk "/$OSCTMP/ { print \\$3 }" | tail -n 1`
151 if [ `expr $NOWUSED - $USED` -gt 1024 ]; then
152 echo "Space not all freed: now ${NOWUSED}kB, was ${USED}kB." 1>&2
155 if [ "$I_MOUNTED" = "yes" ]; then