xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / generic / 275
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2011-2012 Fujitsu, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 275
6 #
7 # The posix write test.  When write size is larger than disk free size,
8 # should write as much as possible until ENOSPC.
9 #
10 #creator
11
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1    # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         _scratch_unmount
25 }
26
27 . ./common/rc
28 . ./common/filter
29
30 # real QA test starts here
31 _supported_fs generic
32 _require_scratch
33
34 echo "------------------------------"
35 echo "write until ENOSPC test"
36 echo "------------------------------"
37
38 rm -f $seqres.full
39
40 _scratch_unmount 2>/dev/null
41 _scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1
42 _scratch_mount
43
44 # this file will get removed to create 256k of free space after ENOSPC
45 # conditions are created.
46 dd if=/dev/zero of=$SCRATCH_MNT/tmp1 bs=256K count=1 >>$seqres.full 2>&1
47 [ $? -ne 0 ] && _fail "Error creating file"
48
49 # Attempt to completely fill fs
50 dd if=/dev/zero of=$SCRATCH_MNT/tmp2 bs=1M >>$seqres.full 2>&1
51 sync
52 dd if=/dev/zero of=$SCRATCH_MNT/tmp3 bs=4K >>$seqres.full 2>&1
53 sync
54 # Last effort, use O_SYNC
55 dd if=/dev/zero of=$SCRATCH_MNT/tmp4 bs=4K oflag=sync >>$seqres.full 2>&1
56 # Save space usage info to the full file
57 echo "Pre rm space:" >> $seqres.full
58 $DF_PROG $SCRATCH_MNT >>$seqres.full 2>&1
59
60 # Should leave approx 256k free
61 rm -f $SCRATCH_MNT/tmp1
62 sync
63 echo "Post rm space:" >> $seqres.full
64 $DF_PROG $SCRATCH_MNT >>$seqres.full 2>&1
65 _freespace=`$DF_PROG -k $SCRATCH_MNT | tail -n 1 | awk '{print $5}'`
66 [ $_freespace -gt 1024 ] && _fail "could not sufficiently fill filesystem"
67
68 # Try to write more than available space in chunks that will allow at least one
69 # full write to succeed.
70 dd if=/dev/zero of=$SCRATCH_MNT/tmp1 bs=128k count=8 >>$seqres.full 2>&1
71 echo "Bytes written until ENOSPC:" >>$seqres.full
72 du $SCRATCH_MNT/tmp1 >>$seqres.full
73
74 # And at least some of it should succeed.
75 _filesize=`_get_filesize $SCRATCH_MNT/tmp1`
76 [ $_filesize -lt $((128 * 1024)) ] && \
77         _fail "Partial write until enospc failed; wrote $_filesize bytes."
78
79 echo "done"
80 status=0
81 exit