generic/395: remove workarounds for wrong error codes
[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
36 _require_scratch
37 _require_no_large_scratch_dev
38
39 # btrfs needs at least 256MB (with upward round off) to create a non-mixed mode
40 # fs. Ref: btrfs-progs: btrfs_min_dev_size()
41 _scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 \
42     || _fail "mkfs failed"
43 _scratch_mount
44 out=$SCRATCH_MNT/fillup.$$
45 rm -f $seqres.full
46
47 free0=`_free`
48 if [ -z "$free0" ]
49 then
50     echo "   *** failed to get free space (0)"
51     exit 1
52 fi
53 echo "free space at start $free0" >> $seqres.full
54
55 echo "fill disk:"       # well, filesystem really - not disk
56
57 POSIXLY_CORRECT=yes dd if=/dev/zero of=$out bs=1024k 2>&1 | _filter_dd
58
59 echo "check free space:"
60
61 free1=`_free`
62 if [ -z "$free1" ]
63 then
64     echo "   *** failed to get free space (1)"
65     exit 1
66 fi
67 echo "free space after fill $free1" >> $seqres.full
68
69 if [ ! -e $out ]
70 then
71     echo "   *** file not created"
72     exit 1
73 fi
74
75 if [ ! -s $out ]
76 then
77     echo "   *** file created with zero length"
78     ls -l $out
79     exit 1
80 fi
81
82 echo "delete fill:"
83
84 if ! rm $out
85 then
86     echo "   *** file not deleted"
87     exit 1
88 fi
89
90 if [ -e $out ]
91 then
92     echo "   *** file still exists"
93     ls -l $out
94     exit 1
95 fi
96
97 echo "check free space:"
98
99 sync
100
101 free2=`_free`
102 if [ -z "$free2" ]
103 then
104     echo "   *** failed to get free space (2)"
105     exit 1
106 fi
107 echo "free space after delete $free2" >> $seqres.full
108
109 echo -n "   !!! "
110 _within_tolerance "free space" $free2 $free0 1% -v
111
112 status=0
113 exit