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
39 _scratch_mkfs > /dev/null 2>&1
41 #receive needs to be able to setxattrs, including the selinux context, if we use
42 #the normal nfs context thing it screws up our ability to set the
43 #security.selinux xattrs so we need to disable this for this test
44 export SELINUX_MOUNT_OPTIONS=""
48 mkdir $TEST_DIR/$tmp_dir
49 $BTRFS_UTIL_PROG subvolume create $TEST_DIR/$tmp_dir/send \
50 > $seqres.full 2>&1 || _fail "failed subvolume create"
52 SEND_TEST_DIR=$TEST_DIR/$tmp_dir/send
54 mkdir $SEND_TEST_DIR/test
55 touch $SEND_TEST_DIR/test/baz
56 touch $SEND_TEST_DIR/test/blah
57 mkdir $SEND_TEST_DIR/test/foo
58 touch $SEND_TEST_DIR/test/foo/bar
60 $BTRFS_UTIL_PROG subvolume snapshot -r $TEST_DIR/$tmp_dir/send \
61 $TEST_DIR/$tmp_dir/snap1 >> $seqres.full 2>&1 || _fail "failed snap1"
63 $BTRFS_UTIL_PROG send -f $TEST_DIR/$tmp_dir/send1.dump \
64 $TEST_DIR/$tmp_dir/snap1 >> $seqres.full 2>&1 || _fail "failed send"
66 $BTRFS_UTIL_PROG receive -f $TEST_DIR/$tmp_dir/send1.dump $SCRATCH_MNT \
67 >> $seqres.full 2>&1 || _fail "failed receive"
69 #recreate everything exactly the way it was exceptn in a different order so we
70 #get different inode numbers
71 rm -rf $SEND_TEST_DIR/test
72 mkdir $SEND_TEST_DIR/test
73 touch $SEND_TEST_DIR/test/baz
74 mkdir $SEND_TEST_DIR/test/foo
75 touch $SEND_TEST_DIR/test/foo/bar
76 touch $SEND_TEST_DIR/test/blah
78 $BTRFS_UTIL_PROG subvolume snapshot -r $TEST_DIR/$tmp_dir/send \
79 $TEST_DIR/$tmp_dir/snap2 >> $seqres.full 2>&1 || _fail "failed snap2"
81 $BTRFS_UTIL_PROG send -f $TEST_DIR/$tmp_dir/send2.dump \
82 -p $TEST_DIR/$tmp_dir/snap1 $TEST_DIR/$tmp_dir/snap2 \
83 >> $seqres.full 2>&1 || _fail "failed second send"
85 $BTRFS_UTIL_PROG receive -f $TEST_DIR/$tmp_dir/send2.dump $SCRATCH_MNT \
86 >> $seqres.full 2>&1 || _fail "failed second receive"
88 echo "Silence is golden"