overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / generic / 425
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 425
6 #
7 # Check that FIEMAP produces some output when we require an external
8 # block to hold extended attributes.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 7 15
18
19 _cleanup()
20 {
21         cd /
22         rm -rf $tmp.*
23         wait
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/attr
30
31 # real QA test starts here
32 _supported_os Linux
33 _supported_fs generic
34 _require_scratch
35 _require_attrs
36 _require_xfs_io_command "fiemap" "-a"
37
38 echo "Format and mount"
39 _scratch_mkfs > $seqres.full 2>&1
40 _scratch_mount >> $seqres.full 2>&1
41
42 testdir=$SCRATCH_MNT/test-$seq
43 mkdir $testdir
44
45 echo "Create the original files"
46 testfile=$testdir/attrfile
47 touch $testfile
48 blk_sz=$(_get_file_block_size $SCRATCH_MNT)
49
50 # Assume each attr eats at least 20 bytes.  Try to fill 2 fs blocks.
51 max_attrs=$((2 * blk_sz / 20))
52
53 i=0
54 while [ $i -lt $max_attrs ]; do
55         n="$(printf "%010d" $i)"
56         $SETFATTR_PROG -n "user.$n" -v "$n" $testfile > $seqres.full 2>&1 || break
57         i=$((i + 1))
58 done
59 sync
60
61 echo "Check attr extent counts"
62 f1=$(_count_attr_extents $testfile)
63 echo "$f1 xattr extents" >> $seqres.full
64 $XFS_IO_PROG -c 'fiemap -a -v' $testfile >> $seqres.full
65 test $f1 -gt 0 || echo "Expected at least one xattr extent."
66
67 _scratch_cycle_mount
68
69 echo "Check attr extent counts after remount"
70 f1=$(_count_attr_extents $testfile)
71 echo "$f1 xattr extents" >> $seqres.full
72 $XFS_IO_PROG -c 'fiemap -a -v' $testfile >> $seqres.full
73 test $f1 -gt 0 || echo "Expected at least one xattr extent."
74
75 # success, all done
76 status=0
77 exit