82d093aacd1369fa1089aec498e90d4dda27589b
[xfstests-dev.git] / tests / btrfs / 007
1 #! /bin/bash
2 # FSQA Test No. 007
3 #
4 # Run fsstress to create a reasonably strange file system, make a
5 # snapshot (base) and run more fsstress. Then take another snapshot
6 # (incr) and send both snapshots to a temp file. Remake the file
7 # system and receive from the files. Check both states with fssum.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (C) 2013 STRATO.  All rights reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #
25 #-----------------------------------------------------------------------
26 #
27 # creator
28 owner=list.btrfs@jan-o-sch.net
29
30 seq=`basename $0`
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
33
34 tmp=`mktemp -d`
35 status=1
36
37 _cleanup()
38 {
39         echo "*** unmount"
40         _scratch_unmount 2>/dev/null
41         rm -f $tmp.*
42 }
43 trap "_cleanup; exit \$status" 0 1 2 3 15
44
45 # get standard environment, filters and checks
46 . ./common/rc
47 . ./common/filter
48
49 # real QA test starts here
50 _need_to_be_root
51 _supported_fs btrfs
52 _supported_os Linux
53 _require_scratch
54 _require_fssum
55 _require_seek_data_hole
56
57 rm -f $seqres.full
58
59 workout()
60 {
61         fsz=$1
62         ops=$2
63
64         _scratch_unmount >/dev/null 2>&1
65         echo "*** mkfs -dsize=$fsz"    >>$seqres.full
66         echo ""                                     >>$seqres.full
67         _scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
68                 || _fail "size=$fsz mkfs failed"
69         run_check _scratch_mount "-o noatime"
70
71         run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n $ops $FSSTRESS_AVOID -x \
72                 "$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/base"
73
74         _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/incr
75
76         echo "# $BTRFS_UTIL_PROG send $SCRATCH_MNT/base > $tmp/base.snap" \
77                 >> $seqres.full
78         $BTRFS_UTIL_PROG send $SCRATCH_MNT/base > $tmp/base.snap 2>> $seqres.full \
79                 || _fail "failed: '$@'"
80         echo "# $BTRFS_UTIL_PROG send -p $SCRATCH_MNT/base\
81                 $SCRATCH_MNT/incr > $tmp/incr.snap" >> $seqres.full
82         $BTRFS_UTIL_PROG send -p $SCRATCH_MNT/base \
83                 $SCRATCH_MNT/incr > $tmp/incr.snap 2>> $seqres.full \
84                 || _fail "failed: '$@'"
85
86         run_check $FSSUM_PROG -A -f -w $tmp/base.fssum $SCRATCH_MNT/base
87         run_check $FSSUM_PROG -A -f -w $tmp/incr.fssum -x $SCRATCH_MNT/incr/base \
88                 $SCRATCH_MNT/incr
89
90         _scratch_unmount >/dev/null 2>&1
91         echo "*** mkfs -dsize=$fsz"    >>$seqres.full
92         echo ""                                     >>$seqres.full
93         _scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
94                 || _fail "size=$fsz mkfs failed"
95         run_check _scratch_mount "-o noatime"
96
97         _run_btrfs_util_prog receive $SCRATCH_MNT < $tmp/base.snap
98         run_check $FSSUM_PROG -r $tmp/base.fssum $SCRATCH_MNT/base
99
100         _run_btrfs_util_prog receive $SCRATCH_MNT < $tmp/incr.snap
101         run_check $FSSUM_PROG -r $tmp/incr.fssum $SCRATCH_MNT/incr
102 }
103
104 echo "*** test send / receive"
105
106 fssize=`expr 2000 \* 1024 \* 1024`
107 ops=200
108
109 workout $fssize $ops
110
111 echo "*** done"
112 status=0
113 exit