Update xfsprogs to latest kernel headers and functions
[xfstests-dev.git] / 166
1 #! /bin/sh
2 # FSQA Test No. 166
3 #
4 # ->page-mkwrite test - unwritten extents and mmap
5 #
6 #-----------------------------------------------------------------------
7 #  Copyright (c) 2007 Silicon Graphics, Inc.  All Rights Reserved.
8 #-----------------------------------------------------------------------
9 #
10 # creator
11 owner=dgc@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 rm -f $seq.full
21
22 _cleanup()
23 {
24     _cleanup_testdir
25 }
26
27 # get standard environment, filters and checks
28 . ./common.rc
29 . ./common.filter
30
31 # assumes 1st, 3rd and 5th blocks are single written blocks,
32 # the others are unwritten.
33 _filter_blocks()
34 {
35         $AWK_PROG '
36 /^ +[0-9]/ {
37         if (!written_size) {
38                 written_size = $6
39                 unwritten1 = ((1048576/512) / 2) - written_size
40                 unwritten2 = ((1048576/512) / 2) - 2 * written_size
41         }
42
43         # is the extent unwritten?
44         unwritten_ext = 0;
45         if ($7 >= 10000)
46                 unwritten_ext = 1;
47
48         size = "RIGHT"
49         flags = "GOOD"
50         if (unwritten_ext) {
51                 if (unwritten1) {
52                         if ($6 != unwritten1)
53                                 size = "WRONG"
54                         unwritten1 = 0;
55                 } else if ($6 != unwritten2) {
56                         size = "WRONG"
57                 }
58         } else {
59                 if ($6 != written_size)
60                         size = "WRONG"
61         }
62         print $1, "[AA..BB]", "XX..YY", "AG", "(AA..BB)", size, flags
63 }'
64 }
65
66 # real QA test starts here
67 _supported_fs xfs
68 _supported_os Linux
69
70 _setup_testdir
71 _require_scratch
72 _scratch_mkfs_xfs >/dev/null 2>&1
73 _scratch_mount
74
75 TEST_FILE=$SCRATCH_MNT/test_file
76 TEST_PROG=$here/src/unwritten_mmap
77 FILE_SIZE=1048576
78
79 rm -f $TEST_FILE
80 $TEST_PROG $FILE_SIZE $TEST_FILE
81
82 xfs_bmap -vp $TEST_FILE >> $seq.full
83 xfs_bmap -vp $TEST_FILE | _filter_blocks
84
85 status=0
86 exit