common/rc: Add _require_{chown,chmod}()
[xfstests-dev.git] / tests / generic / 371
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Fujitsu.  All Rights Reserved.
4 #
5 # FS QA Test 371
6 #
7 # Run write(2) and fallocate(2) in parallel and the total needed data space
8 # for these operations don't exceed whole fs free data space, to see whether
9 # we will get any unexpected ENOSPC error.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # remove previous $seqres.full before test
31 rm -f $seqres.full
32
33 # Modify as appropriate.
34 _supported_fs generic
35 _require_scratch
36 _require_xfs_io_command "falloc"
37
38 _scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
39 _scratch_mount
40
41 testfile1=$SCRATCH_MNT/testfile1
42 testfile2=$SCRATCH_MNT/testfile2
43
44 echo "Silence is golden"
45 for ((i=0; i<100; i++)); do
46         $XFS_IO_PROG -fc "pwrite 0 80M" $testfile1 >/dev/null
47         rm -f $testfile1
48 done &
49 pids=$!
50
51 for ((i=0; i<100; i++)); do
52         $XFS_IO_PROG -fc "falloc 0 80M" $testfile2 >/dev/null
53         rm -f $testfile2
54 done &
55 pids="$pids $!"
56
57 wait $pids
58 status=0
59 exit