fstests: Add path $here before src/<file>
[xfstests-dev.git] / tests / generic / 068
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. 068
6 #
7 # Test case to reproduce xfs_freeze hang under filsystem load.
8 # The fail case for this test is a hang on an xfs_freeze.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=0        # success is the default!
17
18 ITERATIONS=10
19
20 _cleanup()
21 {
22     cd /
23
24     trap 0 1 2 3 15
25     exit $status
26 }
27
28 trap "_cleanup" 0 1 2 3 15
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/filter
33
34 # real QA test starts here
35 _supported_fs generic
36 _supported_os Linux
37
38 _require_scratch
39 _require_freeze
40
41 echo "*** init FS"
42
43 rm -f $seqres.full
44 _scratch_unmount >/dev/null 2>&1
45 echo "*** MKFS ***"                         >>$seqres.full
46 echo ""                                     >>$seqres.full
47 _scratch_mkfs                               >>$seqres.full 2>&1 \
48     || _fail "mkfs failed"
49 _scratch_mount
50
51 touch $tmp.running
52
53 # start fsstress loop in a background block
54 {
55     STRESS_DIR="$SCRATCH_MNT/fsstress_test_dir"
56     mkdir "$STRESS_DIR"
57
58     procs=2
59     nops=200
60     while [ -f "$tmp.running" ]
61       do
62       # We do both read & write IO - not only is this more realistic,
63       # but it also potentially tests atime updates
64       FSSTRESS_ARGS=`_scale_fsstress_args -d $STRESS_DIR -p $procs -n $nops $FSSTRESS_AVOID`
65       $FSSTRESS_PROG $FSSTRESS_ARGS > /dev/null 2>&1
66     done
67
68     rm -r $STRESS_DIR/*
69     rmdir $STRESS_DIR
70 } &
71
72 # start fstest -m loop in a background block; this gets us mmap coverage
73 {
74     FSTEST_DIR="$SCRATCH_MNT/fstest_test_dir"
75     mkdir "$FSTEST_DIR"
76
77     procs=2
78     while [ -f "$tmp.running" ]
79       do
80       $here/src/fstest -m -p $FSTEST_DIR  -n $procs -f 4 > /dev/null 2>&1
81     done
82
83     rm -rf $FSTEST_DIR/*
84     rmdir $FSTEST_DIR
85 } &
86
87 i=0
88 let ITERATIONS=$ITERATIONS-1
89
90 echo | tee -a $seqres.full
91 while [ $i -le $ITERATIONS ]
92 do
93         echo "*** iteration: $i" | tee -a $seqres.full
94         echo "*** freezing \$SCRATCH_MNT" | tee -a $seqres.full
95         xfs_freeze -f "$SCRATCH_MNT" | tee -a $seqres.full
96         [ $? != 0 ] && echo xfs_freeze -f "$SCRATCH_MNT" failed | \
97             tee -a $seqres.full
98         sleep 2
99
100         echo "*** thawing  \$SCRATCH_MNT" | tee -a $seqres.full
101         xfs_freeze -u "$SCRATCH_MNT" | tee -a $seqres.full
102         [ $? != 0 ] && echo xfs_freeze -u "$SCRATCH_MNT" failed | \
103             tee -a $seqres.full
104         sleep 2
105
106         echo  | tee -a $seqres.full
107         let i=$i+1
108 done
109
110 # stop fsstress iterations
111 rm $tmp.running
112
113 # wait for fsstresses to finish
114 wait
115
116 exit 1