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