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}
18 RUNTESTS_SRC=${RUNTESTS_SRC:-"/etc /bin"}
19 [ "$COUNT" ] || COUNT=1000
20 [ "$SLOW" = "no" ] && COUNT=100
22 [ "$MCREATE" ] || MCREATE=mcreate
24 [ "$MKDIRMANY" ] || MKDIRMANY="createmany -d"
26 check_and_setup_lustre
28 OSCTMP=`echo $MOUNT | tr "/" "."`
29 USED=`df | awk "/$OSCTMP/ { print \\$3 }" | tail -n 1`
30 USED=`expr $USED + 16` # Some space for the status file
32 # let's start slowly here...
34 log "touching $MOUNT at `date`"
35 touch $MOUNT || error "can't touch $MOUNT" 2
39 if [ $COUNT -gt 10 -o $COUNT -eq 0 ]; then
40 # this will cause the following cp to trigger bug #620096
41 log "create an empty file $HOSTS"
43 log "copying /etc/hosts to $HOSTS"
44 cp /etc/hosts $HOSTS || error "can't cp /etc/hosts to $HOSTS" 3
45 log "comparing /etc/hosts and $HOSTS"
46 diff -u /etc/hosts $HOSTS || error "$HOSTS different" 4
47 log "renaming $HOSTS to $HOSTS.ren"
48 mv $HOSTS $HOSTS.ren || error "can't rename $HOSTS to $HOSTS.ren" 5
49 log "copying /etc/hosts to $HOSTS again"
50 cp /etc/hosts $HOSTS || error "can't cp /etc/hosts to $HOSTS again" 6
51 log "truncating $HOSTS"
52 > $HOSTS || error "can't truncate $HOSTS" 8
54 rm $HOSTS || error "can't remove $HOSTS" 9
55 cp /etc/hosts $HOSTS.2 || error "can't cp /etc/hosts to $HOSTS.2" 7
56 log "truncating $HOSTS.2 to $TRUNCSIZE bytes"
57 truncate $HOSTS.2 $TRUNCSIZE
61 # let's start slowly here...
63 mkdir $DST || error "can't mkdir $DST" 10
65 # ok, that hopefully worked, so let's do a little more, with files that
66 # haven't changed in the last day (hopefully they don't change during test)
67 FILES=`find $RUNTESTS_SRC -type f -mtime +1 | head -n $COUNT`
68 [ -z "$FILES" ] && error "No unchanged files - is $RUNTESTS_SRC a new dir?"
70 log "copying files from $RUNTESTS_SRC to $DST$RUNTESTS_SRC at `date`"
71 tar cf - $FILES | tar xvf - -C $DST > /dev/null || error "copying $RUNTESTS_SRC" 11
73 log "comparing newly copied files at `date`"
75 [ $V ] && log "verifying $DST/$f"
76 diff -q $f $DST/$f || ERROR=11
79 [ "$ERROR" ] && error "old and new files are different" $ERROR
80 log "finished at `date` ($(($(date +%s) - START)))"
85 log "comparing previously copied files"
87 [ $V ] && log "verifying $DST/$f"
88 diff -q $f $DST/$f || ERROR=22
91 [ "$ERROR" ] && error "old and new files are different on second diff" $ERROR
97 rm -r $V $DST || error "can't remove $DST" 37
99 if [ $COUNT -gt 10 -o $COUNT -eq 0 ]; then
100 log "renaming $HOSTS.ren to $HOSTS"
101 mv $HOSTS.ren $HOSTS || error "can't rename $HOSTS.ren to $HOSTS" 32
102 log "truncating $HOSTS"
103 > $HOSTS || error "can't truncate $HOSTS" 34
104 log "removing $HOSTS"
105 rm $HOSTS || error "can't remove $HOSTS again" 36
106 log "verifying $HOSTS.2 is $TRUNCSIZE bytes"
107 checkstat -s $TRUNCSIZE $HOSTS.2 || \
108 error "$HOSTS.2 isn't $TRUNCSIZE bytes" 37
109 rm $HOSTS.2 || error "can't remove $HOSTS.2" 38
112 # mkdirmany test (bug 589)
113 log "running $MKDIRMANY $MOUNT/base$$ 100"
114 $MKDIRMANY $MOUNT/base$$ 100 || error "mkdirmany failed"
115 log "removing mkdirmany directories"
116 rmdir $MOUNT/base$$* || error "mkdirmany cleanup failed"
120 NOWUSED=`df | awk "/$OSCTMP/ { print \\$3 }" | tail -n 1`
121 if [ `expr $NOWUSED - $USED` -gt 1024 ]; then
122 echo "Space not all freed: now ${NOWUSED}kB, was ${USED}kB." 1>&2
125 check_and_cleanup_lustre