populate: add _require_populate_commands to check for tools
[xfstests-dev.git] / tests / xfs / 297
1 #! /bin/bash
2 # FS QA Test No. 297
3 #
4 # Test freeze/unfreeze file system randomly under fsstress
5 # Regression test for commit:
6 # 437a255 xfs: fix direct IO nested transaction deadlock.
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37     cd /
38     rm -f $tmp.*
39 }
40
41 # get standard environment, filters and checks
42 . ./common/rc
43 . ./common/filter
44
45 # real QA test starts here
46 _supported_fs xfs
47 _supported_os IRIX Linux
48
49 _require_scratch
50 _require_freeze
51 _require_command "$KILLALL_PROG" killall
52
53 rm -f $seqres.full
54 _scratch_mkfs_xfs -d agcount=16,su=256k,sw=12 -l su=256k,size=5120b >/dev/null 2>&1
55 _scratch_mount >/dev/null 2>&1
56
57 STRESS_DIR="$SCRATCH_MNT/testdir"
58 mkdir -p $STRESS_DIR
59
60 $FSSTRESS_PROG -d $STRESS_DIR -n 100 -p 1000 $FSSTRESS_AVOID >/dev/null 2>&1 &
61
62 # Freeze/unfreeze file system randomly
63 echo "Start freeze/unfreeze randomly" | tee -a $seqres.full
64 LOOP=10
65 while [ $LOOP -gt 0 ];do
66         TIMEOUT=`expr $RANDOM % 5`
67         sleep $TIMEOUT
68         echo "* Freeze file system after sleeping $TIMEOUT seconds" >>$seqres.full
69         xfs_freeze -f $SCRATCH_MNT
70         if [ $? -ne 0 ];then
71                 echo " - Error: freeze filesystem failed" | tee -a $seqres.full
72         fi
73         TIMEOUT=`expr $RANDOM % 3`
74         sleep $TIMEOUT
75         echo "* Unfreeze file system after sleeping $TIMEOUT seconds" >>$seqres.full
76         xfs_freeze -u $SCRATCH_MNT
77         if [ $? -ne 0 ];then
78                 echo " - Error: unfreeze filesystem failed" | tee -a $seqres.full
79         fi
80         let LOOP=$LOOP-1
81 done
82 echo "Test done" | tee -a $seqres.full
83 $KILLALL_PROG -q $FSSTRESS_PROG
84 wait
85
86 status=0
87 exit