2 # FS QA Test No. btrfs/001
4 # Test btrfs's subvolume and snapshot support
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2011 Red Hat. All Rights Reserved.
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.
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.
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
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
38 trap "_cleanup ; exit \$status" 0 1 2 3 15
40 # get standard environment, filters and checks
43 . ./common/filter.btrfs
45 # real QA test starts here
50 _scratch_mkfs > /dev/null 2>&1
53 # First test basic snapshotting
54 echo "Creating file foo in root dir"
55 dd if=/dev/zero of=$SCRATCH_MNT/foo bs=1M count=1 &> /dev/null
58 echo "Creating snapshot of root dir"
59 $BTRFS_UTIL_PROG subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap | _filter_scratch
60 echo "List root dir after snapshot"
62 echo "List snapshot dir"
64 rm -f $SCRATCH_MNT/foo
65 echo "List root dir after rm of foo"
67 echo "List snapshot dir"
70 # Test creating a normal subvolme
71 $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol | _filter_scratch
72 echo "Listing root dir"
75 ls $SCRATCH_MNT/subvol
77 # Test setting a default mount
78 echo "Creating file bar in subvol"
79 dd if=/dev/zero of=$SCRATCH_MNT/subvol/bar bs=1M count=1 &> /dev/null
80 echo "Setting subvol to the default"
81 subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT subvol)
82 $BTRFS_UTIL_PROG subvolume set-default $subvolid $SCRATCH_MNT | _filter_scratch
84 echo "List root dir which is now subvol"
87 echo "Mounting sbuvolid=0 for the root dir"
88 _scratch_mount "-o subvolid=0"
91 echo "Setting the root dir as the default again"
92 $BTRFS_UTIL_PROG subvolume set-default 0 $SCRATCH_MNT | _filter_scratch
97 # Test listing the subvolumes
98 echo "Listing subvolumes"
99 $BTRFS_UTIL_PROG subvolume list $SCRATCH_MNT | awk '{ print $NF }'
101 # Delete the snapshot
102 $BTRFS_UTIL_PROG subvolume delete $SCRATCH_MNT/snap | _filter_btrfs_subvol_delete