fsx/fsstress: round blocksize properly
[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 _require_test
34
35 [ -n "$XFS_IO_PROG" ] || _notrun "xfs_io executable not found"
36
37 rm -f $seqres.full
38
39 # Sanity check to see if fallocate works
40 _require_xfs_io_command "falloc"
41
42 # Check if we have good enough space available
43 avail=`df -P $TEST_DIR | awk 'END {print $4}'`
44 [ "$avail" -ge 104000 ] || _notrun "Test device is too small ($avail KiB)"
45
46 # Suppress core dumped messages
47 core_pattern=`sysctl -n kernel.core_pattern`
48 ulimit_c=`ulimit -c`
49 sysctl -w kernel.core_pattern=core &>/dev/null
50 ulimit -c 0
51
52 # Set the FSIZE ulimit to 100MB and check
53 ulimit -f 102400
54 flim=`ulimit -f`
55 [ "$flim" != "unlimited" ] || _notrun "Unable to set FSIZE ulimit"
56 [ "$flim" -eq 102400 ] || _notrun "FSIZE ulimit is not correct (100 MB)"
57
58 echo "File size limit is now set to 100 MB."
59 echo "Let us try to preallocate 101 MB. This should fail."
60 $XFS_IO_PROG -f -c 'falloc 0 101m' $TEST_DIR/ouch
61 rm -f $TEST_DIR/ouch
62
63 echo "Let us now try to preallocate 50 MB. This should succeed."
64 $XFS_IO_PROG -f -c 'falloc 0 50m' $TEST_DIR/ouch
65 rm -f $TEST_DIR/ouch
66
67 echo "Test over."
68 # success, all done
69 status=0
70 exit