xfstests: include test subdirectory support
[xfstests-dev.git] / 271
1 #! /bin/bash
2 # FSQA Test No. 271
3 #
4 # Regression testcase for d583fb87a3ff0 (ext4 extent corruption)
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2006 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 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=1        # failure is the default!
31 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
32
33 # get standard environment, filters and checks
34 . ./common.rc
35 . ./common.filter
36
37 # real QA test starts here
38 _supported_fs ext4
39 _supported_os Linux
40 _need_to_be_root
41 _require_scratch
42
43 _scratch_mkfs_sized $((128 * 1024 * 1024)) >> $seq.full 2>&1
44
45 # -onoload and EXT4_SYNC_FL on file is important becase result in
46 # metadata sync writes inside ext4_handle_dirty_metadata()
47 _scratch_mount -onoload
48 touch $SCRATCH_MNT/file
49 chattr +S $SCRATCH_MNT/file
50 # Create sparse file 
51 for ((i = 0; i < 21; i++))
52 do
53     dd if=/dev/zero of=$SCRATCH_MNT/file bs=4k count=1 seek=$((i*10))
54 done
55 # truncate last extent
56 $XFS_IO_PROG -F -f -c "truncate $((4096*200))" $SCRATCH_MNT/file
57
58 if ! _scratch_unmount; then
59         echo "failed to umount"
60         status=1
61         exit
62 fi
63 echo "Check filesystem"
64 _check_scratch_fs
65 status=$?
66 exit