X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=util-linux%2Fmkfs_ext2_test.sh;h=f5347cc04dd0b2168081f08e323ca9133fd0cbce;hb=52a515d18724bbb34e3ccbbb0218efcc4eccc0a8;hp=1199852fa8142b841814dfccebfb0069b1202152;hpb=cbeb4528247cca8eb1aa6c5d7e43778ea6de1762;p=oweals%2Fbusybox.git diff --git a/util-linux/mkfs_ext2_test.sh b/util-linux/mkfs_ext2_test.sh index 1199852fa..f5347cc04 100755 --- a/util-linux/mkfs_ext2_test.sh +++ b/util-linux/mkfs_ext2_test.sh @@ -1,6 +1,10 @@ #!/bin/sh -run_test() { # params: mke2fs_invocation image_name +# Disabling features we do not match exactly: +system_mke2fs='/sbin/mke2fs -O ^resize_inode' +bbox_mke2fs='./busybox mke2fs' + +gen_image() { # params: mke2fs_invocation image_name >$2 dd seek=$((kilobytes-1)) bs=1K count=1 /dev/null 2>&1 || exit 1 $1 -F $2 $kilobytes >$2.raw_out 2>&1 || return 1 @@ -11,7 +15,6 @@ run_test() { # params: mke2fs_invocation image_name | grep -v '^Writing superblocks and filesystem accounting information' \ | grep -v '^This filesystem will be automatically checked every' \ | grep -v '^180 days, whichever comes first' \ - | sed 's/inodes, [0-9]* blocks/inodes, N blocks/' \ | sed 's/blocks* unused./blocks unused/' \ | sed 's/block groups*/block groups/' \ | sed 's/ *$//' \ @@ -23,63 +26,79 @@ run_test() { # params: mke2fs_invocation image_name test_mke2fs() { echo Testing $kilobytes - run_test '/sbin/mke2fs' image_std || return 1 - run_test './busybox mke2fs' image_bb || return 1 + gen_image "$system_mke2fs" image_std || return 1 + gen_image "$bbox_mke2fs" image_bb || return 1 diff -ua image_bb.out image_std.out >image.out.diff || { cat image.out.diff return 1 } - e2fsck -f -n image_bb >/dev/null 2>&1 || { + e2fsck -f -n image_bb >image_bb_e2fsck.out 2>&1 || { echo "e2fsck error on image_bb" - e2fsck -f -n image_bb + cat image_bb_e2fsck.out exit 1 } } +# -:bbox +:standard + # kilobytes=60 is the minimal allowed size kilobytes=60 while true; do - test_mke2fs #|| exit 1 + test_mke2fs || exit 1 : $((kilobytes++)) test $kilobytes = 200 && break done -exit - -# Specific sizes with known differences: -# -:bbox +:standard -# -6240 inodes, 24908 blocks -# +6240 inodes, 24577 blocks -# -4 block group -# +3 block group -# -1560 inodes per group -# +2080 inodes per group -kilobytes=24908 test_mke2fs +# Transition from one block group to two +# fails in [8378..8410] range unless -O ^resize_inode +kilobytes=$((1 * 8*1024 - 50)) +while true; do + test_mke2fs || exit 1 + : $((kilobytes++)) + test $kilobytes = $((1 * 8*1024 + 300)) && break +done -# -304 inodes, N blocks -# +152 inodes, N blocks -# -304 inodes per group -# +152 inodes per group -kilobytes=1218 test_mke2fs +# Transition from 2 block groups to 3 +# works +kilobytes=$((2 * 8*1024 - 50)) +while true; do + test_mke2fs || exit 1 + : $((kilobytes++)) + test $kilobytes = $((2 * 8*1024 + 400)) && break +done -# -14464 inodes, N blocks -# +14448 inodes, N blocks -# -8 block group -# +7 block group -# -1808 inodes per group -# +2064 inodes per group -kilobytes=57696 test_mke2fs +# Transition from 3 block groups to 4 +# fails in [24825..24922] range unless -O ^resize_inode +kilobytes=$((3 * 8*1024 - 50)) +while true; do + test_mke2fs || exit 1 + : $((kilobytes++)) + test $kilobytes = $((3 * 8*1024 + 500)) && break +done -# -warning: 239 blocks unused. -# +warning: 242 blocks unused. -kilobytes=49395 test_mke2fs +# Transition from 4 block groups to 5 +# works +kilobytes=$((4 * 8*1024 - 50)) +while true; do + test_mke2fs || exit 1 + : $((kilobytes++)) + test $kilobytes = $((4 * 8*1024 + 600)) && break +done -## This size results in "warning: 75 blocks unused" -#kilobytes=98380 test_mke2fs +# Transition from 5 block groups to 6 +# fails in [41230..41391] range unless -O ^resize_inode +kilobytes=$((5 * 8*1024 - 50)) +while true; do + test_mke2fs || exit 1 + : $((kilobytes++)) + test $kilobytes = $((5 * 8*1024 + 700)) && break +done +exit +# Random sizes while true; do - kilobytes=$(( (RANDOM*RANDOM) % 1000000 + 60)) + kilobytes=$(( (RANDOM*RANDOM) % 5000000 + 60)) test_mke2fs || exit 1 done