xfstests: randholes: encapsulate direct I/O setup code
[xfstests-dev.git] / 013
1 #! /bin/bash
2 # FS QA Test No. 013
3 #
4 # fsstress
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24 # creator
25 owner=dxm@sgi.com
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=0        # success is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37     cd /
38     # we might get here with a RO FS
39     mount -o remount,rw $TEST_DEV >/dev/null 2>&1
40     # now remove fsstress directory.
41     # N.B. rm(1) on IRIX can find problems when building up a long pathname
42     # such that what it has is greater the 1024 chars and will
43     # stop and complain - so get rid of complaint
44     # Ref. pv#935754
45     rm -rf $testdir/fsstress.$$.* 2>&1 | grep -v 'Path too long'
46     _cleanup_testdir
47 }
48
49 _filesize()
50 {
51     ls -l $1 | $AWK_PROG '{print "    filesize = " $5}'
52 }
53
54 # get standard environment, filters and checks
55 . ./common.rc
56 . ./common.filter
57
58 _do_test()
59 {
60     _n="$1"
61     _param="$2"
62     _count="$3"
63
64     out=$testdir/fsstress.$$.$_n
65     rm -rf $out
66     if ! mkdir $out
67     then
68         echo "    failed to mkdir $out"
69         status=1
70         exit
71     fi
72
73     echo ""
74     echo "-----------------------------------------------"
75     echo "fsstress.$_n : $_param"
76     echo "-----------------------------------------------"
77     # -m limits number of users/groups so check doesn't fail (malloc) later
78     dbgoutfile=$seq.full
79     if ! $FSSTRESS_PROG $_param $FSSTRESS_AVOID -v -m 8 -n $_count -d $out >>$dbgoutfile 2>&1
80     then
81         echo "    fsstress (count=$_count) returned $? - see $seq.full"
82         echo "--------------------------------------"       >>$here/$seq.full
83         echo "$_n - output from fsstress:"                  >>$here/$seq.full
84         echo "--------------------------------------"       >>$here/$seq.full
85         echo "<NOT LOGGED>"                                 >>$here/$seq.full
86         #cat $tmp.out                                       >>$here/$seq.full
87         status=1
88     fi
89
90     _check_test_fs
91 }
92
93
94 # real QA test starts here
95 _supported_fs generic
96 _supported_os IRIX Linux
97
98 _setup_testdir
99
100 rm -f $here/$seq.full
101 echo "brevity is wit..."
102
103 count=1000
104 procs=20
105
106 _check_test_fs
107
108 # the default
109
110 _do_test 1 "-r" $count
111
112 # and the default with multiprocess
113
114 _do_test 2 "-p $procs -r" $count
115
116 # from Glen's notes
117
118 _do_test 3 "-p 4 -z -f rmdir=10 -f link=10 -f creat=10 -f mkdir=10 -f rename=30 -f stat=30 -f unlink=30 -f truncate=20" $count
119
120 # if all ok by here then probably don't need $seq.full
121 rm -f $seq.full
122
123 exit
124
125 # Test with error injection:
126 #
127 # (error injection)
128 # fsstress -n 1000 -d $scratch -p 4 -z -f rmdir=10 -f link=10 -f creat=10 \
129 #          -f mkdir=10 -f rename=30 -f stat=30 -f unlink=30 -f truncate=20 \
130 #          -e 1
131 #
132 # Error values 1 - 6 test IFLUSH
133 #         1 - corrupt buffer being flushed to di_core.di_magic
134 #         2 - corrupt inode being flushed i_d.di_magic
135 #         3 - corrupt S_IFREG format check
136 #         4 - corrupt S_IFDIR format check
137 #         5 - corrupt i_d.di_nextents
138 #         6 - corrupt i_d.di_forkoff > sb_inodesize