3 # Script which does some basic tests to ensure we haven't regressed.
5 LUSTRE=${LUSTRE:-$(dirname $0)/..}
6 . $LUSTRE/tests/test-framework.sh
10 RUNTESTS_SRC=${RUNTESTS_SRC:-"/etc /bin"}
11 [ "$COUNT" ] || COUNT=10000
12 [ "$SLOW" = "no" ] && COUNT=1000
14 [ "$MKDIRMANY" ] || MKDIRMANY="createmany -d"
15 [ "$RMDIRMANY" ] || RMDIRMANY="unlinkmany -d"
17 check_and_setup_lustre
20 sleep 5 # let MDS refresh aggregated statfs
21 # Include some extra space for the status file
22 local dfused=$(df -P $DIR | awk '{ print $3 }' | tail -n 1)
25 # let's start slowly here...
26 local stime=$(date +%s)
27 log "touching $DIR at $(date) (@$stime)"
28 touch $DIR || error "can't touch $DIR"
29 local hfile=$DIR/hosts.$$
31 if [ $COUNT -gt 10 -o $COUNT -eq 0 ]; then
32 # this will cause the following cp to trigger bug #620096
33 log "create an empty file $hfile"
35 log "copying /etc/hosts to $hfile"
36 cp /etc/hosts $hfile || error "can't cp /etc/hosts to $hfile"
37 log "comparing /etc/hosts and $hfile"
38 diff -u /etc/hosts $hfile || error "$hfile different"
39 log "renaming $hfile to $hfile.ren"
40 mv $hfile $hfile.ren ||
41 error "can't rename $hfile to $hfile.ren"
42 log "copying /etc/hosts to $hfile again"
43 cp /etc/hosts $hfile ||
44 error "can't cp /etc/hosts to $hfile again"
45 log "truncating $hfile"
46 > $hfile || error "can't truncate $hfile"
48 rm $hfile || error "can't remove $hfile"
49 log "copying /etc/hosts to $hfile.2"
50 cp /etc/hosts $hfile.2 ||
51 error "can't cp /etc/hosts to $hfile.2"
52 log "truncating $hfile.2 to $truncsize bytes"
53 $TRUNCATE $hfile.2 $truncsize || error "can't truncate $hfile.2"
54 checkstat -s $truncsize $hfile.2 ||
55 error "$hfile.2 isn't $truncsize bytes"
60 test_mkdir -p $dst || error "can't mkdir $dst"
62 # let's do a little more, with files that haven't changed in the
63 # last day (hopefully they don't change during test)
64 local findfiles=$TMP/runtests.files
66 # use "NUL" instead of newline as filename terminator, bug 19702
67 find $RUNTESTS_SRC -type f -mtime +1 | head -n $COUNT | \
68 tr '\n' '\0' > $findfiles
69 [ -s "$findfiles" ] ||
70 error "$RUNTESTS_SRC contains only files modifed less than " \
72 stack_trap "rm -f $findfiles"
73 COUNT=$(xargs -0 -n 1 echo < $findfiles | wc -l)
75 log "copying $COUNT files from $RUNTESTS_SRC to $dst$RUNTESTS_SRC " \
77 tar cf - --null --files-from $findfiles | \
78 tar xvf - -C $dst > /dev/null || error "copying $RUNTESTS_SRC"
80 log "comparing $COUNT newly copied files at $(date)"
82 cat $findfiles | tr "\0" "\n" | ( rc=0; while read f; do
83 diff -q "$f" "$dst/$f" || rc=18
85 [ "$rc" = 0 ] || error_exit "old and new files are different: rc=$rc" )
87 log "finished at $(date) ($(($(date +%s) - stime)))"
89 stopall || error "stopall failed"
90 setupall || error "setupall failed"
92 log "comparing $COUNT previously copied files"
93 cat $findfiles | tr "\0" "\n" | ( rc=0; while read f; do
94 diff -q "$f" "$dst/$f" || rc=22
96 [ "$rc" = 0 ] || error_exit "old and new files are different: rc=$rc" )
98 stopall || error "stopall failed (2)"
99 setupall || error "setupall failed (2)"
102 rm -r $dst || error "can't remove $dst"
104 if [ $COUNT -gt 10 -o $COUNT -eq 0 ]; then
105 log "renaming $hfile.ren to $hfile"
106 mv $hfile.ren $hfile ||
107 error "can't rename $hfile.ren to $hfile"
108 log "truncating $hfile"
109 > $hfile || error "can't truncate $hfile"
110 log "removing $hfile"
111 rm $hfile || error "can't remove $hfile again"
112 log "verifying $hfile.2 is $truncsize bytes"
113 checkstat -s $truncsize $hfile.2 ||
114 error "$hfile.2 isn't $truncsize bytes"
115 rm $hfile.2 || error "can't remove $hfile.2"
118 # mkdirmany test (bug 589)
120 log "running $MKDIRMANY $dst/d 100"
121 $MKDIRMANY $dst/d 100 || error "$MKDIRMANY failed"
122 log "running $RMDIRMANY $dst/d 100"
123 $RMDIRMANY $dst/d 100 || error "$RMDIRMANY cleanup failed"
127 wait_delete_completed
128 sleep 5 # let MDS refresh aggregated statfs
129 local nowdfused=$(($(df -P $DIR | awk '{ print $3 }' | tail -n 1)))
130 if [ $(expr $nowdfused - $dfused) -gt $(fs_log_size) ]; then
131 error "Space not all freed: now ${nowdfused}kB, was ${dfused}kB"
133 log "Space was freed: now ${nowdfused}kB, was ${dfused}kB."
136 run_test 1 "All Runtests"
139 check_and_cleanup_lustre