overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / xfs / 207
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 207
6 #
7 # Test setting the extsz and cowextsz hints:
8 # - Ensure that we can set both on a zero-byte file.
9 # - Ensure that we can set only cowextsz on a many-byte file.
10 # - Ensure that whatever we set we get back later.
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     rm -rf $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30 . ./common/reflink
31
32 # real QA test starts here
33 _supported_os Linux
34 _supported_fs xfs
35 _require_scratch_reflink
36 _require_cp_reflink
37 _require_xfs_io_command "fiemap"
38 _require_xfs_io_command "cowextsize"
39
40 # Takes the fsxattr.xflags line,
41 # i.e. fsxattr.xflags = 0x0 [--------------C-]
42 # and tests whether a flag character is set
43 test_xflag()
44 {
45     local flg=$1
46     grep -q "\[.*${flg}.*\]" && echo "$flg flag set" || echo "$flg flag unset"
47 }
48
49 rm -f $seqres.full
50
51 echo "Format and mount"
52 _scratch_mkfs > $seqres.full 2>&1
53 _scratch_mount >> $seqres.full 2>&1
54
55 testdir=$SCRATCH_MNT/test-$seq
56 mkdir $testdir
57
58 echo "Create the original files"
59 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 0" $testdir/file1 >> $seqres.full
60 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 1048576" $testdir/file2 >> $seqres.full
61 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 0" $testdir/file3 >> $seqres.full
62 _scratch_cycle_mount
63
64 echo "Set extsz and cowextsz on zero byte file"
65 $XFS_IO_PROG -c "extsize 1048576" $testdir/file1 | _filter_scratch
66 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file1 | _filter_scratch
67
68 echo "Set extsz and cowextsz on 1Mbyte file"
69 $XFS_IO_PROG -c "extsize 1048576" $testdir/file2 | _filter_scratch
70 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file2 | _filter_scratch
71 _scratch_cycle_mount
72
73 echo "Check extsz and cowextsz settings on zero byte file"
74 $XFS_IO_PROG -c "extsize" $testdir/file1 | _filter_scratch
75 $XFS_IO_PROG -c "cowextsize" $testdir/file1 | _filter_scratch
76
77 echo "Check extsz and cowextsz settings on 1Mbyte file"
78 $XFS_IO_PROG -c "extsize" $testdir/file2 | _filter_scratch
79 $XFS_IO_PROG -c "cowextsize" $testdir/file2 | _filter_scratch
80
81 echo "Set cowextsize and check flag"
82 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file3 | _filter_scratch
83 _scratch_cycle_mount
84
85 $XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags' | test_xflag "C"
86 $XFS_IO_PROG -c "cowextsize" $testdir/file3 | _filter_scratch
87
88 echo "Unset cowextsize and check flag"
89 $XFS_IO_PROG -c "cowextsize 0" $testdir/file3 | _filter_scratch
90 _scratch_cycle_mount
91
92 $XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags' | test_xflag "C"
93 $XFS_IO_PROG -c "cowextsize" $testdir/file3 | _filter_scratch
94
95 status=0
96 exit