xfstests: introduce a common directory
[xfstests-dev.git] / tests / generic / 270
1 #! /bin/bash
2 # FSQA Test No. 270
3 #
4 # Run fsstress and ENSPC hitters in parallel, check quota and 
5 # fs consistency an the end
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
36
37 # get standard environment, filters and checks
38 . ./common/rc
39 . ./common/filter
40 . ./common/quota
41
42 # Disable all sync operations to get higher load
43 FSSTRESS_AVOID="$FSSTRESS_AVOID -ffsync=0 -fsync=0 -ffdatasync=0"
44 _workout()
45 {
46         echo ""
47         echo "Run fsstress"
48         echo ""
49         num_iterations=10
50         enospc_time=2
51         out=$SCRATCH_MNT/fsstress.$$
52         args=`_scale_fsstress_args -p128 -n999999999 -f setattr=1 $FSSTRESS_AVOID -d $out`
53         echo "fsstress $args" >> $here/$seqres.full
54         # Grant chown capability 
55         cp $FSSTRESS_PROG  $tmp.fsstress.bin
56         if [ "`whereis setcap`" == "setcap:" ]; then
57             _notrun "setcap not installed."
58         fi
59         setcap cap_chown=epi  $tmp.fsstress.bin
60
61         (su $qa_user -c "$tmp.fsstress.bin $args" &) > /dev/null 2>&1
62         pid=$!
63
64         echo "Run dd writers in parallel"
65         for ((i=0; i < num_iterations; i++))
66         do
67                 # File will be opened with O_TRUNC each time
68                 su $qa_user -c "dd if=/dev/zero \
69                         of=$SCRATCH_MNT/SPACE_CONSUMER bs=1M " \
70                         >> $here/$seqres.full 2>&1
71                 sleep $enospc_time
72         done
73
74         killall $tmp.fsstress.bin
75         wait $pid
76 }
77
78 # real QA test starts here
79 _supported_fs generic
80 _supported_os Linux
81 _require_quota
82 _require_user
83 _need_to_be_root
84 _require_scratch
85
86 _scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
87 _scratch_mount "-o usrquota,grpquota"
88 chmod 777 $SCRATCH_MNT
89 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
90 quotaon -u -g $SCRATCH_MNT 2>/dev/null
91
92 if ! _workout; then
93         _scratch_unmount 2>/dev/null
94         exit
95 fi
96
97 if ! _check_quota_usage; then
98         _scratch_unmount 2>/dev/null
99         status=1
100         exit
101 fi
102
103 echo Comparing filesystem consistency
104 if ! _scratch_unmount; then
105         echo "failed to umount"
106         status=1
107         exit
108 fi
109 _check_scratch_fs
110 status=$?
111 exit