check: use generated group files
[xfstests-dev.git] / tests / ext4 / 045
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. 045
6 #
7 # Test subdirectory limit of ext4.
8 # We create more than 65000 subdirectories on the ext4 filesystem.
9 #
10 . ./common/preamble
11 _begin_fstest auto dir
12
13 SHORT_DIR=1
14 LONG_DIR=2
15
16 # Import common functions.
17 . ./common/filter
18
19 # real QA test starts here
20 _supported_fs ext4
21
22 _require_scratch
23 _require_test_program "t_create_short_dirs"
24 _require_test_program "t_create_long_dirs"
25 _require_dumpe2fs "$DUMPE2FS_PROG" dumpe2fs
26
27 echo "Silence is golden"
28
29 # Run a test case
30 # $1: Number of directories to create
31 # $2: create short dir or long dir
32 # $3: parent directory
33 workout()
34 {
35        local dir_name_len=""
36        if [ $2 -eq $SHORT_DIR ]; then
37                dir_name_len="short name"
38        else
39                dir_name_len="long name"
40        fi
41
42        echo "Num of dirs to create: $1, Dir name len: $dir_name_len, " \
43                "Parent dir: $3" >> $seqres.full
44
45        _scratch_mkfs "-O extent,dir_nlink,dir_index -I 256" >> $seqres.full 2>&1
46        _scratch_mount
47
48        # create directories
49        mkdir -p $3 2> /dev/null
50
51        if [ $2 -eq $SHORT_DIR ]; then
52                $here/src/t_create_short_dirs $1 $3
53        else
54                $here/src/t_create_long_dirs $1 $3
55        fi
56
57        if [ $? -ne 0 ]; then
58                nr_dirs=`ls $3 | wc -l`
59                echo "Failed to create directories - $nr_dirs"
60                _scratch_unmount
61                return
62        fi
63
64        # delete directories
65        cd $3
66        ls | xargs rmdir
67        if [ $? -ne 0 ]; then
68                echo "Failed to remove directories in $3"
69                cd - > /dev/null
70                _scratch_unmount
71                return
72        fi
73        cd - > /dev/null
74        _scratch_unmount
75
76        # check dir_nlink is set
77        $DUMPE2FS_PROG -h $SCRATCH_DEV 2>> $seqres.full | grep '^Filesystem features' | grep -q dir_nlink
78        if [ $? -ne 0 ]; then
79                echo "Feature dir_nlink is not set, please check $seqres.full for detail"
80                return
81        fi
82 }
83
84 # main
85 DIR_NUM=65537
86 DIR_LEN=( $SHORT_DIR $LONG_DIR )
87 PARENT_DIR="$SCRATCH_MNT/subdir"
88
89 for ((i = 0; i < 2; i++)); do
90        workout $DIR_NUM ${DIR_LEN[$i]} $PARENT_DIR
91 done
92
93 status=0
94 exit