xfstests: move xfs specific tests out of top directory
[xfstests-dev.git] / tests / xfs / 182
1 #! /bin/bash
2 # FSQA Test No. 182
3 #
4 # Test for NULL files problem
5 # test inode size is on disk after sync - expose log replay bug
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1    # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
33
34 _cleanup()
35 {
36     _cleanup_testdir
37 }
38
39 # get standard environment, filters and checks
40 . ./common.rc
41 . ./common.filter
42
43 # real QA test starts here
44 _supported_fs xfs
45 _supported_os Linux IRIX
46
47 _setup_testdir
48 _require_scratch
49 _scratch_mkfs_xfs >/dev/null 2>&1
50 _scratch_mount
51
52 _check_files()
53 {
54         # check file size and contents
55         i=1;
56         while [ $i -lt 1000 ]
57         do
58                 file=$SCRATCH_MNT/$i
59                 # if file is missing then sync failed
60                 if [ -e $file ]
61                 then
62                         # if file size is not 32KB then sync failed
63                         if [ `ls -l $file | tr -s ' ' | cut -d ' ' -f 5` -eq 32768 ]
64                         then
65                                 # if file has non-zero size but no extents then it's contents will be NULLs, bad.
66                                 if xfs_bmap $file | grep 'no extents' > /dev/null
67                                 then
68                                         echo corrupt file $file - non-zero size but no extents
69                                 else
70                                         rm -f $file
71                                 fi
72                         else
73                                 echo file $file has incorrect size - sync failed
74                         fi
75                 else
76                         echo file $file missing - sync failed
77                 fi
78                 let i=$i+1
79         done
80 }
81
82 # create files and sync them
83 i=1;
84 while [ $i -lt 1000 ]
85 do
86         file=$SCRATCH_MNT/$i
87         xfs_io -f -c "pwrite -b 32k -S 0xff 0 32k" $file > /dev/null
88         if [ $? -ne 0 ]
89         then
90                 echo error creating/writing file $file
91                 exit
92         fi
93         let i=$i+1
94 done
95
96 # sync, then shutdown immediately after, then remount and test
97 sync
98 src/godown $SCRATCH_MNT
99 umount $SCRATCH_MNT
100 _scratch_mount
101 umount $SCRATCH_MNT
102 if [ ! _check_scratch_fs ]
103 then
104         echo error detected in filesystem
105         exit
106 fi
107 _scratch_mount
108 _check_files
109
110 status=0
111 exit