misc: move exit status into trap handler
[xfstests-dev.git] / tests / btrfs / 207
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Facebook.  All Rights Reserved.
4 #
5 # FS QA Test 207
6 #
7 # Test large DIO reads and writes with various profiles. Regression test for
8 # patch "btrfs: fix RAID direct I/O reads with alternate csums".
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 _supported_fs btrfs
33 # we check scratch dev after each loop
34 _require_scratch_nocheck
35 _require_scratch_dev_pool 4
36 _btrfs_get_profile_configs
37
38 for mkfs_opts in "${_btrfs_profile_configs[@]}"; do
39         echo "Test $mkfs_opts" >>$seqres.full
40         _scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
41         _scratch_mount >>$seqres.full 2>&1
42
43         dd if=/dev/urandom of="$SCRATCH_MNT/$seq" \
44                 bs=1M count=64 conv=fsync status=none
45         dd if="$SCRATCH_MNT/$seq" of="$SCRATCH_MNT/$seq.dioread" \
46                 bs=1M iflag=direct status=none
47         dd if="$SCRATCH_MNT/$seq" of="$SCRATCH_MNT/$seq.diowrite" \
48                 bs=1M oflag=direct status=none
49         diff -q "$SCRATCH_MNT/$seq" "$SCRATCH_MNT/$seq.dioread" |
50                 tee -a $seqres.full
51         diff -q "$SCRATCH_MNT/$seq" "$SCRATCH_MNT/$seq.diowrite" |
52                 tee -a $seqres.full
53
54         _scratch_unmount
55         _check_scratch_fs
56 done
57
58 echo "Silence is golden"
59
60 status=0
61 exit