btrfs: add test for btrfs send with long paths
[xfstests-dev.git] / tests / btrfs / 051
1 #! /bin/bash
2 # FS QA Test No. btrfs/051
3 #
4 # Regression test for btrfs send where long paths (exceeding 230 characters)
5 # made send produce paths with random characters from a memory buffer returned
6 # by kmalloc, as send forgot to populate the new buffer with the path string.
7 #
8 # This issue is fixed by the following linux kernel btrfs patch:
9 #
10 #   Btrfs: send, fix corrupted path strings for long paths
11 #
12 #-----------------------------------------------------------------------
13 # Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
14 #
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
18 #
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
27 #-----------------------------------------------------------------------
28 #
29
30 seq=`basename $0`
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
33
34 tmp=/tmp/$$
35 status=1        # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
37
38 _cleanup()
39 {
40     rm -fr $send_files_dir
41     rm -fr $tmp
42 }
43
44 # get standard environment, filters and checks
45 . ./common/rc
46 . ./common/filter
47
48 # real QA test starts here
49 _supported_fs btrfs
50 _supported_os Linux
51 _require_scratch
52 _require_fssum
53 _need_to_be_root
54
55 send_files_dir=$TEST_DIR/btrfs-test-$seq
56
57 rm -f $seqres.full
58 rm -fr $send_files_dir
59 mkdir $send_files_dir
60
61 _scratch_mkfs >/dev/null 2>&1
62 _scratch_mount
63
64 TEST_PATH="$SCRATCH_MNT/fdmanana/.config/google-chrome-mysetup/Default/Pepper_Data/Shockwave_Flash/WritableRoot/#SharedObjects/JSHJ4ZKN/s.wsj.net/[[IMPORT]]/players.edgesuite.net/flash/plugins/osmf/advanced-streaming-plugin/v2.7/osmf1.6/Ak#"
65
66 mkdir -p $TEST_PATH
67 echo "hello world" > $TEST_PATH/amaiAdvancedStreamingPlugin.txt
68
69 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
70 run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
71 _run_btrfs_util_prog send $SCRATCH_MNT/mysnap1 -f $send_files_dir/1.snap
72
73 _scratch_unmount
74 _check_scratch_fs
75
76 _scratch_mkfs >/dev/null 2>&1
77 _scratch_mount
78
79 _run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/1.snap
80 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
81
82 _check_scratch_fs
83
84 status=0
85 exit