common: Check fs consistency on TEST_DEV only when needed
[xfstests-dev.git] / tests / btrfs / 019
1 #! /bin/bash
2 # FS QA Test No. btrfs/019
3 #
4 # btrfs send ENOENT regression test, kernel bugzilla 60673
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2013 Fusion IO.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 tmp_dir=send_temp_$seq
32
33 status=1        # failure is the default!
34
35 _cleanup()
36 {
37         $BTRFS_UTIL_PROG subvolume delete $TEST_DIR/$tmp_dir/snap1 > /dev/null 2>&1
38         $BTRFS_UTIL_PROG subvolume delete $TEST_DIR/$tmp_dir/snap2 > /dev/null 2>&1
39         $BTRFS_UTIL_PROG subvolume delete $TEST_DIR/$tmp_dir/send > /dev/null 2>&1
40         rm -rf $TEST_DIR/$tmp_dir
41         rm -f $tmp.*
42 }
43
44 trap "_cleanup ; exit \$status" 0 1 2 3 15
45
46 # get standard environment, filters and checks
47 . ./common/rc
48 . ./common/filter
49
50 # real QA test starts here
51 _supported_fs btrfs
52 _supported_os Linux
53 _require_test
54 _require_scratch
55
56 _scratch_mkfs > /dev/null 2>&1
57
58 #receive needs to be able to setxattrs, including the selinux context, if we use
59 #the normal nfs context thing it screws up our ability to set the
60 #security.selinux xattrs so we need to disable this for this test
61 export SELINUX_MOUNT_OPTIONS=""
62
63 _scratch_mount
64
65 mkdir $TEST_DIR/$tmp_dir
66 $BTRFS_UTIL_PROG subvolume create $TEST_DIR/$tmp_dir/send \
67         > $seqres.full 2>&1 || _fail "failed subvolume create"
68
69 SEND_TEST_DIR=$TEST_DIR/$tmp_dir/send
70
71 mkdir $SEND_TEST_DIR/test
72 touch $SEND_TEST_DIR/test/baz
73 touch $SEND_TEST_DIR/test/blah
74 mkdir $SEND_TEST_DIR/test/foo
75 touch $SEND_TEST_DIR/test/foo/bar
76
77 $BTRFS_UTIL_PROG subvolume snapshot -r $TEST_DIR/$tmp_dir/send \
78         $TEST_DIR/$tmp_dir/snap1 >> $seqres.full 2>&1 || _fail "failed snap1"
79
80 $BTRFS_UTIL_PROG send -f $TEST_DIR/$tmp_dir/send1.dump \
81         $TEST_DIR/$tmp_dir/snap1 >> $seqres.full 2>&1 || _fail "failed send"
82
83 $BTRFS_UTIL_PROG receive -f $TEST_DIR/$tmp_dir/send1.dump $SCRATCH_MNT \
84         >> $seqres.full 2>&1 || _fail "failed receive"
85
86 #recreate everything exactly the way it was exceptn in a different order so we
87 #get different inode numbers
88 rm -rf $SEND_TEST_DIR/test
89 mkdir $SEND_TEST_DIR/test
90 touch $SEND_TEST_DIR/test/baz
91 mkdir $SEND_TEST_DIR/test/foo
92 touch $SEND_TEST_DIR/test/foo/bar
93 touch $SEND_TEST_DIR/test/blah
94
95 $BTRFS_UTIL_PROG subvolume snapshot -r $TEST_DIR/$tmp_dir/send \
96         $TEST_DIR/$tmp_dir/snap2 >> $seqres.full 2>&1 || _fail "failed snap2"
97
98 $BTRFS_UTIL_PROG send -f $TEST_DIR/$tmp_dir/send2.dump \
99         $TEST_DIR/$tmp_dir/snap2 -p $TEST_DIR/$tmp_dir/snap1 \
100         >> $seqres.full 2>&1 || _fail "failed second send"
101
102 $BTRFS_UTIL_PROG receive -f $TEST_DIR/$tmp_dir/send2.dump $SCRATCH_MNT \
103         >> $seqres.full 2>&1 || _fail "failed second receive"
104
105 echo "Silence is golden"
106 status=0 ; exit