xfs: Check for extent overflow when trivally adding a new extent
[xfstests-dev.git] / tests / btrfs / 001
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2011 Red Hat.  All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/001
6 #
7 # Test btrfs's subvolume and snapshot support
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16
17 _cleanup()
18 {
19     rm -f $tmp.*
20 }
21
22 trap "_cleanup ; exit \$status" 0 1 2 3 15
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/filter.btrfs
28
29 # real QA test starts here
30 _supported_fs btrfs
31 _require_scratch
32
33 _scratch_mkfs > /dev/null 2>&1
34 _scratch_mount
35
36 # First test basic snapshotting
37 echo "Creating file foo in root dir"
38 dd if=/dev/zero of=$SCRATCH_MNT/foo bs=1M count=1 &> /dev/null
39 echo "List root dir"
40 ls $SCRATCH_MNT
41 echo "Creating snapshot of root dir"
42 $BTRFS_UTIL_PROG subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap | _filter_scratch
43 echo "List root dir after snapshot"
44 ls $SCRATCH_MNT
45 echo "List snapshot dir"
46 ls $SCRATCH_MNT/snap
47 rm -f $SCRATCH_MNT/foo
48 echo "List root dir after rm of foo"
49 ls $SCRATCH_MNT
50 echo "List snapshot dir"
51 ls $SCRATCH_MNT/snap
52
53 # Test creating a normal subvolme
54 $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol | _filter_scratch
55 echo "Listing root dir"
56 ls $SCRATCH_MNT
57 echo "Listing subvol"
58 ls $SCRATCH_MNT/subvol
59
60 # Test setting a default mount
61 echo "Creating file bar in subvol"
62 dd if=/dev/zero of=$SCRATCH_MNT/subvol/bar bs=1M count=1 &> /dev/null
63 echo "Setting subvol to the default"
64 subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT subvol)
65 $BTRFS_UTIL_PROG subvolume set-default $subvolid $SCRATCH_MNT | _filter_scratch
66 _scratch_cycle_mount
67 echo "List root dir which is now subvol"
68 ls $SCRATCH_MNT
69 _scratch_unmount
70 echo "Mounting sbuvolid=0 for the root dir"
71 _scratch_mount "-o subvolid=0"
72 echo "List root dir"
73 ls $SCRATCH_MNT
74 echo "Setting the root dir as the default again"
75 $BTRFS_UTIL_PROG subvolume set-default 0 $SCRATCH_MNT | _filter_scratch
76 _scratch_cycle_mount
77 echo "List root dir"
78 ls $SCRATCH_MNT
79
80 # Test listing the subvolumes
81 echo "Listing subvolumes"
82 $BTRFS_UTIL_PROG subvolume list $SCRATCH_MNT | awk '{ print $NF }'
83
84 # Delete the snapshot
85 $BTRFS_UTIL_PROG subvolume delete $SCRATCH_MNT/snap | _filter_btrfs_subvol_delete
86 echo "List root dir"
87 ls $SCRATCH_MNT
88 _scratch_cycle_mount
89 echo "List root dir"
90 ls $SCRATCH_MNT
91
92 status=0 ; exit