Currently there are a few ways mkfs options are specified in XFSQA:
[xfstests-dev.git] / 137
1 #! /bin/sh
2 # FSQA Test No. 137
3 #
4 # Test for NULL files problem
5 #
6 #-----------------------------------------------------------------------
7 #  Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
8 #-----------------------------------------------------------------------
9 #
10 # creator
11 owner=lachlan@sgi.com
12
13 seq=`basename $0`
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1    # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23     _cleanup_testdir
24 }
25
26 # get standard environment, filters and checks
27 . ./common.rc
28 . ./common.filter
29
30 # real QA test starts here
31 _supported_fs xfs
32 _supported_os Linux IRIX
33
34 _setup_testdir
35 _require_scratch
36 _scratch_mkfs_xfs >/dev/null 2>&1
37 _scratch_mount
38
39 # create files
40 i=1;
41 while [ $i -lt 1000 ]
42 do
43         file=$SCRATCH_MNT/$i
44         xfs_io -f -c "pwrite -b 64k -S 0xff 0 64k" $file > /dev/null
45         i=`expr $i + 1`
46 done
47
48 # give the system a chance to write something out
49 sleep 10
50
51 src/godown $SCRATCH_MNT
52
53 umount $SCRATCH_MNT
54 _scratch_mount
55
56 # check file size and contents
57 i=1;
58 while [ $i -lt 1000 ]
59 do
60         file=$SCRATCH_MNT/$i
61         # if file does not exist, the create was not logged, skip it
62         if [ -e $file ]
63         then
64                 # if file size is zero it cannot be corrupt, skip it
65                 if [ -s $file ]
66                 then
67                         # if file has non-zero size but no extents then it's contents will be NULLs, bad.
68                         if xfs_bmap $file | grep 'no extents' > /dev/null
69                         then
70                                 echo corrupt file $file - non-zero size but no extents
71                         elif xfs_bmap $file | grep 'hole' > /dev/null
72                         then
73                                 echo corrupt file $file - contains holes
74                         fi
75                 fi
76                 rm -f $file
77         fi
78         i=`expr $i + 1`
79 done
80
81 status=0
82 exit