adc3910b2505b6b4540e9bf89f8e967fb47c3c20
[xfstests-dev.git] / tests / btrfs / 016
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/016
6 #
7 # btrfs send hole punch test
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 tmp=`mktemp -d`
14 tmp_dir=send_temp_$seq
15
16 status=1        # failure is the default!
17
18 _cleanup()
19 {
20         $BTRFS_UTIL_PROG subvolume delete $TEST_DIR/$tmp_dir/snap > /dev/null 2>&1
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/send > /dev/null 2>&1
23         rm -rf $TEST_DIR/$tmp_dir
24         rm -f $tmp.*
25 }
26
27 trap "_cleanup ; exit \$status" 0 1 2 3 15
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32
33 # real QA test starts here
34 _supported_fs btrfs
35 _supported_os Linux
36 _require_test
37 _require_scratch
38 _require_fssum
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 subvolume create"
52
53 _ddt of=$TEST_DIR/$tmp_dir/send/foo bs=1M count=10 >> $seqres.full \
54         2>&1 || _fail "dd failed"
55 $BTRFS_UTIL_PROG subvolume snapshot -r $TEST_DIR/$tmp_dir/send \
56         $TEST_DIR/$tmp_dir/snap >> $seqres.full 2>&1 || _fail "failed snap"
57 $XFS_IO_PROG -c "fpunch 1m 1m" $TEST_DIR/$tmp_dir/send/foo
58 $BTRFS_UTIL_PROG subvolume snapshot -r $TEST_DIR/$tmp_dir/send \
59         $TEST_DIR/$tmp_dir/snap1 >> $seqres.full 2>&1 || _fail "failed snap"
60
61 $FSSUM_PROG -A -f -w $tmp/fssum.snap $TEST_DIR/$tmp_dir/snap >> $seqres.full \
62         2>&1 || _fail "fssum gen failed"
63 $FSSUM_PROG -A -f -w $tmp/fssum.snap1 $TEST_DIR/$tmp_dir/snap1 >> $seqres.full \
64         2>&1 || _fail "fssum gen failed"
65
66 $BTRFS_UTIL_PROG send -f $tmp/send.snap $TEST_DIR/$tmp_dir/snap >> \
67         $seqres.full 2>&1 || _fail "failed send"
68 $BTRFS_UTIL_PROG send -p $TEST_DIR/$tmp_dir/snap \
69         -f $tmp/send.snap1 $TEST_DIR/$tmp_dir/snap1 \
70         >> $seqres.full 2>&1 || _fail "failed send"
71
72 $BTRFS_UTIL_PROG receive -f $tmp/send.snap $SCRATCH_MNT >> $seqres.full 2>&1 \
73         || _fail "failed recv"
74 $BTRFS_UTIL_PROG receive -f $tmp/send.snap1 $SCRATCH_MNT >> $seqres.full 2>&1 \
75         || _fail "failed recv"
76
77 $FSSUM_PROG -r $tmp/fssum.snap $SCRATCH_MNT/snap >> $seqres.full 2>&1 \
78         || _fail "fssum failed"
79 $FSSUM_PROG -r $tmp/fssum.snap1 $SCRATCH_MNT/snap1 >> $seqres.full 2>&1 \
80         || _fail "fssum failed"
81
82 echo "Silence is golden"
83 status=0 ; exit