generic: test for non-zero used blocks while writing into a file
[xfstests-dev.git] / tests / generic / 390
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 999
6 #
7 # Multi-threads freeze/unfreeze testing. This's a stress test case,
8 # it won't do functional check.
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=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         # Make sure $SCRATCH_MNT is unfreezed
23         xfs_freeze -u $SCRATCH_MNT 2>/dev/null
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # remove previous $seqres.full before test
32 rm -f $seqres.full
33
34 # real QA test starts here
35 echo "Silence is golden"
36
37 # Modify as appropriate.
38 _supported_fs generic
39 _require_scratch
40 _require_freeze
41 _require_test_program "feature"
42
43 _scratch_mkfs >>$seqres.full 2>&1
44 # We don't want to freeze/unfreeze root fs if mount scratch dev failed
45 _scratch_mount
46
47 num_cpus=`$here/src/feature -o`
48
49 # Start fsstress in background
50 procs=$num_cpus
51 if [ $procs -gt 20 ]; then
52         procs=20
53 elif [ $procs -le 1 ]; then
54         procs=2
55 fi
56 nops=1000
57 stress_dir="$SCRATCH_MNT/fsstress_test_dir"
58 mkdir "$stress_dir"
59 fsstress_args=`_scale_fsstress_args -d $stress_dir -p $procs -n $nops $FSSTRESS_AVOID`
60 $FSSTRESS_PROG $fsstress_args >>$seqres.full 2>&1 &
61 fsstress_pid=$!
62
63 # Start multi-threads freeze/unfreeze
64 for ((i=0; i<$procs; i++)); do
65         while kill -0 $fsstress_pid 2>/dev/null; do
66                 xfs_freeze -f $SCRATCH_MNT 2>/dev/null
67                 xfs_freeze -u $SCRATCH_MNT 2>/dev/null
68         done &
69         freeze_pids="$! $freeze_pids"
70 done
71
72 wait $fsstress_pid
73 result=$?
74 wait $freeze_pids
75
76 # Exit with fsstress return value
77 status=$result
78 exit