generic: convert tests to SPDX license tags
[xfstests-dev.git] / tests / generic / 013
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 013
6 #
7 # fsstress
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=0        # success is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20     cd /
21     # we might get here with a RO FS
22     _test_cycle_mount
23     # now remove fsstress directory.
24     rm -rf $TEST_DIR/fsstress.$$.*
25 }
26
27 _filesize()
28 {
29     ls -l $1 | $AWK_PROG '{print "    filesize = " $5}'
30 }
31
32 # get standard environment, filters and checks
33 . ./common/rc
34 . ./common/filter
35
36 _do_test()
37 {
38     _n="$1"
39     _param="$2"
40     _count="$3"
41
42     out=$TEST_DIR/fsstress.$$.$_n
43     rm -rf $out
44     if ! mkdir $out
45     then
46         echo "    failed to mkdir $out"
47         status=1
48         exit
49     fi
50
51     echo ""
52     echo "-----------------------------------------------"
53     echo "fsstress.$_n : $_param"
54     echo "-----------------------------------------------"
55     # -m limits number of users/groups so check doesn't fail (malloc) later
56     dbgoutfile=$seqres.full
57     if ! $FSSTRESS_PROG $_param $FSSTRESS_AVOID -v -m 8 -n $_count -d $out >>$dbgoutfile 2>&1
58     then
59         echo "    fsstress (count=$_count) returned $? - see $seqres.full"
60         echo "--------------------------------------"       >>$seqres.full
61         echo "$_n - output from fsstress:"                  >>$seqres.full
62         echo "--------------------------------------"       >>$seqres.full
63         echo "<NOT LOGGED>"                                 >>$seqres.full
64         #cat $tmp.out                                       >>$seqres.full
65         status=1
66     fi
67
68     _check_test_fs
69 }
70
71 # real QA test starts here
72 _supported_fs generic
73 _supported_os Linux
74 _require_test
75
76 rm -f $seqres.full
77 echo "brevity is wit..."
78
79 count=1000
80 procs=20
81
82 _check_test_fs
83
84 # the default
85
86 _do_test 1 "-r" $count
87
88 # and the default with multiprocess
89
90 _do_test 2 "-p $procs -r" $count
91
92 # from Glen's notes
93
94 _do_test 3 "-p 4 -z -f rmdir=10 -f link=10 -f creat=10 -f mkdir=10 -f rename=30 -f stat=30 -f unlink=30 -f truncate=20" $count
95
96 # if all ok by here then probably don't need $seqres.full
97 rm -f $seqres.full
98
99 exit
100
101 # Test with error injection:
102 #
103 # (error injection)
104 # fsstress -n 1000 -d $scratch -p 4 -z -f rmdir=10 -f link=10 -f creat=10 \
105 #          -f mkdir=10 -f rename=30 -f stat=30 -f unlink=30 -f truncate=20 \
106 #          -e 1
107 #
108 # Error values 1 - 6 test IFLUSH
109 #         1 - corrupt buffer being flushed to di_core.di_magic
110 #         2 - corrupt inode being flushed i_d.di_magic
111 #         3 - corrupt S_IFREG format check
112 #         4 - corrupt S_IFDIR format check
113 #         5 - corrupt i_d.di_nextents
114 #         6 - corrupt i_d.di_forkoff > sb_inodesize