btrfs/057: Fix false alerts due to orphan files
[xfstests-dev.git] / tests / btrfs / 036
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Fujitsu.  All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/036
6 #
7 # Regression test for running snapshots and send concurrently.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 snapshots_pid=0
17
18 _cleanup()
19 {
20         # kill backgroud snapshots
21         if [ $snapshots_pid -ne 0 ] && ps -p $snapshots_pid | grep -q $snapshots_pid; then
22                 kill -TERM $snapshots_pid 2> /dev/null
23         fi
24         rm -f $tmp.*
25 }
26
27 do_snapshots()
28 {
29         i=2
30         while [ 1 ]
31         do
32                 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT/snap_1 \
33                         $SCRATCH_MNT/snap_$i >> $seqres.full 2>&1
34                 let i=$i+1
35                 sleep 1
36         done
37 }
38
39 trap "_cleanup ; exit \$status" 0 1 2 3 15
40
41 # get standard environment, filters and checks
42 . ./common/rc
43 . ./common/filter
44
45 # real QA test starts here
46 _supported_fs btrfs
47 _supported_os Linux
48 _require_scratch
49
50 _scratch_mkfs > /dev/null 2>&1
51 _scratch_mount
52
53 touch $SCRATCH_MNT/foo
54
55 # get file with fragments by using backwards writes.
56 for i in `seq 10240 -1 1`; do
57         $XFS_IO_PROG -f -d -c "pwrite $(($i * 4096)) 4096" \
58                 $SCRATCH_MNT/foo > /dev/null | _filter_xfs_io
59 done
60
61 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
62         $SCRATCH_MNT/snap_1 >> $seqres.full 2>&1
63
64 do_snapshots &
65 snapshots_pid=$!
66
67 $BTRFS_UTIL_PROG send -f /dev/null $SCRATCH_MNT/snap_1 2>&1 | _filter_scratch
68
69 status=0 ; exit