generic: add test for boundary in xfs_attr_shortform_verify
[xfstests-dev.git] / tests / generic / 324
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. generic/324
6 #
7 # Sanity check for defrag utility.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 PIDS=""
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         rm -f $tmp.*
21 }
22
23 # get standard environment, filters and checks
24 . ./common/rc
25 . ./common/filter
26 . ./common/defrag
27
28 # real QA test starts here
29 _supported_os Linux
30 _require_scratch
31 _require_defrag
32 _require_xfs_io_command "falloc"
33
34 rm -f $seqres.full
35
36 _workout()
37 {
38         nr=$1
39         echo "Defragment file with $nr * 2 fragments"
40         # Create sparse file
41         for ((i=0;i<nr;i++))
42         do
43                 $XFS_IO_PROG -f -c "falloc $((409600*i)) 4k"  \
44                         $SCRATCH_MNT/test.$nr >> $seqres.full 2>&1
45         done
46         # Fill holes for half of range , as result file will contain nr*1.5 fragments
47         $XFS_IO_PROG -c "falloc 0 $((204800*nr))"  \
48             $SCRATCH_MNT/test.$nr | _filter_xfs_io
49         # Data wrilte will convert extetns to inialized ones
50         for ((i=0;i<nr;i++))
51         do
52                 patt=`printf "0x%x" $i`
53                 $XFS_IO_PROG -c "pwrite -S $patt $((i*123400)) 1234" \
54                         $SCRATCH_MNT/test.$nr | _filter_xfs_io
55         done
56         _defrag --min_before $nr --max_before $((nr*4)) \
57                 --min_after 1 $SCRATCH_MNT/test.$nr
58 }
59
60
61 # Actual testing starting from here
62 _scratch_mkfs  >> $seqres.full 2>&1
63 _scratch_mount
64 _workout 10
65 _workout 250
66 _workout 1000
67 status=0