generic: test for non-zero used blocks while writing into a file
[xfstests-dev.git] / tests / btrfs / 195
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test btrfs/195
6 #
7 # Test raid profile conversion. It's sufficient to test all dest profiles as
8 # source profiles just rely on being able to read the data and metadata.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # remove previous $seqres.full before test
30 rm -f $seqres.full
31
32 # real QA test starts here
33
34 # Modify as appropriate.
35 _supported_fs btrfs
36 _require_scratch_dev_pool 4
37
38
39 declare -a TEST_VECTORS=(
40 # $nr_dev_min:$data:$metadata:$data_convert:$metadata_convert
41 "4:single:raid1"
42 "4:single:raid0"
43 "4:single:raid10"
44 "4:single:dup"
45 "4:single:raid5"
46 "4:single:raid6"
47 "2:raid1:single"
48 )
49
50 run_testcase() {
51         IFS=':' read -ra args <<< $1
52         num_disks=${args[0]}
53         src_type=${args[1]}
54         dst_type=${args[2]}
55
56         _scratch_dev_pool_get $num_disks
57
58         echo "=== Running test: $1 ===" >> $seqres.full
59
60         _scratch_pool_mkfs -d$src_type >> $seqres.full 2>&1
61         _scratch_mount
62
63         # Create random filesystem with 20k write ops
64         $FSSTRESS_PROG -d $SCRATCH_MNT -w -n 10000 $FSSTRESS_AVOID >>$seqres.full 2>&1
65
66         _run_btrfs_balance_start -f -dconvert=$dst_type $SCRATCH_MNT >> $seqres.full
67         [ $? -eq 0 ] || echo "$1: Failed convert"
68
69         $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
70         [ $? -eq 0 ] || echo "$1: Scrub failed"
71
72         _scratch_unmount
73         _check_btrfs_filesystem $SCRATCH_DEV
74         _scratch_dev_pool_put
75 }
76
77 for i in "${TEST_VECTORS[@]}"; do
78         run_testcase $i
79 done
80
81 echo "Silence is golden"
82 status=0
83 exit