generic/402: Drop useless fail message
[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
25 _require_scratch
26 _require_scratch_shutdown
27 _require_xfs_io_command "fiemap"
28 _scratch_mkfs >/dev/null 2>&1
29 _require_metadata_journaling $SCRATCH_DEV
30 _scratch_mount
31
32 # create files
33 i=1;
34 while [ $i -lt 1000 ]
35 do
36         file=$SCRATCH_MNT/$i
37         $XFS_IO_PROG -f -c "pwrite -b 64k -S 0xff 0 64k" $file > /dev/null
38         if [ $? -ne 0 ]
39         then
40                 echo error creating/writing file $file
41                 exit
42         fi
43         let i=$i+1
44 done
45
46 # give the system a chance to write something out
47 sleep 10
48
49 _scratch_shutdown
50
51 _scratch_unmount
52 _scratch_mount
53 _scratch_unmount
54 if [ ! _check_scratch_fs ]
55 then
56         echo error detected in filesystem
57         exit
58 fi
59 _scratch_mount
60
61 # check file size and contents
62 i=1;
63 while [ $i -lt 1000 ]
64 do
65         file=$SCRATCH_MNT/$i
66         # if file does not exist, the create was not logged, skip it
67         if [ -e $file ]
68         then
69                 # if file size is zero it cannot be corrupt, skip it
70                 if [ -s $file ]
71                 then
72                         # if file has non-zero size but no extents then it's contents will be NULLs, bad.
73                         num_extents=`_count_extents $file`
74                         num_holes=`_count_holes $file`
75                         if [ $num_extents -eq 0 ]; then
76                                 echo corrupt file $file - non-zero size but no extents
77                         elif [ $num_holes -ne 0 ]; then
78                                 echo corrupt file $file - contains holes
79                         else
80                                 rm -f $file
81                         fi
82                 else
83                         rm -f $file
84                 fi
85         fi
86         let i=$i+1
87 done
88
89 status=0
90 exit