fstests: move test group info to test files
[xfstests-dev.git] / tests / btrfs / 208
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FSQA Test No. 208
6 #
7 # Test subvolume deletion using the subvolume id, even when the subvolume in
8 # question is in a different mount space.
9 #
10 . ./common/preamble
11 _begin_fstest auto quick subvol
12
13 # Import common functions.
14 . ./common/filter
15 . ./common/filter.btrfs
16
17 # real QA test starts here
18 _supported_fs btrfs
19 _require_scratch
20 _require_btrfs_command subvolume delete --subvolid
21
22 _scratch_mkfs > /dev/null 2>&1
23 _scratch_mount
24
25 _delete_and_list()
26 {
27         local subvol_name="$1"
28         local msg="$2"
29
30         SUBVOLID=$(_btrfs_get_subvolid $SCRATCH_MNT "$subvol_name")
31         $BTRFS_UTIL_PROG subvolume delete --subvolid $SUBVOLID $SCRATCH_MNT | _filter_scratch
32
33         echo "$msg"
34         $BTRFS_UTIL_PROG subvolume list $SCRATCH_MNT | $AWK_PROG '{ print $NF }'
35 }
36
37 # Test creating a normal subvolumes
38 $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol1 | _filter_scratch
39 $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol2 | _filter_scratch
40 $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol3 | _filter_scratch
41
42 echo "Current subvolume ids:"
43 $BTRFS_UTIL_PROG subvolume list $SCRATCH_MNT | $AWK_PROG '{ print $NF }'
44
45 # Delete the subvolume subvol1, and list the remaining two subvolumes
46 _delete_and_list subvol1 "After deleting one subvolume:"
47 _scratch_unmount
48
49 # Now we mount the subvol2, which makes subvol3 not accessible for this mount
50 # point, but we should be able to delete it using it's subvolume id
51 $MOUNT_PROG -o subvol=subvol2 $SCRATCH_DEV $SCRATCH_MNT
52 _delete_and_list subvol3 "Last remaining subvolume:"
53 _scratch_unmount
54
55 # now mount the rootfs
56 _scratch_mount
57 # Delete the subvol2
58 _delete_and_list subvol2 "All subvolumes removed."
59 _scratch_unmount
60
61 # success, all done
62 status=0
63 exit