438f2f27a8fc4e5c95c14a52c4667574f8431573
[xfstests-dev.git] / tests / btrfs / 007
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2013 STRATO.  All rights reserved.
4 #
5 # FSQA Test No. 007
6 #
7 # Run fsstress to create a reasonably strange file system, make a
8 # snapshot (base) and run more fsstress. Then take another snapshot
9 # (incr) and send both snapshots to a temp file. Remake the file
10 # system and receive from the files. Check both states with fssum.
11 #
12 # creator
13 owner=list.btrfs@jan-o-sch.net
14
15 seq=`basename $0`
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
18
19 tmp=/tmp/$$
20 status=1
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.*
26         rm -fr $send_files_dir
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_scratch
38 _require_fssum
39 _require_seek_data_hole
40
41 send_files_dir=$TEST_DIR/btrfs-test-$seq
42
43 rm -f $seqres.full
44 rm -fr $send_files_dir
45 mkdir $send_files_dir
46
47 workout()
48 {
49         fsz=$1
50         ops=$2
51
52         _scratch_unmount >/dev/null 2>&1
53         echo "*** mkfs -dsize=$fsz"    >>$seqres.full
54         echo ""                                     >>$seqres.full
55         _scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
56                 || _fail "size=$fsz mkfs failed"
57         _scratch_mount "-o noatime"
58
59         run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n $ops $FSSTRESS_AVOID -x \
60                 "$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/base"
61
62         _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/incr
63
64         echo "# $BTRFS_UTIL_PROG send $SCRATCH_MNT/base > ${send_files_dir}/base.snap" \
65                 >> $seqres.full
66         $BTRFS_UTIL_PROG send $SCRATCH_MNT/base > $send_files_dir/base.snap 2>> $seqres.full \
67                 || _fail "failed: '$@'"
68         echo "# $BTRFS_UTIL_PROG send -p $SCRATCH_MNT/base\
69                 $SCRATCH_MNT/incr > ${send_files_dir}/incr.snap" >> $seqres.full
70         $BTRFS_UTIL_PROG send -p $SCRATCH_MNT/base \
71                 $SCRATCH_MNT/incr > $send_files_dir/incr.snap 2>> $seqres.full \
72                 || _fail "failed: '$@'"
73
74         run_check $FSSUM_PROG -A -f -w $send_files_dir/base.fssum \
75                 $SCRATCH_MNT/base
76         run_check $FSSUM_PROG -A -f -w $send_files_dir/incr.fssum \
77                 -x $SCRATCH_MNT/incr/base $SCRATCH_MNT/incr
78
79         _scratch_unmount >/dev/null 2>&1
80         echo "*** mkfs -dsize=$fsz"    >>$seqres.full
81         echo ""                                     >>$seqres.full
82         _scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
83                 || _fail "size=$fsz mkfs failed"
84         _scratch_mount "-o noatime"
85
86         _run_btrfs_util_prog receive $SCRATCH_MNT < $send_files_dir/base.snap
87         run_check $FSSUM_PROG -r $send_files_dir/base.fssum $SCRATCH_MNT/base
88
89         _run_btrfs_util_prog receive $SCRATCH_MNT < $send_files_dir/incr.snap
90         run_check $FSSUM_PROG -r $send_files_dir/incr.fssum $SCRATCH_MNT/incr
91 }
92
93 echo "*** test send / receive"
94
95 fssize=`expr 2000 \* 1024 \* 1024`
96 ops=200
97
98 workout $fssize $ops
99
100 echo "*** done"
101 status=0
102 exit