fstests: convert remaining tests to SPDX license tags
[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 _supported_os Linux
40 _require_scratch
41 _require_freeze
42 _require_test_program "feature"
43
44 _scratch_mkfs >>$seqres.full 2>&1
45 # We don't want to freeze/unfreeze root fs if mount scratch dev failed
46 _scratch_mount
47
48 num_cpus=`$here/src/feature -o`
49
50 # Start fsstress in background
51 procs=$num_cpus
52 if [ $procs -gt 20 ]; then
53         procs=20
54 elif [ $procs -le 1 ]; then
55         procs=2
56 fi
57 nops=1000
58 stress_dir="$SCRATCH_MNT/fsstress_test_dir"
59 mkdir "$stress_dir"
60 fsstress_args=`_scale_fsstress_args -d $stress_dir -p $procs -n $nops $FSSTRESS_AVOID`
61 $FSSTRESS_PROG $fsstress_args >>$seqres.full 2>&1 &
62 fsstress_pid=$!
63
64 # Start multi-threads freeze/unfreeze
65 for ((i=0; i<$procs; i++)); do
66         while kill -0 $fsstress_pid 2>/dev/null; do
67                 xfs_freeze -f $SCRATCH_MNT 2>/dev/null
68                 xfs_freeze -u $SCRATCH_MNT 2>/dev/null
69         done &
70         freeze_pids="$! $freeze_pids"
71 done
72
73 wait $fsstress_pid
74 result=$?
75 wait $freeze_pids
76
77 # Exit with fsstress return value
78 status=$result
79 exit