generic/395: remove workarounds for wrong error codes
[xfstests-dev.git] / tests / generic / 044
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. 044
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         $XFS_IO_PROG -c "truncate 64k" $file > /dev/null
44         if [ $? -ne 0 ]
45         then
46                 echo error truncating file $file
47                 exit
48         fi
49         let i=$i+1
50 done
51
52 # give the system a chance to write something out
53 sleep 10
54
55 _scratch_shutdown
56
57 _scratch_unmount
58 _scratch_mount
59 _scratch_unmount
60 if [ ! _check_scratch_fs ]
61 then
62         echo error detected in filesystem
63         exit
64 fi
65 _scratch_mount
66
67 # check file size and contents
68 i=1;
69 while [ $i -lt 1000 ]
70 do
71         file=$SCRATCH_MNT/$i
72         # if file does not exist, the create was not logged, skip it
73         if [ -e $file ]
74         then
75                 # if file size is zero it cannot be corrupt, skip it
76                 if [ -s $file ]
77                 then
78                         # if file has non-zero size but no extents then it's contents will be NULLs, bad.
79                         num_extents=`_count_extents $file`
80                         num_holes=`_count_holes $file`
81                         if [ $num_extents -eq 0 ]; then
82                                 echo corrupt file $file - non-zero size but no extents
83                         elif [ $num_holes -ne 0 ]; then
84                                 echo corrupt file $file - contains holes
85                         else
86                                 rm -f $file
87                         fi
88                 else
89                         rm -f $file
90                 fi
91         fi
92         let i=$i+1
93 done
94
95 status=0
96 exit