3 run_test() { # params: mke2fs_invocation image_name
5 dd seek=$((kilobytes-1)) bs=1K count=1 </dev/zero of=$2 >/dev/null 2>&1 || exit 1
6 $1 -F $2 $kilobytes >$2.raw_out 2>&1 || return 1
8 | grep -v '^mke2fs [0-9]*\.[0-9]*\.[0-9]* ' \
9 | grep -v '^Maximum filesystem' \
10 | grep -v '^Writing inode tables' \
11 | grep -v '^Writing superblocks and filesystem accounting information' \
12 | grep -v '^This filesystem will be automatically checked every' \
13 | grep -v '^180 days, whichever comes first' \
14 | sed 's/inodes, [0-9]* blocks/inodes, N blocks/' \
15 | sed 's/blocks* unused./blocks unused/' \
16 | sed 's/block groups*/block groups/' \
18 | sed 's/blocks (.*%) reserved/blocks reserved/' \
24 echo Testing $kilobytes
26 run_test '/sbin/mke2fs' image_std || return 1
27 run_test './busybox mke2fs' image_bb || return 1
29 diff -ua image_bb.out image_std.out >image.out.diff || {
34 e2fsck -f -n image_bb >/dev/null 2>&1 || {
35 echo "e2fsck error on image_bb"
41 # kilobytes=60 is the minimal allowed size
44 test_mke2fs #|| exit 1
46 test $kilobytes = 200 && break
50 # Specific sizes with known differences:
53 # -6240 inodes, 24908 blocks
54 # +6240 inodes, 24577 blocks
57 # -1560 inodes per group
58 # +2080 inodes per group
59 kilobytes=24908 test_mke2fs
61 # -304 inodes, N blocks
62 # +152 inodes, N blocks
63 # -304 inodes per group
64 # +152 inodes per group
65 kilobytes=1218 test_mke2fs
67 # -14464 inodes, N blocks
68 # +14448 inodes, N blocks
71 # -1808 inodes per group
72 # +2064 inodes per group
73 kilobytes=57696 test_mke2fs
75 # -warning: 239 blocks unused.
76 # +warning: 242 blocks unused.
77 kilobytes=49395 test_mke2fs
79 ## This size results in "warning: 75 blocks unused"
80 #kilobytes=98380 test_mke2fs
83 kilobytes=$(( (RANDOM*RANDOM) % 1000000 + 60))