generic/402: Drop useless fail message
[xfstests-dev.git] / tests / generic / 047
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. 047
6 #
7 # Test for NULL files problem
8 # test inode size is on disk after fsync
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 _check_files()
34 {
35         # check file size and contents
36         i=1;
37         while [ $i -lt 1000 ]
38         do
39                 file=$SCRATCH_MNT/$i
40                 # if file is missing then fsync failed
41                 if [ -e $file ]
42                 then
43                         # if file size is not 32KB then fsync failed
44                         if [ `ls -l $file | tr -s ' ' | cut -d ' ' -f 5` -eq 32768 ]
45                         then
46                                 # if file has non-zero size but no extents then it's contents will be NULLs, bad.
47                                 num_extents=`_count_extents $file`
48                                 if [ $num_extents -eq 0 ]; then
49                                         echo corrupt file $file - non-zero size but no extents
50                                 else
51                                         rm -f $file
52                                 fi
53                         else
54                                 echo file $file has incorrect size - fsync failed
55                         fi
56                 else
57                         echo file $file missing - fsync failed
58                 fi
59                 let i=$i+1
60         done
61 }
62
63 # create files and fsync them
64 i=1;
65 while [ $i -lt 1000 ]
66 do
67         file=$SCRATCH_MNT/$i
68         $XFS_IO_PROG -f -c "pwrite -b 32k -S 0xff 0 32k" -c "fsync" $file > /dev/null
69         if [ $? -ne 0 ]
70         then
71                 echo error creating/writing file $file
72                 exit
73         fi
74         let i=$i+1
75 done
76
77 # shutdown immediately after, then remount and test
78 _scratch_shutdown
79 _scratch_unmount
80 _scratch_mount
81 _scratch_unmount
82 if [ ! _check_scratch_fs ]
83 then
84         echo error detected in filesystem
85         exit
86 fi
87 _scratch_mount
88 _check_files
89
90 status=0
91 exit