overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / generic / 228
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2010 IBM Corporation. All Rights Reserved.
4 #
5 # FS QA Test No. 228
6 #
7 # Check if fallocate respects RLIMIT_FSIZE
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 _cleanup()
14 {
15         cd /
16         rm -f $tmp.*
17         sysctl -w kernel.core_pattern="$core_pattern" &>/dev/null
18         ulimit -c $ulimit_c
19 }
20
21 here=`pwd`
22 tmp=$TEST_DIR/$$
23 status=1        # failure is the default!
24 trap "_cleanup; exit \$status" 0 1 2 3 15 25
25
26 # get standard environment, filters and checks
27 . ./common/rc
28
29 # real QA test starts here
30 # generic, but xfs_io's fallocate must work
31 _supported_fs generic
32 # only Linux supports fallocate
33 _supported_os Linux
34 _require_test
35
36 [ -n "$XFS_IO_PROG" ] || _notrun "xfs_io executable not found"
37
38 rm -f $seqres.full
39
40 # Sanity check to see if fallocate works
41 _require_xfs_io_command "falloc"
42
43 # Check if we have good enough space available
44 avail=`df -P $TEST_DIR | awk 'END {print $4}'`
45 [ "$avail" -ge 104000 ] || _notrun "Test device is too small ($avail KiB)"
46
47 # Suppress core dumped messages
48 core_pattern=`sysctl -n kernel.core_pattern`
49 ulimit_c=`ulimit -c`
50 sysctl -w kernel.core_pattern=core &>/dev/null
51 ulimit -c 0
52
53 # Set the FSIZE ulimit to 100MB and check
54 ulimit -f 102400
55 flim=`ulimit -f`
56 [ "$flim" != "unlimited" ] || _notrun "Unable to set FSIZE ulimit"
57 [ "$flim" -eq 102400 ] || _notrun "FSIZE ulimit is not correct (100 MB)"
58
59 echo "File size limit is now set to 100 MB."
60 echo "Let us try to preallocate 101 MB. This should fail."
61 $XFS_IO_PROG -f -c 'falloc 0 101m' $TEST_DIR/ouch
62 rm -f $TEST_DIR/ouch
63
64 echo "Let us now try to preallocate 50 MB. This should succeed."
65 $XFS_IO_PROG -f -c 'falloc 0 50m' $TEST_DIR/ouch
66 rm -f $TEST_DIR/ouch
67
68 echo "Test over."
69 # success, all done
70 status=0
71 exit