2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Fusion IO. All Rights Reserved.
5 # FS QA Test No. btrfs/019
7 # btrfs send ENOENT regression test, kernel bugzilla 60673
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 tmp_dir=send_temp_$seq
17 status=1 # failure is the default!
21 $BTRFS_UTIL_PROG subvolume delete $TEST_DIR/$tmp_dir/snap1 > /dev/null 2>&1
22 $BTRFS_UTIL_PROG subvolume delete $TEST_DIR/$tmp_dir/snap2 > /dev/null 2>&1
23 $BTRFS_UTIL_PROG subvolume delete $TEST_DIR/$tmp_dir/send > /dev/null 2>&1
24 rm -rf $TEST_DIR/$tmp_dir
28 trap "_cleanup ; exit \$status" 0 1 2 3 15
30 # get standard environment, filters and checks
34 # real QA test starts here
40 _scratch_mkfs > /dev/null 2>&1
42 #receive needs to be able to setxattrs, including the selinux context, if we use
43 #the normal nfs context thing it screws up our ability to set the
44 #security.selinux xattrs so we need to disable this for this test
45 export SELINUX_MOUNT_OPTIONS=""
49 mkdir $TEST_DIR/$tmp_dir
50 $BTRFS_UTIL_PROG subvolume create $TEST_DIR/$tmp_dir/send \
51 > $seqres.full 2>&1 || _fail "failed subvolume create"
53 SEND_TEST_DIR=$TEST_DIR/$tmp_dir/send
55 mkdir $SEND_TEST_DIR/test
56 touch $SEND_TEST_DIR/test/baz
57 touch $SEND_TEST_DIR/test/blah
58 mkdir $SEND_TEST_DIR/test/foo
59 touch $SEND_TEST_DIR/test/foo/bar
61 $BTRFS_UTIL_PROG subvolume snapshot -r $TEST_DIR/$tmp_dir/send \
62 $TEST_DIR/$tmp_dir/snap1 >> $seqres.full 2>&1 || _fail "failed snap1"
64 $BTRFS_UTIL_PROG send -f $TEST_DIR/$tmp_dir/send1.dump \
65 $TEST_DIR/$tmp_dir/snap1 >> $seqres.full 2>&1 || _fail "failed send"
67 $BTRFS_UTIL_PROG receive -f $TEST_DIR/$tmp_dir/send1.dump $SCRATCH_MNT \
68 >> $seqres.full 2>&1 || _fail "failed receive"
70 #recreate everything exactly the way it was exceptn in a different order so we
71 #get different inode numbers
72 rm -rf $SEND_TEST_DIR/test
73 mkdir $SEND_TEST_DIR/test
74 touch $SEND_TEST_DIR/test/baz
75 mkdir $SEND_TEST_DIR/test/foo
76 touch $SEND_TEST_DIR/test/foo/bar
77 touch $SEND_TEST_DIR/test/blah
79 $BTRFS_UTIL_PROG subvolume snapshot -r $TEST_DIR/$tmp_dir/send \
80 $TEST_DIR/$tmp_dir/snap2 >> $seqres.full 2>&1 || _fail "failed snap2"
82 $BTRFS_UTIL_PROG send -f $TEST_DIR/$tmp_dir/send2.dump \
83 -p $TEST_DIR/$tmp_dir/snap1 $TEST_DIR/$tmp_dir/snap2 \
84 >> $seqres.full 2>&1 || _fail "failed second send"
86 $BTRFS_UTIL_PROG receive -f $TEST_DIR/$tmp_dir/send2.dump $SCRATCH_MNT \
87 >> $seqres.full 2>&1 || _fail "failed second receive"
89 echo "Silence is golden"