xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / btrfs / 144
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2017 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/144
6 #
7 # Test that an incremental send operation works correctly when an inode A is
8 # renamed, a new hard link added to it and some other inode B is renamed to
9 # the old name of inode A.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -fr $send_files_dir
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # real QA test starts here
31 _supported_fs btrfs
32 _require_test
33 _require_scratch
34 _require_fssum
35
36 send_files_dir=$TEST_DIR/btrfs-test-$seq
37
38 rm -f $seqres.full
39 rm -fr $send_files_dir
40 mkdir $send_files_dir
41
42 _scratch_mkfs >>$seqres.full 2>&1
43 _scratch_mount
44
45 touch $SCRATCH_MNT/f1
46 touch $SCRATCH_MNT/f2
47 touch $SCRATCH_MNT/f3
48
49 # Filesystem looks like:
50 #
51 # .                                                             (ino 256)
52 # |
53 # |--- f1                                                       (ino 257)
54 # |--- f2                                                       (ino 258)
55 # |--- f3                                                       (ino 259)
56 #
57 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
58         $SCRATCH_MNT/mysnap1 > /dev/null
59
60 $BTRFS_UTIL_PROG send -f $send_files_dir/1.snap \
61         $SCRATCH_MNT/mysnap1 2>&1 1>/dev/null | _filter_scratch
62
63 mv $SCRATCH_MNT/f3 $SCRATCH_MNT/f4
64 ln $SCRATCH_MNT/f2 $SCRATCH_MNT/f5
65 mv $SCRATCH_MNT/f2 $SCRATCH_MNT/f3
66 mv $SCRATCH_MNT/f1 $SCRATCH_MNT/f2
67
68 # Filesystem now looks like:
69 #
70 # .                                                             (ino 256)
71 # |
72 # |--- f2                                                       (ino 257)
73 # |--- f3                                                       (ino 258)
74 # |--- f4                                                       (ino 259)
75 # |--- f5                                                       (ino 258)
76 #
77
78 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
79                  $SCRATCH_MNT/mysnap2 > /dev/null
80
81 $BTRFS_UTIL_PROG send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
82                  $SCRATCH_MNT/mysnap2 2>&1 1>/dev/null | _filter_scratch
83
84 $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
85 $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
86         -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
87
88 # Now recreate the filesystem by receiving both send streams and verify we get
89 # the same content that the original filesystem had.
90 _scratch_unmount
91 _scratch_mkfs >>$seqres.full 2>&1
92 _scratch_mount
93
94 $BTRFS_UTIL_PROG receive -f $send_files_dir/1.snap $SCRATCH_MNT > /dev/null
95 $BTRFS_UTIL_PROG receive -f $send_files_dir/2.snap $SCRATCH_MNT > /dev/null
96 $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
97 $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
98
99 status=0
100 exit