9fa36a613667f00d585d5654ecb542f40ec188de
[xfstests-dev.git] / tests / btrfs / 008
1 #! /bin/bash
2 # FS QA Test No. btrfs/008
3 #
4 # btrfs send ENOENT regression test, from a user report on linux-btrfs
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/send/snapshots/backup2 > /dev/null 2>&1
38         $BTRFS_UTIL_PROG subvolume delete $TEST_DIR/$tmp_dir/send/snapshots/backup3 > /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_scratch
54
55 _scratch_mkfs > /dev/null 2>&1
56
57 #receive needs to be able to setxattrs, including the selinux context, if we use
58 #the normal nfs context thing it screws up our ability to set the
59 #security.selinux xattrs so we need to disable this for this test
60 export SELINUX_MOUNT_OPTIONS=""
61
62 _scratch_mount
63
64 mkdir $TEST_DIR/$tmp_dir
65 $BTRFS_UTIL_PROG subvolume create $TEST_DIR/$tmp_dir/send \
66         > $seqres.full 2>&1 || _fail "failed subvol create"
67 work_dir="$TEST_DIR/$tmp_dir/send"
68 mkdir $work_dir/testdir
69 mkdir $work_dir/testdir/1/
70 mkdir $work_dir/testdir/2/
71 dd if=/dev/urandom  of=$work_dir/testdir/aa count=16 > /dev/null 2>&1
72 dd if=/dev/urandom  of=$work_dir/testdir/bb count=16 > /dev/null 2>&1
73
74 mkdir $work_dir/snapshots
75 $BTRFS_UTIL_PROG subvolume snapshot -r $work_dir $work_dir/snapshots/backup2 \
76         >> $seqres.full 2>&1 || _fail "failed backup2"
77 $BTRFS_UTIL_PROG subvolume snapshot -r $work_dir $work_dir/snapshots/backup3 \
78         >> $seqres.full 2>&1 || _fail "failed backup3"
79 $BTRFS_UTIL_PROG send $work_dir/snapshots/backup3/ -f $TEST_DIR/$tmp_dir/blah \
80         >> $seqres.full 2>&1 || _fail "send failed"
81 $BTRFS_UTIL_PROG receive $SCRATCH_MNT -vvvv -f $TEST_DIR/$tmp_dir/blah \
82         >> $seqres.full 2>&1 || _fail "receive failed"
83
84 echo "Silence is golden"
85 status=0 ; exit