09f2f011bc77097830ad3b0fe6eb5e92ed6e167a
[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=`mktemp -d`
20 status=1
21
22 _cleanup()
23 {
24         echo "*** unmount"
25         _scratch_unmount 2>/dev/null
26         rm -f $tmp.*
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 rm -f $seqres.full
42
43 workout()
44 {
45         fsz=$1
46         ops=$2
47
48         _scratch_unmount >/dev/null 2>&1
49         echo "*** mkfs -dsize=$fsz"    >>$seqres.full
50         echo ""                                     >>$seqres.full
51         _scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
52                 || _fail "size=$fsz mkfs failed"
53         _scratch_mount "-o noatime"
54
55         run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n $ops $FSSTRESS_AVOID -x \
56                 "$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/base"
57
58         _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/incr
59
60         echo "# $BTRFS_UTIL_PROG send $SCRATCH_MNT/base > $tmp/base.snap" \
61                 >> $seqres.full
62         $BTRFS_UTIL_PROG send $SCRATCH_MNT/base > $tmp/base.snap 2>> $seqres.full \
63                 || _fail "failed: '$@'"
64         echo "# $BTRFS_UTIL_PROG send -p $SCRATCH_MNT/base\
65                 $SCRATCH_MNT/incr > $tmp/incr.snap" >> $seqres.full
66         $BTRFS_UTIL_PROG send -p $SCRATCH_MNT/base \
67                 $SCRATCH_MNT/incr > $tmp/incr.snap 2>> $seqres.full \
68                 || _fail "failed: '$@'"
69
70         run_check $FSSUM_PROG -A -f -w $tmp/base.fssum $SCRATCH_MNT/base
71         run_check $FSSUM_PROG -A -f -w $tmp/incr.fssum -x $SCRATCH_MNT/incr/base \
72                 $SCRATCH_MNT/incr
73
74         _scratch_unmount >/dev/null 2>&1
75         echo "*** mkfs -dsize=$fsz"    >>$seqres.full
76         echo ""                                     >>$seqres.full
77         _scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
78                 || _fail "size=$fsz mkfs failed"
79         _scratch_mount "-o noatime"
80
81         _run_btrfs_util_prog receive $SCRATCH_MNT < $tmp/base.snap
82         run_check $FSSUM_PROG -r $tmp/base.fssum $SCRATCH_MNT/base
83
84         _run_btrfs_util_prog receive $SCRATCH_MNT < $tmp/incr.snap
85         run_check $FSSUM_PROG -r $tmp/incr.fssum $SCRATCH_MNT/incr
86 }
87
88 echo "*** test send / receive"
89
90 fssize=`expr 2000 \* 1024 \* 1024`
91 ops=200
92
93 workout $fssize $ops
94
95 echo "*** done"
96 status=0
97 exit