fstests: convert remaining tests to SPDX license tags
[xfstests-dev.git] / tests / generic / 015
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 015
6 #
7 # check out-of-space behaviour
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        # success is the default!
16
17 # get standard environment, filters and checks
18 . ./common/rc
19 . ./common/filter
20
21 _cleanup()
22 {
23         _scratch_unmount
24 }
25
26 trap "_cleanup; exit \$status" 0 1 2 3 15
27
28 _free()
29 {
30     _df_dir $SCRATCH_MNT | $AWK_PROG '{ print $5 }'
31 }
32
33 # real QA test starts here
34 _supported_fs generic
35 _supported_os Linux
36
37 _require_scratch
38 _require_no_large_scratch_dev
39
40 # With filesystems less than 100mb btrfs is created in mixed mode
41 # which can lead to slight accounting errors of 1mb. Having the
42 # fs be at least 101 mb ensures those errors are within the error
43 # tolerance of 1%
44 _scratch_mkfs_sized `expr 101 \* 1024 \* 1024` >/dev/null 2>&1 \
45     || _fail "mkfs failed"
46 _scratch_mount
47 out=$SCRATCH_MNT/fillup.$$
48 rm -f $seqres.full
49
50 free0=`_free`
51 if [ -z "$free0" ]
52 then
53     echo "   *** failed to get free space (0)"
54     exit 1
55 fi
56 echo "free space at start $free0" >> $seqres.full
57
58 echo "fill disk:"       # well, filesystem really - not disk
59
60 POSIXLY_CORRECT=yes dd if=/dev/zero of=$out bs=1024k 2>&1 | _filter_dd
61
62 echo "check free space:"
63
64 free1=`_free`
65 if [ -z "$free1" ]
66 then
67     echo "   *** failed to get free space (1)"
68     exit 1
69 fi
70 echo "free space after fill $free1" >> $seqres.full
71
72 if [ ! -e $out ]
73 then
74     echo "   *** file not created"
75     exit 1
76 fi
77
78 if [ ! -s $out ]
79 then
80     echo "   *** file created with zero length"
81     ls -l $out
82     exit 1
83 fi
84
85 echo "delete fill:"
86
87 if ! rm $out
88 then
89     echo "   *** file not deleted"
90     exit 1
91 fi
92
93 if [ -e $out ]
94 then
95     echo "   *** file still exists"
96     ls -l $out
97     exit 1
98 fi
99
100 echo "check free space:"
101
102 sync
103
104 free2=`_free`
105 if [ -z "$free2" ]
106 then
107     echo "   *** failed to get free space (2)"
108     exit 1
109 fi
110 echo "free space after delete $free2" >> $seqres.full
111
112 echo -n "   !!! "
113 _within_tolerance "free space" $free2 $free0 1% -v
114
115 status=0
116 exit