Whamcloud - gitweb
ATM-1754 tests: skip f_large_dir on RHEL6
[tools/e2fsprogs.git] / tests / f_large_dir / script
1 OUT=$test_name.log
2 EXP=$test_dir/expect
3 E2FSCK=../e2fsck/e2fsck
4
5 # skip this test on aarch64 builders because it is extremely slow
6 if [ "`uname -m`" = "aarch64" ]; then
7         echo "$test_name: $test_description: skipped (slow on aarch64)"
8         return 0
9 fi
10
11 if grep -q 'release 6' /etc/redhat-release 2> /dev/null; then
12         echo "$test_name: $test_description: skipped (slow on EL6)"
13         return 0
14 fi
15
16 NAMELEN=255
17 DIRENT_SZ=8
18 BLOCKSZ=1024
19 INODESZ=128
20 DIRENT_PER_LEAF=$((BLOCKSZ / (NAMELEN + DIRENT_SZ)))
21 HEADER=32
22 INDEX_SZ=8
23 INDEX_L1=$(((BLOCKSZ - HEADER) / INDEX_SZ))
24 INDEX_L2=$(((BLOCKSZ - DIRENT_SZ) / INDEX_SZ))
25 DIRBLK=$((2 + INDEX_L1 * INDEX_L2))
26 ENTRIES=$((DIRBLK * DIRENT_PER_LEAF))
27 EXT4_LINK_MAX=65000
28 if [ $ENTRIES -lt $((EXT4_LINK_MAX + 10)) ]; then
29         ENTRIES=$((EXT4_LINK_MAX + 10))
30         DIRBLK=$((ENTRIES / DIRENT_PER_LEAF + 3))
31 fi
32 # directory leaf blocks plus inode count and 25% for the rest of the fs
33 FSIZE=$(((DIRBLK + EXT4_LINK_MAX * ((BLOCKSZ + INODESZ) / BLOCKSZ)) * 5 / 4))
34
35 $MKE2FS -b 1024 -O large_dir,uninit_bg -N $((ENTRIES + 50)) \
36         -I $INODESZ -F $TMPFILE $FSIZE > $OUT.new 2>&1
37 RC=$?
38 if [ $RC -eq 0 ]; then
39 {
40         # First some initial fs setup to create indexed dir
41         echo "mkdir /foo"
42         echo "cd /foo"
43         touch $TMPFILE.tmp
44         echo "write $TMPFILE.tmp foofile"
45         i=0
46         while test $i -lt $DIRENT_PER_LEAF ; do
47                 printf "mkdir d%0254u\n" $i
48                 i=$((i + 1));
49         done
50         echo "expand ./"
51         printf "mkdir d%0254u\n" $i
52 } | $DEBUGFS -w $TMPFILE > /dev/null 2>> $OUT.new
53         RC=$?
54         # e2fsck should optimize the dir to become indexed
55         $E2FSCK -yfD $TMPFILE >> $OUT.new 2>&1
56         status=$?
57         echo Exit status is $status >> $OUT.new
58 fi
59
60 if [ $RC -eq 0 ]; then
61 {
62         START=$SECONDS
63         i=$(($DIRENT_PER_LEAF+1))
64         last=$i
65         echo "cd /foo"
66         while test $i -lt $ENTRIES ; do
67             ELAPSED=$((SECONDS - START))
68             if test $((i % 5000)) -eq 0 -a $ELAPSED -gt 10; then
69                 RATE=$(((i - last) / ELAPSED))
70                 echo "$test_name: $i/$ENTRIES links, ${ELAPSED}s @ $RATE/s" >&2
71                 START=$SECONDS
72                 last=$i
73             fi
74             if test $i -lt $((EXT4_LINK_MAX + 10)); then
75                 printf "mkdir d%0254u\n" $i
76             else
77                 printf "ln foofile f%0254u\n" $i
78             fi
79             i=$((i + 1))
80         done
81 } | $DEBUGFS -w $TMPFILE > /dev/null 2>> $OUT.new
82         RC=$?
83 fi
84
85 if [ $RC -eq 0 ]; then
86         $E2FSCK -yfD $TMPFILE >> $OUT.new 2>&1
87         status=$?
88         echo Exit status is $status >> $OUT.new
89         sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new > $OUT
90         rm -f $OUT.new
91
92         cmp -s $OUT $EXP
93         RC=$?
94 fi
95 if [ $RC -eq 0 ]; then
96         echo "$test_name: $test_description: ok"
97         touch $test_name.ok
98 else
99         echo "$test_name: $test_description: failed"
100         diff -u $EXP $OUT > $test_name.failed
101 fi