xfstests: convert tests to use new results directory
[xfstests-dev.git] / tests / generic / 169
1 #! /bin/bash
2 # FSQA Test No. 169
3 #
4 # Test for file size consistency with append followed by umount/mount
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2007 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 rm -f $seqres.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 generic
58 _supported_os Linux
59
60 _require_scratch
61
62 _scratch_mkfs >>$seqres.full 2>&1 \
63         || _fail "mkfs scratch failed"
64
65 _scratch_mount >>$seqres.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 -F -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>>$seqres.full 2>&1 \
80     || _fail "unmount failed"
81
82 echo "# mounting scratch"
83 _scratch_mount >>$seqres.full 2>&1 \
84     || _fail "mount failed: $MOUNT_OPTIONS"
85
86 echo "# stating file to confirm correct size"
87 xfs_io -F -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 -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>>$seqres.full 2>&1 \
97     || _fail "unmount failed"
98
99 echo "# mounting scratch"
100 _scratch_mount >>$seqres.full 2>&1 \
101     || _fail "mount failed: $MOUNT_OPTIONS"
102
103 echo "# stating file to confirm correct size"
104 xfs_io -F -r -c "stat" $SCRATCH_MNT/nextfile \
105     | _show_wrote_and_stat_only
106
107 # success, all done
108 status=0
109 exit
110