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}
22 RUNTESTS_SRC=${RUNTESTS_SRC:-"/etc /bin"}
23 [ "$COUNT" ] || COUNT=1000
24 [ "$SLOW" = "no" ] && COUNT=100
26 [ "$MCREATE" ] || MCREATE=mcreate
28 [ "$MKDIRMANY" ] || MKDIRMANY="createmany -d"
32 *.xml) export NAME=`echo $1 | sed "s/.xml//"` ;;
38 MOUNTED=$(mounted_lustre_filesystems | head -1)
39 if [ -z "$MOUNTED" ]; then
42 MOUNTED="`mounted_lustre_filesystems`"
43 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
49 OSCTMP=`echo $MOUNT | tr "/" "."`
50 USED=`df | awk "/$OSCTMP/ { print \\$3 }" | tail -n 1`
51 USED=`expr $USED + 16` # Some space for the status file
53 # let's start slowly here...
55 log "touching $MOUNT at `date`"
56 touch $MOUNT || error "can't touch $MOUNT" 2
60 if [ $COUNT -gt 10 -o $COUNT -eq 0 ]; then
61 # this will cause the following cp to trigger bug #620096
62 log "create an empty file $HOSTS"
64 log "copying /etc/hosts to $HOSTS"
65 cp /etc/hosts $HOSTS || error "can't cp /etc/hosts to $HOSTS" 3
66 log "comparing /etc/hosts and $HOSTS"
67 diff -u /etc/hosts $HOSTS || error "$HOSTS different" 4
68 log "renaming $HOSTS to $HOSTS.ren"
69 mv $HOSTS $HOSTS.ren || error "can't rename $HOSTS to $HOSTS.ren" 5
70 log "copying /etc/hosts to $HOSTS again"
71 cp /etc/hosts $HOSTS || error "can't cp /etc/hosts to $HOSTS again" 6
72 log "truncating $HOSTS"
73 > $HOSTS || error "can't truncate $HOSTS" 8
75 rm $HOSTS || error "can't remove $HOSTS" 9
76 cp /etc/hosts $HOSTS.2 || error "can't cp /etc/hosts to $HOSTS.2" 7
77 log "truncating $HOSTS.2 to $TRUNCSIZE bytes"
78 truncate $HOSTS.2 $TRUNCSIZE
82 # let's start slowly here...
84 mkdir $DST || error "can't mkdir $DST" 10
86 # ok, that hopefully worked, so let's do a little more, with files that
87 # haven't changed in the last day (hopefully they don't change during test)
88 FILES=`find $RUNTESTS_SRC -type f -mtime +1 | head -n $COUNT`
89 [ -z "$FILES" ] && error "No unchanged files - is $RUNTESTS_SRC a new dir?"
91 log "copying files from $RUNTESTS_SRC to $DST$RUNTESTS_SRC at `date`"
92 tar cf - $FILES | tar xvf - -C $DST > /dev/null || error "copying $RUNTESTS_SRC" 11
94 log "comparing newly copied files at `date`"
96 [ $V ] && log "verifying $DST/$f"
97 diff -q $f $DST/$f || ERROR=11
100 [ "$ERROR" ] && error "old and new files are different" $ERROR
101 log "finished at `date` ($(($(date +%s) - START)))"
106 log "comparing previously copied files"
108 [ $V ] && log "verifying $DST/$f"
109 diff -q $f $DST/$f || ERROR=22
112 [ "$ERROR" ] && error "old and new files are different on second diff" $ERROR
118 rm -r $V $DST || error "can't remove $DST" 37
120 if [ $COUNT -gt 10 -o $COUNT -eq 0 ]; then
121 log "renaming $HOSTS.ren to $HOSTS"
122 mv $HOSTS.ren $HOSTS || error "can't rename $HOSTS.ren to $HOSTS" 32
123 log "truncating $HOSTS"
124 > $HOSTS || error "can't truncate $HOSTS" 34
125 log "removing $HOSTS"
126 rm $HOSTS || error "can't remove $HOSTS again" 36
127 log "verifying $HOSTS.2 is $TRUNCSIZE bytes"
128 checkstat -s $TRUNCSIZE $HOSTS.2 || \
129 error "$HOSTS.2 isn't $TRUNCSIZE bytes" 37
130 rm $HOSTS.2 || error "can't remove $HOSTS.2" 38
133 # mkdirmany test (bug 589)
134 log "running $MKDIRMANY $MOUNT/base$$ 100"
135 $MKDIRMANY $MOUNT/base$$ 100 || error "mkdirmany failed"
136 log "removing mkdirmany directories"
137 rmdir $MOUNT/base$$* || error "mkdirmany cleanup failed"
141 NOWUSED=`df | awk "/$OSCTMP/ { print \\$3 }" | tail -n 1`
142 if [ `expr $NOWUSED - $USED` -gt 1024 ]; then
143 echo "Space not all freed: now ${NOWUSED}kB, was ${USED}kB." 1>&2
146 if [ "$I_MOUNTED" = "yes" ]; then