xfstests: kill useless test owner fields
[xfstests-dev.git] / 254
1 #! /bin/bash
2 # FS QA Test No. 254
3 #
4 # Test btrfs's subvolume and snapshot support
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2011 Red Hat.  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
32 _cleanup()
33 {
34     rm -f $tmp.*
35 }
36
37 trap "_cleanup ; exit \$status" 0 1 2 3 15
38
39 # get standard environment, filters and checks
40 . ./common.rc
41 . ./common.filter
42
43 # real QA test starts here
44 _supported_fs btrfs
45 _supported_os Linux
46 _require_scratch
47
48 _scratch_mkfs > /dev/null 2>&1
49 _scratch_mount
50
51 # First test basic snapshotting
52 echo "Creating file foo in root dir"
53 dd if=/dev/zero of=$SCRATCH_MNT/foo bs=1M count=1 &> /dev/null
54 echo "List root dir"
55 ls $SCRATCH_MNT
56 echo "Creating snapshot of root dir"
57 btrfs subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap | _filter_scratch
58 echo "List root dir after snapshot"
59 ls $SCRATCH_MNT
60 echo "List snapshot dir"
61 ls $SCRATCH_MNT/snap
62 rm -f $SCRATCH_MNT/foo
63 echo "List root dir after rm of foo"
64 ls $SCRATCH_MNT
65 echo "List snapshot dir"
66 ls $SCRATCH_MNT/snap
67
68 # Test creating a normal subvolme
69 btrfs subvolume create $SCRATCH_MNT/subvol | _filter_scratch
70 echo "Listing root dir"
71 ls $SCRATCH_MNT
72 echo "Listing subvol"
73 ls $SCRATCH_MNT/subvol
74
75 # Test setting a default mount
76 echo "Creating file bar in subvol"
77 dd if=/dev/zero of=$SCRATCH_MNT/subvol/bar bs=1M count=1 &> /dev/null
78 echo "Setting subvol to the default"
79 btrfs subvolume set-default 0 $SCRATCH_MNT/subvol | _filter_scratch
80 _scratch_remount
81 echo "List root dir which is now subvol"
82 ls $SCRATCH_MNT
83 _scratch_unmount
84 echo "Mounting sbuvolid=0 for the root dir"
85 _scratch_mount "-o subvolid=0"
86 echo "List root dir"
87 ls $SCRATCH_MNT
88 echo "Setting the root dir as the default again"
89 btrfs subvolume set-default 0 $SCRATCH_MNT | _filter_scratch
90 _scratch_remount
91 echo "List root dir"
92 ls $SCRATCH_MNT
93
94 # Test listing the subvolumes
95 echo "Listing subvolumes"
96 btrfs subvolume list $SCRATCH_MNT | awk '{ print $NF }'
97
98 # Delete the snapshot
99 btrfs subvolume delete $SCRATCH_MNT/snap | _filter_scratch
100 echo "List root dir"
101 ls $SCRATCH_MNT
102 _scratch_remount
103 echo "List root dir"
104 ls $SCRATCH_MNT
105
106 status=0 ; exit