btrfs: convert tests to SPDX license tags
[xfstests-dev.git] / tests / btrfs / 008
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Fusion IO.  All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/008
6 #
7 # btrfs send ENOENT regression test, from a user report on linux-btrfs
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 tmp_dir=send_temp_$seq
16
17 status=1        # failure is the default!
18
19 _cleanup()
20 {
21         $BTRFS_UTIL_PROG subvolume delete $TEST_DIR/$tmp_dir/send/snapshots/backup2 > /dev/null 2>&1
22         $BTRFS_UTIL_PROG subvolume delete $TEST_DIR/$tmp_dir/send/snapshots/backup3 > /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
25         rm -f $tmp.*
26 }
27
28 trap "_cleanup ; exit \$status" 0 1 2 3 15
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/filter
33
34 # real QA test starts here
35 _supported_fs btrfs
36 _supported_os Linux
37 _require_test
38 _require_scratch
39
40 _scratch_mkfs > /dev/null 2>&1
41
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=""
46
47 _scratch_mount
48
49 mkdir $TEST_DIR/$tmp_dir
50 $BTRFS_UTIL_PROG subvolume create $TEST_DIR/$tmp_dir/send \
51         > $seqres.full 2>&1 || _fail "failed subvol create"
52 work_dir="$TEST_DIR/$tmp_dir/send"
53 mkdir $work_dir/testdir
54 mkdir $work_dir/testdir/1/
55 mkdir $work_dir/testdir/2/
56 _ddt of=$work_dir/testdir/aa count=16 > /dev/null 2>&1
57 _ddt of=$work_dir/testdir/bb count=16 > /dev/null 2>&1
58
59 mkdir $work_dir/snapshots
60 $BTRFS_UTIL_PROG subvolume snapshot -r $work_dir $work_dir/snapshots/backup2 \
61         >> $seqres.full 2>&1 || _fail "failed backup2"
62 $BTRFS_UTIL_PROG subvolume snapshot -r $work_dir $work_dir/snapshots/backup3 \
63         >> $seqres.full 2>&1 || _fail "failed backup3"
64 $BTRFS_UTIL_PROG send -f $TEST_DIR/$tmp_dir/blah $work_dir/snapshots/backup3 \
65         >> $seqres.full 2>&1 || _fail "send failed"
66 $BTRFS_UTIL_PROG receive -vvvv -f $TEST_DIR/$tmp_dir/blah $SCRATCH_MNT \
67         >> $seqres.full 2>&1 || _fail "receive failed"
68
69 echo "Silence is golden"
70 status=0 ; exit