b658004794ab91e7c78d22b3d0421fc1d7fa130c
[xfstests-dev.git] / 274
1 #! /bin/bash
2 # FS QA Test No. 274
3 #
4 # preallocation test
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2011-2012 Fujitsu, 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 #creator
25 owner=wu.bo@cn.fujitsu.com
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=0    # success is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37         cd /
38         rm -f $SCRATCH_MNT/* $tmp.*
39         _scratch_unmount
40 }
41
42 . ./common.rc
43 . ./common.filter
44
45 # real QA test starts here
46 _supported_fs generic
47 _supported_os IRIX Linux
48 _require_scratch
49
50 echo "------------------------------"
51 echo "preallocation test"
52 echo "------------------------------"
53
54 rm -f $seq.full
55
56 umount $SCRATCH_DEV 2>/dev/null
57 _scratch_mkfs_sized $((1 * 1024 * 1024 * 1024)) >>$seq.full 2>&1
58 _scratch_mount
59
60 rm -rf $SCRATCH_MNT/*
61 cd $SCRATCH_MNT
62 dd if=/dev/zero of=test bs=4K count=1 >/dev/null 2>&1
63 if [ $? -ne 0 ]
64 then
65         echo "create file err"
66         status=1
67         exit
68 fi
69
70 fallocate -n -o 4K -l 1M test >/dev/null 2>&1
71 if [ $? -ne 0 ]
72 then
73         echo "fallocate file err"
74         status=1
75         exit
76 fi
77
78 dd if=/dev/zero of=tmp1 bs=1M >/dev/null 2>&1
79 dd if=/dev/zero of=tmp2 bs=4K >/dev/null 2>&1
80 sync
81
82 dd if=/dev/zero of=test seek=1 bs=4K count=2 conv=notrunc >/dev/null 2>&1
83 if [ $? -ne 0 ]
84 then
85         echo "fill prealloc range err"
86         status=1
87         exit
88 fi
89
90 echo "done"
91 exit