btrfs: convert tests to SPDX license tags
[xfstests-dev.git] / tests / btrfs / 025
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/025
6 #
7 # Test for an issue in btrfs send where it sent clone operations to user
8 # space with a range (offset + length) that was not aligned with the block
9 # size. This caused the btrfs receive command to send such clone operations
10 # to the ioctl clone API, which would return -EINVAL errors to btrfs receive,
11 # causing the receive command to abort immediately.
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 tmp=`mktemp -d`
18
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24     rm -fr $tmp
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # real QA test starts here
32 _supported_fs btrfs
33 _supported_os Linux
34 _require_scratch
35
36 rm -f $seqres.full
37
38 _scratch_mkfs >/dev/null 2>&1
39 _scratch_mount
40
41 run_check $XFS_IO_PROG -f -c "truncate 819200" $SCRATCH_MNT/foo
42 _run_btrfs_util_prog filesystem sync $SCRATCH_MNT
43
44 run_check $XFS_IO_PROG -c "falloc -k 819200 667648" $SCRATCH_MNT/foo
45 _run_btrfs_util_prog filesystem sync $SCRATCH_MNT
46
47 run_check $XFS_IO_PROG -c "pwrite 1482752 2978" $SCRATCH_MNT/foo
48 _run_btrfs_util_prog filesystem sync $SCRATCH_MNT
49
50 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT \
51     $SCRATCH_MNT/mysnap1
52
53 run_check $XFS_IO_PROG -c "truncate 883305" $SCRATCH_MNT/foo
54 _run_btrfs_util_prog filesystem sync $SCRATCH_MNT
55
56 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT \
57     $SCRATCH_MNT/mysnap2
58
59 _run_btrfs_util_prog send -f $tmp/1.snap $SCRATCH_MNT/mysnap1
60 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $tmp/2.snap \
61     $SCRATCH_MNT/mysnap2 2>&1
62
63 md5sum $SCRATCH_MNT/foo | _filter_scratch
64 md5sum $SCRATCH_MNT/mysnap1/foo | _filter_scratch
65 md5sum $SCRATCH_MNT/mysnap2/foo | _filter_scratch
66
67 _scratch_unmount
68 _check_btrfs_filesystem $SCRATCH_DEV
69 _scratch_mkfs >/dev/null 2>&1
70 _scratch_mount
71
72 _run_btrfs_util_prog receive -f $tmp/1.snap $SCRATCH_MNT
73 md5sum $SCRATCH_MNT/mysnap1/foo | _filter_scratch
74
75 _run_btrfs_util_prog receive -f $tmp/2.snap $SCRATCH_MNT
76 md5sum $SCRATCH_MNT/mysnap2/foo | _filter_scratch
77
78 _scratch_unmount
79 _check_btrfs_filesystem $SCRATCH_DEV
80
81 status=0
82 exit