misc: move exit status into trap handler
[xfstests-dev.git] / tests / btrfs / 024
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Fujitsu.  All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/024
6 #
7 # btrfs wrong compression type regression test. This test is used to check
8 # the oops will happen when the users write some data into the files whose
9 # compress flag is set but the compression of the fs is disabled.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17
18 status=1        # failure is the default!
19
20 _cleanup()
21 {
22         rm -f $tmp.*
23 }
24
25 trap "_cleanup ; exit \$status" 0 1 2 3 15
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # real QA test starts here
32 _supported_fs btrfs
33 _require_scratch
34
35 __workout()
36 {
37         work_file="$SCRATCH_MNT/tmpfile"
38
39         touch $work_file
40         $CHATTR_PROG =c $work_file
41         $XFS_IO_PROG -f -c "pwrite 0 1M" -c "fsync" $work_file | _filter_xfs_io
42 }
43
44 echo "*** test compress=no"
45 _scratch_mkfs > /dev/null 2>&1
46 _scratch_mount "-o compress=no"
47 __workout
48 _scratch_unmount
49 _check_scratch_fs
50
51 echo "*** test compress-force=no"
52 _scratch_mkfs > /dev/null 2>&1
53 _scratch_mount "-o compress-force=no"
54 __workout
55 _scratch_unmount
56
57 echo "*** done"
58 status=0 ; exit