-
Notifications
You must be signed in to change notification settings - Fork 4
/
run_test
executable file
·162 lines (148 loc) · 4.22 KB
/
run_test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/sh
# (c) 2006, Steve Grubb <[email protected]>
# (c) 2006, LMH <[email protected]>
#
# This software may be freely redistributed under the terms of the GNU
# public license version 2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1335, USA.
if [ $# -ne 2 ] ; then
echo "Usage: ./run_test <file system type> <pass number>"
exit 1
fi
fs="$1"
i="$2"
if [ `id -u` != 0 ] ; then
echo "You need to be root to run this test suite"
exit 1
fi
dmesg -c >/dev/null 2>&1
trap cleanup 1 2 3 5 15
# Clear ring buff
if [ x"$DIR" = "x" ] ; then
DIR="/media/test"
if [ ! -d $DIR ] ; then
mkdir $DIR
fi
fi
cleanup () {
umount $DIR 2>/dev/null
rmdir $DIR
}
check_results () {
echo "++ Checking results"
if [ "$fs" = "xfs" -o "$fs" = "gfs2" ] ; then
FAULT=`dmesg | grep -Ei 'oops|unable to handle|assert|panic|internal error' | grep -v 'swap header version'`
elif [ "$fs" = "msdos" -o "$fs" = "vfat" ] ; then
FAULT=`dmesg | grep -Ei 'oops|bug|unable to handle|assert|\[<' | grep -v 'swap header version'`
elif [ "$fs" = "ecryptfs" ] ; then
FAULT=`dmesg | grep -Ei 'oops|bug|unable to handle|assert|panic|\[<' | grep -Ev 'swap header version|\[<NULL>\]'`
else
FAULT=`dmesg | grep -Ei 'oops|bug|unable to handle|assert|panic|\[<' | grep -v 'swap header version'`
fi
if [ x"$FAULT" != "x" ] ; then
echo "++ Something found (`pwd`/fs/$fs.$i.img)..."
exit 1
fi
}
###
# Start of real test
###
while [ `dmesg | wc -l` -ne 0 ]
do
# Sometimes messages are still coming through
# so make sure we are empty
dmesg -c >/dev/null 2>&1
done
echo "++ Testing $PWD/fs/$fs.$i.img..."
if [ $fs = "swap" ] ; then
swapon ./cfs/$fs.$i.img
swapoff ./cfs/$fs.$i.img
check_results
if [ $? -ne 0 ] ; then
exit 1
fi
rm -f cfs/$fs.*
sync
exit 0
fi
if [ "$fs" != "ecryptfs" ] ; then
mount ./cfs/$fs.$i.img $DIR -t $fs -o loop >/dev/null
base_mount_ret=$?
else
mount ./cfs/$fs.$i.img $DIR -t ext3 -o loop >/dev/null
base_mount_ret=$?
mount -t $fs $DIR $DIR -o "key=passphrase:passwd=foo,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,verbosity=0,no_sig_cache" >/dev/null
if [ $? -ne 0 ] ; then
echo "Failed to mount ecryptfs overlay"
exit 1
fi
fi
if [ $base_mount_ret -eq 0 ] ; then
# Run this test first
echo "+++ New Tests..."
./fstest $DIR
if [ $? -ne 0 ] ; then
echo "New tests failed aborting"
exit 1
fi
# perform basic operations...
echo "+++ Checking dir..."
ls -Z $DIR >/dev/null 2>&1
if [ $? -ne 0 ] ; then
ls $DIR >/dev/null 2>&1
fi
echo "+++ Making files..."
touch $DIR/file >/dev/null 2>&1
ln -s $DIR/file $DIR/fileb >/dev/null 2>&1
mkdir $DIR/dir1 >/dev/null 2>&1
echo "+++ Checking stat..."
stat $DIR/file >/dev/null 2>&1
stat $DIR/fileb >/dev/null 2>&1
stat $DIR/dir1 >/dev/null 2>&1
echo "+++ Writing to files..."
echo "test" > $DIR/file
cat $DIR/file >/dev/null 2>&1
chcon -u user_u $DIR/file >/dev/null 2>&1
chown nobody,nobody $DIR/COPYING >/dev/null 2>&1
chmod 0600 $DIR/COPYING >/dev/null 2>&1
echo "+++ Reading from files..."
# This tends to hang machines...so commented out for now
# dd if=$DIR/mangle of=/dev/null >/dev/null 2>&1
# cat $DIR/* >/dev/null 2>&1
find $DIR -type f -exec cat {} \; >/dev/null 2>&1
echo "+++ device files..."
rm $DIR/null >/dev/null 2>&1
mknod $DIR/null c 1 3 >/dev/null 2>&1
echo "+++ Writing to dirs..."
cat $DIR/file > $DIR/dir1 2>/dev/null
cp $DIR/file $DIR/dir1 >/dev/null 2>&1
chcon -u user_u $DIR/dir1 >/dev/null 2>&1
echo "+++ Checking unlink..."
rm -rf $DIR/file >/dev/null 2>&1
rm -rf $DIR/fileb >/dev/null 2>&1
rm -rf $DIR/dir1/* >/dev/null 2>&1
rmdir $DIR/dir1 >/dev/null 2>&1
echo "++ unmounting ./cfs/$fs.$i.img"
umount $DIR >/dev/null 2>&1
if [ "$fs" = "ecryptfs" ] ; then
umount $DIR >/dev/null 2>&1
fi
if [ $? -ne 0 ] ; then
echo "Failed to unmount test file system"
exit 1
fi
sync
# NOTE: we do not have an else clause here for mount failing. This sometimes
# happens. We count on check_results to catch any true mount problems. This
# does mean that we could miss some test problems like where a filesystem
# really didn't unmount but umount thinks it did.
fi
check_results
if [ $? -ne 0 ] ; then
exit 1
fi
exit 0