Whamcloud - gitweb
e2fsck: mark that we don't care about the return value of e2fsck_lookup()
[tools/e2fsprogs.git] / tests / f_large_dir_csum / script
1 OUT=$test_name.log
2 EXP=$test_dir/expect
3 E2FSCK=../e2fsck/e2fsck
4
5 NAMELEN=255
6 DIRENT_SZ=8
7 BLOCKSZ=1024
8 INODESZ=128
9 CSUM_SZ=8
10 CSUM_TAIL_SZ=12
11 DIRENT_PER_LEAF=$(((BLOCKSZ - CSUM_TAIL_SZ) / (NAMELEN + DIRENT_SZ)))
12 HEADER=32
13 INDEX_SZ=8
14 INDEX_L1=$(((BLOCKSZ - HEADER - CSUM_SZ) / INDEX_SZ))
15 INDEX_L2=$(((BLOCKSZ - DIRENT_SZ - CSUM_SZ) / INDEX_SZ))
16 DIRBLK=$((3 + INDEX_L1 * INDEX_L2))
17 ENTRIES=$((DIRBLK * DIRENT_PER_LEAF))
18 # directory leaf blocks - get twice as much because the leaves won't be full
19 # and there are also other filesystem blocks.
20 FSIZE=$((DIRBLK * 2))
21
22 $MKE2FS -b 1024 -O extents,64bit,large_dir,uninit_bg,metadata_csum -N 50 \
23         -I $INODESZ -F $TMPFILE $FSIZE > $OUT.new 2>&1
24 RC=$?
25 if [ $RC -eq 0 ]; then
26 {
27         # First some initial fs setup to create indexed dir
28         echo "mkdir /foo"
29         echo "cd /foo"
30         touch $TMPFILE.tmp
31         echo "write $TMPFILE.tmp foofile"
32         i=0
33         while test $i -lt $DIRENT_PER_LEAF ; do
34                 printf "ln foofile f%0254u\n" $i
35                 i=$((i + 1));
36         done
37         echo "expand ./"
38         printf "ln foofile f%0254u\n" $i
39 } | $DEBUGFS -w $TMPFILE > /dev/null 2>> $OUT.new
40         RC=$?
41         # e2fsck should optimize the dir to become indexed
42         $E2FSCK -yfD $TMPFILE >> $OUT.new 2>&1
43         status=$?
44         echo Exit status is $status >> $OUT.new
45 fi
46
47 if [ $RC -eq 0 ]; then
48 {
49         START=$SECONDS
50         i=$(($DIRENT_PER_LEAF+1))
51         last=$i
52         echo "cd /foo"
53         while test $i -lt $ENTRIES ; do
54             ELAPSED=$((SECONDS - START))
55             if test $((i % 5000)) -eq 0 -a $ELAPSED -gt 10; then
56                 RATE=$(((i - last) / ELAPSED))
57                 echo "$test_name: $i/$ENTRIES links, ${ELAPSED}s @ $RATE/s" >&2
58                 START=$SECONDS
59                 last=$i
60             fi
61             printf "ln foofile f%0254u\n" $i
62             i=$((i + 1))
63         done
64 } | $DEBUGFS -w $TMPFILE > /dev/null 2>> $OUT.new
65         RC=$?
66 fi
67
68 if [ $RC -eq 0 ]; then
69         $E2FSCK -yfD $TMPFILE >> $OUT.new 2>&1
70         status=$?
71         echo Exit status is $status >> $OUT.new
72         sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new > $OUT
73         rm -f $OUT.new
74
75         cmp -s $OUT $EXP
76         RC=$?
77 fi
78 if [ $RC -eq 0 ]; then
79         echo "$test_name: $test_description: ok"
80         touch $test_name.ok
81 else
82         echo "$test_name: $test_description: failed"
83         diff -u $EXP $OUT > $test_name.failed
84 fi