xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / generic / 614
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. 614
6 #
7 # Test that after doing a memory mapped write to an empty file, a call to
8 # stat(2) reports a non-zero number of used blocks.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13 tmp=/tmp/$$
14 status=1        # failure is the default!
15 trap "_cleanup; exit \$status" 0 1 2 3 15
16
17 _cleanup()
18 {
19         cd /
20         rm -f $tmp.*
21 }
22
23 # get standard environment, filters and checks
24 . ./common/rc
25 . ./common/filter
26
27 # real QA test starts here
28 _supported_fs generic
29 _require_scratch
30
31 rm -f $seqres.full
32
33 _scratch_mkfs >>$seqres.full 2>&1
34 _scratch_mount
35
36 $XFS_IO_PROG -f -c "truncate 64K"      \
37              -c "mmap -w 0 64K"        \
38              -c "mwrite -S 0xab 0 64K" \
39              -c "munmap"               \
40              $SCRATCH_MNT/foobar | _filter_xfs_io
41
42 blocks_used=$(stat -c %b $SCRATCH_MNT/foobar)
43 if [ $blocks_used -eq 0 ]; then
44     echo "error: stat(2) reported 0 used blocks"
45 fi
46
47 echo "Silence is golden"
48
49 status=0
50 exit