common/rc: Add _require_{chown,chmod}()
[xfstests-dev.git] / tests / generic / 394
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test 394
6 #
7 # Make sure fs honors file size resource limit.
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         ulimit -f unlimited
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 # need a wrapper function so "File size limit exceeded" message can be filtered
33 do_truncate()
34 {
35         $XFS_IO_PROG -fc "truncate $1" $2
36 }
37
38 # real QA test starts here
39 _supported_fs generic
40 _require_test
41
42 # set max file size to 1G (in block number of 1k blocks), so it should be big
43 # enough to let test run without bringing any trouble to test harness
44 ulimit -f $((1024 * 1024))
45 # default action to SIGXFSZ is coredump, limit core file size to 0 to avoid
46 # such core files after each test run
47 ulimit -c 0
48
49 # exercise file size limit boundaries
50 do_truncate $((1024 * 1024 * 1024 - 1)) $TEST_DIR/$seq.$$-1
51 do_truncate $((1024 * 1024 * 1024))     $TEST_DIR/$seq.$$
52 do_truncate $((1024 * 1024 * 1024 + 1)) $TEST_DIR/$seq.$$+1 2>&1 | \
53         grep -o "File size limit exceeded"
54
55 # success, all done
56 status=0
57 exit