fstests: move test group info to test files
[xfstests-dev.git] / tests / btrfs / 072
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2014 Red Hat Inc. All rights reserved.
4 #
5 # FSQA Test No. btrfs/072
6 #
7 # Run btrfs scrub and defrag operations simultaneously with fsstress
8 # running in background.
9 #
10 . ./common/preamble
11 _begin_fstest auto scrub defrag compress
12
13 # Import common functions.
14 . ./common/filter
15
16 # real QA test starts here
17 _supported_fs btrfs
18 # we check scratch dev after each loop
19 _require_scratch_nocheck
20 _require_scratch_dev_pool 4
21 _btrfs_get_profile_configs
22
23 run_test()
24 {
25         local mkfs_opts=$1
26         local with_compress=$2
27
28         echo "Test $mkfs_opts with $with_compress" >>$seqres.full
29
30         _scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
31         # make sure we created btrfs with desired options
32         if [ $? -ne 0 ]; then
33                 echo "mkfs $mkfs_opts failed"
34                 return
35         fi
36         _scratch_mount >>$seqres.full 2>&1
37
38         args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
39         echo "Run fsstress $args" >>$seqres.full
40         $FSSTRESS_PROG $args >/dev/null 2>&1 &
41         fsstress_pid=$!
42
43         echo -n "Start scrub worker: " >>$seqres.full
44         _btrfs_stress_scrub $SCRATCH_MNT >/dev/null 2>&1 &
45         scrub_pid=$!
46         echo "$scrub_pid" >>$seqres.full
47
48         echo -n "Start defrag worker: " >>$seqres.full
49         _btrfs_stress_defrag $SCRATCH_MNT $with_compress >/dev/null 2>&1 &
50         defrag_pid=$!
51         echo "$defrag_pid" >>$seqres.full
52
53         echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
54         wait $fsstress_pid
55         kill $scrub_pid $defrag_pid
56         wait
57         # wait for the scrub and defrag operations to finish
58         while ps aux | grep "scrub start" | grep -qv grep; do
59                 sleep 1
60         done
61         while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
62                 sleep 1
63         done
64
65         echo "Scrub the filesystem" >>$seqres.full
66         $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
67         if [ $? -ne 0 ]; then
68                 echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
69         fi
70
71         _scratch_unmount
72         # we called _require_scratch_nocheck instead of _require_scratch
73         # do check after test for each profile config
74         _check_scratch_fs
75 }
76
77 echo "Silence is golden"
78 for t in "${_btrfs_profile_configs[@]}"; do
79         run_test "$t" nocompress
80         run_test "$t" compress
81 done
82
83 status=0
84 exit