generic/563: use a loop device to avoid partition incompatibility
[xfstests-dev.git] / tests / btrfs / 161
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test 161
6 #
7 # seed sprout functionality test
8 #  Create a seed device, mount it and, add a new device to create a
9 #  sprout filesystem.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # remove previous $seqres.full before test
31 rm -f $seqres.full
32
33 # real QA test starts here
34
35 # Modify as appropriate.
36 _supported_fs btrfs
37 _require_command "$BTRFS_TUNE_PROG" btrfstune
38 _require_scratch_dev_pool 2
39
40 _scratch_dev_pool_get 2
41
42 dev_seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
43 dev_sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
44
45 create_seed()
46 {
47         _mkfs_dev $dev_seed
48         run_check _mount $dev_seed $SCRATCH_MNT
49         $XFS_IO_PROG -f -d -c "pwrite -S 0xab 0 256K" $SCRATCH_MNT/foobar >\
50                 /dev/null
51         echo -- golden --
52         od -x $SCRATCH_MNT/foobar
53         _run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
54         _scratch_unmount
55         $BTRFS_TUNE_PROG -S 1 $dev_seed
56         run_check _mount $dev_seed $SCRATCH_MNT
57 }
58
59 create_sprout()
60 {
61         _run_btrfs_util_prog device add -f $dev_sprout $SCRATCH_MNT
62         _scratch_unmount
63         run_check _mount $dev_sprout $SCRATCH_MNT
64         echo -- sprout --
65         od -x $SCRATCH_MNT/foobar
66         _scratch_unmount
67 }
68
69 create_seed
70 create_sprout
71
72 _scratch_dev_pool_put
73
74 status=0
75 exit