generic/395: remove workarounds for wrong error codes
[xfstests-dev.git] / tests / generic / 048
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. 048
6 #
7 # Test for NULL files problem
8 # test inode size is on disk after sync
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1    # failure is the default!
17 trap "exit \$status" 0 1 2 3 15
18
19 # get standard environment, filters and checks
20 . ./common/rc
21 . ./common/filter
22
23 # real QA test starts here
24 _supported_fs generic
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 # Do we have enough space on disk?  10G
34 _require_fs_space $SCRATCH_MNT 10485760
35
36 _check_files()
37 {
38         # check file size and contents
39         i=1;
40         while [ $i -lt 1000 ]
41         do
42                 file=$SCRATCH_MNT/$i
43                 # if file is missing then sync failed
44                 if [ -e $file ]
45                 then
46                         # if file size is not 10MB then sync failed
47                         if [ `ls -l $file | tr -s ' ' | cut -d ' ' -f 5` -eq 10485760 ]
48                         then
49                                 # if file has non-zero size but no extents then it's contents will be NULLs, bad.
50                                 num_extents=`_count_extents $file`
51                                 if [ $num_extents -eq 0 ]; then
52                                         echo corrupt file $file - non-zero size but no extents
53                                 else
54                                         rm -f $file
55                                 fi
56                         else
57                                 echo file $file has incorrect size - sync failed
58                         fi
59                 else
60                         echo file $file missing - sync failed
61                 fi
62                 let i=$i+1
63         done
64 }
65
66 # create files and sync them
67 i=1;
68 while [ $i -lt 1000 ]
69 do
70         file=$SCRATCH_MNT/$i
71         $XFS_IO_PROG -f -c "pwrite -b 64k -S 0xff 0 10m" $file > /dev/null
72         if [ $? -ne 0 ]
73         then
74                 echo error creating/writing file $file
75                 exit
76         fi
77         let i=$i+1
78 done
79
80 # sync, then shutdown immediately after, then remount and test
81 sync
82 _scratch_shutdown
83 _scratch_unmount
84 _scratch_mount
85 _scratch_unmount
86 if [ ! _check_scratch_fs ]
87 then
88         echo error detected in filesystem
89         exit
90 fi
91 _scratch_mount
92 _check_files
93
94 status=0
95 exit