-.
[xfstests-dev.git] / 140
1 #! /bin/sh
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 #
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 32k -S 0xff 0 32k" $file > /dev/null
45         xfs_io -f -c "truncate 64k" $file > /dev/null
46         i=`expr $i + 1`
47 done
48
49 # give the system a chance to write something out
50 sleep 10
51
52 src/godown $SCRATCH_MNT
53
54 umount $SCRATCH_MNT
55 _scratch_mount
56
57 # check file size and contents
58 i=1;
59 while [ $i -lt 1000 ]
60 do
61         file=$SCRATCH_MNT/$i
62         # if file does not exist, the create was not logged, skip it
63         if [ -e $file ]
64         then
65                 # if file size is zero it cannot be corrupt, skip it
66                 if [ -s $file ]
67                 then
68                         # if file has non-zero size but no extents then it's contents will be NULLs, bad.
69                         if xfs_bmap $file | grep 'no extents' > /dev/null
70                         then
71                                 echo corrupt file $file - non-zero size but no extents
72                         fi
73                 fi
74                 rm -f $file
75         fi
76         i=`expr $i + 1`
77 done
78
79 status=0
80 exit