Add GPL license plate to SGI's test files.
[xfstests-dev.git] / 169
1 #! /bin/sh
2 #
3 #-----------------------------------------------------------------------
4 # Copyright (c) 2007 Silicon Graphics, Inc.  All Rights Reserved.
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation.
9 #
10 # This program is distributed in the hope that it would be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write the Free Software Foundation,
17 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 #
19 #-----------------------------------------------------------------------
20 #
21 # FSQA Test No. 169
22 #
23 # Test for file size consistency with append followed by umount/mount
24 #
25 # creator
26 owner=ddiss@sgi.com
27
28 seq=`basename $0`
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 rm -f $seq.full
34 status=1    # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
36
37 _cleanup()
38 {
39         cd /
40         rm -f $tmp.*
41 }
42
43 _show_wrote_and_stat_only()
44 {
45         # filer out xfs_io bits we are interested in
46         perl -ne '
47                 if (/^wrote/) { print } ;
48                 if (/^stat\.size/) { print } ;
49         '
50 }
51
52 # get standard environment, filters and checks
53 . ./common.rc
54 . ./common.filter
55
56 # real QA test starts here
57 _supported_fs xfs
58 _supported_os Linux
59
60 _require_scratch
61
62 _scratch_mkfs_xfs >>$seq.full 2>&1 \
63         || _fail "mkfs scratch failed"
64
65 _scratch_mount >>$seq.full 2>&1 \
66     || _fail "mount failed: $MOUNT_OPTIONS"
67
68 echo "# creating new file for io"
69 touch $SCRATCH_MNT/testfile
70
71 echo "# appending 15k to new file, sync every 5k"
72 xfs_io -a -c "pwrite 0 5k" -c "fsync" \
73         -c "pwrite 5k 5k" -c "fsync" \
74         -c "pwrite 10k 5k" -c "fsync" -c "stat" \
75         $SCRATCH_MNT/testfile \
76         | _show_wrote_and_stat_only
77
78 echo "# unmounting scratch"
79 umount $SCRATCH_MNT>>$seq.full 2>&1 \
80     || _fail "unmount failed"
81
82 echo "# mounting scratch"
83 _scratch_mount >>$seq.full 2>&1 \
84     || _fail "mount failed: $MOUNT_OPTIONS"
85
86 echo "# stating file to confirm correct size"
87 xfs_io -r -c "stat" $SCRATCH_MNT/testfile \
88         | _show_wrote_and_stat_only
89
90 echo "# appending 10 bytes to new file, sync at 5 bytes"
91 xfs_io -f -c "pwrite 0 5" -c s -c "pwrite 5 5" \
92         -c "stat" $SCRATCH_MNT/nextfile \
93         | _show_wrote_and_stat_only
94
95 echo "# unmounting scratch"
96 umount $SCRATCH_MNT>>$seq.full 2>&1 \
97     || _fail "unmount failed"
98
99 echo "# mounting scratch"
100 _scratch_mount >>$seq.full 2>&1 \
101     || _fail "mount failed: $MOUNT_OPTIONS"
102
103 echo "# stating file to confirm correct size"
104 xfs_io -r -c "stat" $SCRATCH_MNT/nextfile \
105     | _show_wrote_and_stat_only
106
107 # success, all done
108 status=0
109 exit
110