misc: move exit status into trap handler
[xfstests-dev.git] / tests / xfs / 209
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 209
6 #
7 # Make sure setting cowextsz on a directory propagates it to subfiles.
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 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20     cd /
21     rm -rf $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/reflink
28
29 # real QA test starts here
30 _supported_fs xfs
31 _require_scratch_reflink
32 _require_cp_reflink
33 _require_xfs_io_command "fiemap"
34 _require_xfs_io_command "cowextsize"
35
36 rm -f $seqres.full
37
38 echo "Format and mount"
39 _scratch_mkfs > $seqres.full 2>&1
40 _scratch_mount >> $seqres.full 2>&1
41
42 testdir=$SCRATCH_MNT/test-$seq
43 mkdir $testdir
44
45 echo "Set extsz and cowextsz on directory"
46 $XFS_IO_PROG -c "cowextsize 1048576" $testdir >> $seqres.full
47
48 echo "Create a fake tree structure"
49 seq 1 2 | while read nr; do
50         mkdir "$testdir/dir-$nr"
51         seq 1 4 | while read nnr; do
52                 touch "$testdir/dir-$nr/file-$nnr"
53         done
54 done
55 _scratch_cycle_mount
56
57 echo "Check cowextsize settings"
58 seq 1 2 | while read nr; do
59         seq 1 4 | while read nnr; do
60                 file="$testdir/dir-$nr/file-$nnr"
61                 $XFS_IO_PROG -c "cowextsize" $file | _filter_scratch
62         done
63 done
64
65 # success, all done
66 status=0
67 exit