fstests: convert remaining tests to SPDX license tags
[xfstests-dev.git] / tests / xfs / 062
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 062
6 #
7 # Use the bstat utility to verify bulkstat finds all inodes in a filesystem.
8 # Test under various inode counts, inobt record layouts and bulkstat batch
9 # sizes.
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 # print the number of inodes counted by bulkstat
27 _bstat_count()
28 {
29         batchsize=$1
30         ./src/bstat $SCRATCH_MNT $batchsize | grep ino | wc -l
31 }
32
33 # print bulkstat counts using varied batch sizes
34 _bstat_test()
35 {
36         expect=`find $SCRATCH_MNT -print | wc -l`
37         echo "expect $expect"
38
39         _bstat_count 4096
40         _bstat_count 32
41         _bstat_count 1
42 }
43
44 # get standard environment, filters and checks
45 . ./common/rc
46 . ./common/filter
47
48 _require_scratch
49
50 # real QA test starts here
51
52 _supported_fs xfs
53 _supported_os Linux
54
55 rm -f $seqres.full
56
57 DIRCOUNT=8
58 INOCOUNT=$((2048 / DIRCOUNT))
59
60 _scratch_mkfs "-d agcount=$DIRCOUNT" >> $seqres.full 2>&1 || _fail "mkfs failed"
61 _scratch_mount
62
63 # create a set of directories and fill each with a fixed number of files
64 for dir in $(seq 1 $DIRCOUNT); do
65         mkdir -p $SCRATCH_MNT/$dir
66         for i in $(seq 1 $INOCOUNT); do
67                 touch $SCRATCH_MNT/$dir/$i
68         done
69 done
70 _bstat_test
71
72 # remove every other file from each dir
73 for dir in $(seq 1 $DIRCOUNT); do
74         for i in $(seq 2 2 $INOCOUNT); do
75                 rm -f $SCRATCH_MNT/$dir/$i
76         done
77 done
78 _bstat_test
79
80 # remove the entire second half of files
81 for dir in $(seq 1 $DIRCOUNT); do
82         for i in $(seq $((INOCOUNT / 2)) $INOCOUNT); do
83                 rm -f $SCRATCH_MNT/$dir/$i
84         done
85 done
86 _bstat_test
87
88 # remove all regular files
89 for dir in $(seq 1 $DIRCOUNT); do
90         rm -f $SCRATCH_MNT/$dir/*
91 done
92 _bstat_test
93
94 # success, all done
95 status=0
96 exit