Fix unexpected 32 bit sign extension for linux time. It was fine for Irix.
[xfstests-dev.git] / 169
1 #! /bin/sh
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 #
10 # creator
11 owner=ddiss@sgi.com
12
13 seq=`basename $0`
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 rm -f $seq.full
19 status=1    # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.*
26 }
27
28 _show_wrote_and_stat_only()
29 {
30         # filer out xfs_io bits we are interested in
31         perl -ne '
32                 if (/^wrote/) { print } ;
33                 if (/^stat\.size/) { print } ;
34         '
35 }
36
37 # get standard environment, filters and checks
38 . ./common.rc
39 . ./common.filter
40
41 # real QA test starts here
42 _supported_fs xfs
43 _supported_os Linux
44
45 _require_scratch
46
47 _scratch_mkfs_xfs >>$seq.full 2>&1 \
48         || _fail "mkfs scratch failed"
49
50 _scratch_mount >>$seq.full 2>&1 \
51     || _fail "mount failed: $MOUNT_OPTIONS"
52
53 echo "# creating new file for io"
54 touch $SCRATCH_MNT/testfile
55
56 echo "# appending 15k to new file, sync every 5k"
57 xfs_io -a -c "pwrite 0 5k" -c "fsync" \
58         -c "pwrite 5k 5k" -c "fsync" \
59         -c "pwrite 10k 5k" -c "fsync" -c "stat" \
60         $SCRATCH_MNT/testfile \
61         | _show_wrote_and_stat_only
62
63 echo "# unmounting scratch"
64 umount $SCRATCH_MNT>>$seq.full 2>&1 \
65     || _fail "unmount failed"
66
67 echo "# mounting scratch"
68 _scratch_mount >>$seq.full 2>&1 \
69     || _fail "mount failed: $MOUNT_OPTIONS"
70
71 echo "# stating file to confirm correct size"
72 xfs_io -r -c "stat" $SCRATCH_MNT/testfile \
73         | _show_wrote_and_stat_only
74
75 echo "# appending 10 bytes to new file, sync at 5 bytes"
76 xfs_io -f -c "pwrite 0 5" -c s -c "pwrite 5 5" \
77         -c "stat" $SCRATCH_MNT/nextfile \
78         | _show_wrote_and_stat_only
79
80 echo "# unmounting scratch"
81 umount $SCRATCH_MNT>>$seq.full 2>&1 \
82     || _fail "unmount failed"
83
84 echo "# mounting scratch"
85 _scratch_mount >>$seq.full 2>&1 \
86     || _fail "mount failed: $MOUNT_OPTIONS"
87
88 echo "# stating file to confirm correct size"
89 xfs_io -r -c "stat" $SCRATCH_MNT/nextfile \
90     | _show_wrote_and_stat_only
91
92 # success, all done
93 status=0
94 exit
95