fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 049
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. 049
6 #
7 # Test for NULL files problem
8 # test inode size is on disk after sync - expose log replay bug
9 #
10 . ./common/preamble
11 _begin_fstest shutdown metadata rw auto
12
13 # Import common functions.
14 . ./common/filter
15
16 # real QA test starts here
17 _supported_fs generic
18
19 _require_scratch
20 _require_scratch_shutdown
21 _require_xfs_io_command "fiemap"
22 _scratch_mkfs >/dev/null 2>&1
23 _require_metadata_journaling $SCRATCH_DEV
24 _scratch_mount
25
26 _check_files()
27 {
28         # check file size and contents
29         i=1;
30         while [ $i -lt 1000 ]
31         do
32                 file=$SCRATCH_MNT/$i
33                 # if file is missing then sync failed
34                 if [ -e $file ]
35                 then
36                         # if file size is not 32KB then sync failed
37                         if [ `ls -l $file | tr -s ' ' | cut -d ' ' -f 5` -eq 32768 ]
38                         then
39                                 # if file has non-zero size but no extents then it's contents will be NULLs, bad.
40                                 num_extents=`_count_extents $file`
41                                 if [ $num_extents -eq 0 ]; then
42                                         echo corrupt file $file - non-zero size but no extents
43                                 else
44                                         rm -f $file
45                                 fi
46                         else
47                                 echo file $file has incorrect size - sync failed
48                         fi
49                 else
50                         echo file $file missing - sync failed
51                 fi
52                 let i=$i+1
53         done
54 }
55
56 # create files and sync them
57 i=1;
58 while [ $i -lt 1000 ]
59 do
60         file=$SCRATCH_MNT/$i
61         $XFS_IO_PROG -f -c "pwrite -b 32k -S 0xff 0 32k" $file > /dev/null
62         if [ $? -ne 0 ]
63         then
64                 echo error creating/writing file $file
65                 exit
66         fi
67         let i=$i+1
68 done
69
70 # sync, then shutdown immediately after, then remount and test
71 sync
72 _scratch_shutdown
73 _scratch_unmount
74 _scratch_mount
75 _scratch_unmount
76 if [ ! _check_scratch_fs ]
77 then
78         echo error detected in filesystem
79         exit
80 fi
81 _scratch_mount
82 _check_files
83
84 status=0
85 exit