fsx: Use %ll instead of %q in printf format statements
[xfstests-dev.git] / 180
1 #! /bin/sh
2 # FSQA Test No. 180
3 #
4 # Test for NULL files problem
5 # test inode size is on disk after sync
6 #
7 #-----------------------------------------------------------------------
8 #  Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
9 #-----------------------------------------------------------------------
10 #
11 # creator
12 owner=lachlan@sgi.com
13
14 seq=`basename $0`
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1    # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24     _cleanup_testdir
25 }
26
27 # get standard environment, filters and checks
28 . ./common.rc
29 . ./common.filter
30
31 # real QA test starts here
32 _supported_fs xfs
33 _supported_os Linux IRIX
34
35 _setup_testdir
36 _require_scratch
37 _scratch_mkfs_xfs >/dev/null 2>&1
38 _scratch_mount
39
40 # Do we have enough space on disk?
41 FREE_BLOCKS=`df -klP $SCRATCH_MNT | grep -v Filesystem | awk '{print $4}'`
42 [ $FREE_BLOCKS -lt 10485760 ] && _notrun "This test requires at least 10GB of \
43                                           $SCRATCH_DEV to run"
44
45 _check_files()
46 {
47         # check file size and contents
48         i=1;
49         while [ $i -lt 1000 ]
50         do
51                 file=$SCRATCH_MNT/$i
52                 # if file is missing then sync failed
53                 if [ -e $file ]
54                 then
55                         # if file size is not 10MB then sync failed
56                         if [ `ls -l $file | tr -s ' ' | cut -d ' ' -f 5` -eq 10485760 ]
57                         then
58                                 # if file has non-zero size but no extents then it's contents will be NULLs, bad.
59                                 if xfs_bmap $file | grep 'no extents' > /dev/null
60                                 then
61                                         echo corrupt file $file - non-zero size but no extents
62                                 else
63                                         rm -f $file
64                                 fi
65                         else
66                                 echo file $file has incorrect size - sync failed
67                         fi
68                 else
69                         echo file $file missing - sync failed
70                 fi
71                 let i=$i+1
72         done
73 }
74
75 # create files and sync them
76 i=1;
77 while [ $i -lt 1000 ]
78 do
79         file=$SCRATCH_MNT/$i
80         xfs_io -f -c "pwrite -b 64k -S 0xff 0 10m" $file > /dev/null
81         if [ $? -ne 0 ]
82         then
83                 echo error creating/writing file $file
84                 exit
85         fi
86         let i=$i+1
87 done
88
89 # sync, then shutdown immediately after, then remount and test
90 sync
91 src/godown $SCRATCH_MNT
92 umount $SCRATCH_MNT
93 _scratch_mount
94 umount $SCRATCH_MNT
95 if [ ! _check_scratch_fs ]
96 then
97         echo error detected in filesystem
98         exit
99 fi
100 _scratch_mount
101 _check_files
102
103 status=0
104 exit