fstests: move test group info to test files
[xfstests-dev.git] / tests / btrfs / 185
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle. All Rights Reserved.
4 #
5 # FS QA Test 185
6 #
7 # Fuzzy test for FS image duplication.
8 #  Could be fixed by
9 #  a9261d4125c9 ("btrfs: harden agaist duplicate fsid on scanned devices")
10 #
11 . ./common/preamble
12 _begin_fstest volume
13
14 mnt=$TEST_DIR/$seq.mnt
15 # Override the default cleanup function.
16 _cleanup()
17 {
18         rm -rf $mnt > /dev/null 2>&1
19         cd /
20         rm -f $tmp.*
21 }
22
23 # Import common functions.
24 . ./common/filter
25
26 # real QA test starts here
27 _supported_fs btrfs
28 _require_scratch_dev_pool 2
29 _scratch_dev_pool_get 2
30
31 device_1=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
32 device_2=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
33
34 echo device_1=$device_1 device_2=$device_2 >> $seqres.full
35
36 rm -rf $mnt > /dev/null 2>&1
37 mkdir $mnt
38 _mkfs_dev $device_1
39 _mount $device_1 $mnt
40
41 [[ $(findmnt $mnt | grep -v TARGET | awk '{print $2}') != $device_1 ]] && \
42                                                 _fail "mounted device changed"
43
44 for sb_bytenr in 65536 67108864; do
45         echo -n "dd status=none if=$dev_foo of=$dev_bar bs=1 "\
46                 "seek=$sb_bytenr skip=$sb_bytenr count=4096" >> $seqres.full
47         dd status=none if=$device_1 of=$device_2 bs=1 seek=$sb_bytenr \
48                                 skip=$sb_bytenr count=4096 > /dev/null 2>&1
49         echo ..:$? >> $seqres.full
50 done
51
52 # Original device is mounted, scan of its clone should fail
53 $BTRFS_UTIL_PROG device scan $device_2 >> $seqres.full 2>&1
54 [[ $? != 1 ]] && _fail "cloned device scan should fail"
55
56 [[ $(findmnt $mnt | grep -v TARGET | awk '{print $2}') != $device_1 ]] && \
57                                                 _fail "mounted device changed"
58
59 # Original device scan should be successful
60 $BTRFS_UTIL_PROG device scan $device_1 >> $seqres.full 2>&1
61 [[ $? != 0 ]] && \
62         _fail "if it fails here, then it means subvolume mount at boot may fail "\
63               "in some configs."
64
65 $UMOUNT_PROG $mnt > /dev/null 2>&1
66 _scratch_dev_pool_put
67
68 # success, all done
69 echo "Silence is golden"
70 status=0
71 exit