common/fuzzy: try to clear blocking flags first in _scratch_fuzz_modify
[xfstests-dev.git] / tests / generic / 043
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. 043
6 #
7 # Test for NULL files problem
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=1    # failure is the default!
16 trap "exit \$status" 0 1 2 3 15
17
18 # get standard environment, filters and checks
19 . ./common/rc
20 . ./common/filter
21
22 # real QA test starts here
23 _supported_fs generic
24 _supported_os Linux
25
26 _require_scratch
27 _require_scratch_shutdown
28 _require_xfs_io_command "fiemap"
29 _scratch_mkfs >/dev/null 2>&1
30 _require_metadata_journaling $SCRATCH_DEV
31 _scratch_mount
32
33 # create files
34 i=1;
35 while [ $i -lt 1000 ]
36 do
37         file=$SCRATCH_MNT/$i
38         $XFS_IO_PROG -f -c "pwrite -b 64k -S 0xff 0 64k" $file > /dev/null
39         if [ $? -ne 0 ]
40         then
41                 echo error creating/writing file $file
42                 exit
43         fi
44         let i=$i+1
45 done
46
47 # give the system a chance to write something out
48 sleep 10
49
50 _scratch_shutdown
51
52 _scratch_unmount
53 _scratch_mount
54 _scratch_unmount
55 if [ ! _check_scratch_fs ]
56 then
57         echo error detected in filesystem
58         exit
59 fi
60 _scratch_mount
61
62 # check file size and contents
63 i=1;
64 while [ $i -lt 1000 ]
65 do
66         file=$SCRATCH_MNT/$i
67         # if file does not exist, the create was not logged, skip it
68         if [ -e $file ]
69         then
70                 # if file size is zero it cannot be corrupt, skip it
71                 if [ -s $file ]
72                 then
73                         # if file has non-zero size but no extents then it's contents will be NULLs, bad.
74                         num_extents=`_count_extents $file`
75                         num_holes=`_count_holes $file`
76                         if [ $num_extents -eq 0 ]; then
77                                 echo corrupt file $file - non-zero size but no extents
78                         elif [ $num_holes -ne 0 ]; then
79                                 echo corrupt file $file - contains holes
80                         else
81                                 rm -f $file
82                         fi
83                 else
84                         rm -f $file
85                 fi
86         fi
87         let i=$i+1
88 done
89
90 status=0
91 exit