xfs: fix old fuzz test invocations of xfs_repair
[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 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 mnt=$TEST_DIR/$seq.mnt
21 _cleanup()
22 {
23         rm -rf $mnt > /dev/null 2>&1
24         cd /
25         rm -f $tmp.*
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31
32 # remove previous $seqres.full before test
33 rm -f $seqres.full
34
35 # real QA test starts here
36 _supported_fs btrfs
37 _require_scratch_dev_pool 2
38 _scratch_dev_pool_get 2
39
40 device_1=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
41 device_2=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
42
43 echo device_1=$device_1 device_2=$device_2 >> $seqres.full
44
45 rm -rf $mnt > /dev/null 2>&1
46 mkdir $mnt
47 _mkfs_dev $device_1
48 _mount $device_1 $mnt
49
50 [[ $(findmnt $mnt | grep -v TARGET | awk '{print $2}') != $device_1 ]] && \
51                                                 _fail "mounted device changed"
52
53 for sb_bytenr in 65536 67108864; do
54         echo -n "dd status=none if=$dev_foo of=$dev_bar bs=1 "\
55                 "seek=$sb_bytenr skip=$sb_bytenr count=4096" >> $seqres.full
56         dd status=none if=$device_1 of=$device_2 bs=1 seek=$sb_bytenr \
57                                 skip=$sb_bytenr count=4096 > /dev/null 2>&1
58         echo ..:$? >> $seqres.full
59 done
60
61 # Original device is mounted, scan of its clone should fail
62 $BTRFS_UTIL_PROG device scan $device_2 >> $seqres.full 2>&1
63 [[ $? != 1 ]] && _fail "cloned device scan should fail"
64
65 [[ $(findmnt $mnt | grep -v TARGET | awk '{print $2}') != $device_1 ]] && \
66                                                 _fail "mounted device changed"
67
68 # Original device scan should be successful
69 $BTRFS_UTIL_PROG device scan $device_1 >> $seqres.full 2>&1
70 [[ $? != 0 ]] && \
71         _fail "if it fails here, then it means subvolume mount at boot may fail "\
72               "in some configs."
73
74 $UMOUNT_PROG $mnt > /dev/null 2>&1
75 _scratch_dev_pool_put
76
77 # success, all done
78 echo "Silence is golden"
79 status=0
80 exit