lib/: spdx license conversion
[xfstests-dev.git] / tests / generic / 075
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 075
6 #
7 # fsx (non-AIO variant)
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     rm -rf $TEST_DIR/fsx.* $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 _do_test()
29 {
30     _n="$1"
31     _param="$2"
32
33     out=$TEST_DIR/fsx
34     rm -rf $out
35     if ! mkdir $out
36     then
37         echo "    failed to mkdir $out"
38         status=1
39         exit
40     fi
41
42     _filter_param=`echo "$_param" | sed\
43         -e 's/-N [0-9][0-9]*/-N numops/' \
44         -e 's/-l [0-9][0-9]*/-l filelen/'`
45
46     echo ""
47     echo "-----------------------------------------------"
48     echo "fsx.$_n : $_filter_param"
49     echo "-----------------------------------------------"
50
51     if [ "$FSTYP" != "xfs" ]
52     then
53         if [ "$_n" = "1" -o "$_n" = "3" ]
54         then
55             # HACK: only xfs handles preallocation (-x) so just skip this test
56             return
57         fi
58     fi
59
60     # This cd and use of -P gets full debug on $here (not TEST_DEV)
61     cd $out
62     if ! $here/ltp/fsx $_param -P $here $seq.$_n $FSX_AVOID &>/dev/null
63     then
64         echo "    fsx ($_param) failed, $? - compare $seqres.$_n.{good,bad,fsxlog}"
65         mv $out/$seq.$_n $seqres.$_n.full
66         mv $here/$seq.$_n.fsxlog $seqres.$_n.fsxlog
67         od -xAx $seqres.$_n.full > $seqres.$_n.bad
68         od -xAx $here/$seq.$_n.fsxgood > $seqres.$_n.good
69         rm -f $here/$seq.$_n.fsxgood
70         status=1
71         exit
72     fi
73
74     cd $here
75     _check_test_fs
76 }
77
78 _usage()
79 {
80     echo "$0: [-l filelen] [-n numops1] [-N numops2]"
81 }
82
83 _process_args()
84 {
85     OPTIND=1
86     while getopts "l:n:N:?" c $@
87     do
88         case $c
89         in
90             l)
91                 filelen=$OPTARG
92                 param_type="$param_type, overidde -l"
93                 ;;
94             N)
95                 numops2=$OPTARG
96                 param_type="$param_type, overidde -N"
97                 ;;
98             n)
99                 numops1=$OPTARG
100                 param_type="$param_type, overidde -n"
101                 ;;
102             ?)
103                 _usage
104                 exit    
105                 ;;
106         esac
107     done
108 }
109
110 # real QA test starts here
111 _supported_fs generic
112 _supported_os Linux
113 _require_test
114
115 size10=`expr 10 \* 1024 \* 1024`        # 10 megabytes
116 filelen=$size10
117 numops1=1000
118 numops2=10000
119
120 # can override the params here
121 _process_args "$@"
122
123 echo "Params are for $param_type" >>$seqres.full
124 echo "Params: n = $numops1 N = $numops2 l = $filelen" >>$seqres.full
125
126 rm -f $seqres.full
127 echo "brevity is wit..."
128
129 _check_test_fs
130
131 # Options:
132 # -d: debug output for all operations
133 # -l flen: the upper bound on file size (default 262144)
134 # -o oplen: the upper bound on operation size
135 # -N numops: total # operations to do (default infinity)
136 # -P: save .fsxlog and .fsxgood files in dirpath (default ./)
137 # -S seed: for random # generator (default 1) 0 gets timestamp
138 # -x: pre-allocate file space, exercising unwritten extents
139
140 _do_test 0 "-d -N $numops1 -S 0"
141 _do_test 1 "-d -N $numops1 -S 0 -x"
142 _do_test 2 "-d -N $numops2 -l $filelen -S 0"
143 _do_test 3 "-d -N $numops2 -l $filelen -S 0 -x"
144
145 rm -f $seq.*.fsx{good,log}
146 exit 0