Whamcloud - gitweb
Fixup readme a bit to reflect reality.
[fs/lustre-release.git] / lustre / tests / runtests
1 #!/bin/sh
2 #
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.
6
7 SRCDIR="`dirname $0`"
8 fail() { 
9         echo "ERROR: $1" 1>&2
10         [ $2 ] && RC=$2 || RC=1
11         exit $RC
12 }
13
14 export PATH=/sbin:/usr/sbin:$SRCDIR:$PATH
15
16 ERROR=
17 SRC=/etc
18 [ "$COUNT" ] || COUNT=1000
19
20 [ "$LCONF" ] || LCONF=$SRCDIR/../utils/lconf
21
22 OSCMT="`mount | awk '/ lustre_lite / { print $3 }' | tail -1`"
23 if [ -z "$OSCMT" ]; then
24         [ -z "$*" ] && fail "usage: $0 [--reformat] <conf>.xml" 1
25         $LCONF $@ || exit 1
26         trap "$LCONF --cleanup $@" 0
27         OSCMT="`mount | awk '/ lustre_lite / { print $3 }'`"
28         [ -z "$OSCMT" ] && fail "no lustre filesystem mounted" 1
29 fi
30
31 # let's start slowly here...
32 echo "touching $OSCMT"
33 touch $OSCMT || fail "can't touch $OSCMT" 2
34 HOSTS=$OSCMT/hosts.$$
35 echo "copying /etc/hosts to $HOSTS"
36 cp /etc/hosts $HOSTS || fail "can't cp /etc/hosts to $HOSTS" 3
37 echo "comparing /etc/hosts and $HOSTS"
38 diff -u /etc/hosts $HOSTS || fail "$HOSTS different" 4
39 #echo "renaming $HOSTS to $HOSTS.ren"
40 #mv $HOSTS $HOSTS.ren || fail "can't rename $HOSTS to $HOSTS.ren" 5
41 #echo "copying /etc/hosts to $HOSTS again"
42 #cp /etc/hosts $HOSTS || fail "can't cp /etc/hosts to $HOSTS again" 6
43 #echo "truncating $HOSTS"
44 #> $HOSTS || fail "can't truncate $HOSTS" 8
45 #echo "removing $HOSTS"
46 #rm $HOSTS || fail "can't remove $HOSTS" 9
47
48 DST=$OSCMT/runtest.$$
49 # let's start slowly here...
50 echo "creating $DST"
51 mkdir $DST || fail "can't mkdir $DST" 10
52
53 # ok, that hopefully worked, so let's do a little more
54 FILES=`find $SRC -type f | head -$COUNT`
55 echo "copying files from $SRC to $DST$SRC"
56 tar cf - $FILES | tar xvf - -C $DST || fail "copying $SRC" 11
57
58 echo "comparing newly copied files"
59 for f in $FILES; do
60         diff -q $f $DST/$f || ERROR=11
61 done
62
63 [ "$ERROR" ] && fail "old and new files are different" $ERROR
64
65 $LCONF --cleanup $@ || exit 19
66 $LCONF $@ || exit 20
67
68 echo "comparing previously copied files"
69 for f in $FILES; do
70         diff -q $f $DST/$f || ERROR=22
71 done
72
73 [ "$ERROR" ] && fail "old and new files are different on second diff" $ERROR
74
75 $LCONF --cleanup $@ || exit 29
76 $LCONF $@ || exit 30
77
78 #echo "renaming $HOSTS.ren to $HOSTS"
79 #mv $HOSTS.ren $HOSTS || fail "can't rename $HOSTS.ren to $HOSTS" 32
80 echo "truncating $HOSTS"
81 > $HOSTS || fail "can't truncate $HOSTS" 34
82 echo "removing $HOSTS"
83 rm $HOSTS || fail "can't remove $HOSTS again" 36
84 echo "removing $DST"
85 rm -r $DST || fail "can't remove $DST" 37
86
87 $LCONF --cleanup $@ || exit 29