Denys Vlasenko | e840561 | 2009-10-18 20:57:52 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Denys Vlasenko | 1d6e447 | 2009-10-21 14:14:51 +0200 | [diff] [blame] | 3 | # Disabling features we do not match exactly: |
Denys Vlasenko | 149a32a | 2009-10-22 12:12:17 +0200 | [diff] [blame] | 4 | system_mke2fs='/sbin/mke2fs -O ^resize_inode' |
Denys Vlasenko | 82d6433 | 2009-10-20 17:04:55 +0200 | [diff] [blame] | 5 | bbox_mke2fs='./busybox mke2fs' |
| 6 | |
| 7 | gen_image() { # params: mke2fs_invocation image_name |
Denys Vlasenko | 05647b5 | 2009-10-20 00:06:03 +0200 | [diff] [blame] | 8 | >$2 |
| 9 | dd seek=$((kilobytes-1)) bs=1K count=1 </dev/zero of=$2 >/dev/null 2>&1 || exit 1 |
| 10 | $1 -F $2 $kilobytes >$2.raw_out 2>&1 || return 1 |
| 11 | cat $2.raw_out \ |
| 12 | | grep -v '^mke2fs [0-9]*\.[0-9]*\.[0-9]* ' \ |
| 13 | | grep -v '^Maximum filesystem' \ |
| 14 | | grep -v '^Writing inode tables' \ |
| 15 | | grep -v '^Writing superblocks and filesystem accounting information' \ |
| 16 | | grep -v '^This filesystem will be automatically checked every' \ |
| 17 | | grep -v '^180 days, whichever comes first' \ |
Denys Vlasenko | 05647b5 | 2009-10-20 00:06:03 +0200 | [diff] [blame] | 18 | | sed 's/blocks* unused./blocks unused/' \ |
| 19 | | sed 's/block groups*/block groups/' \ |
| 20 | | sed 's/ *$//' \ |
| 21 | | sed 's/blocks (.*%) reserved/blocks reserved/' \ |
| 22 | | grep -v '^$' \ |
| 23 | >$2.out |
| 24 | } |
| 25 | |
Denys Vlasenko | e840561 | 2009-10-18 20:57:52 +0200 | [diff] [blame] | 26 | test_mke2fs() { |
| 27 | echo Testing $kilobytes |
| 28 | |
Denys Vlasenko | 82d6433 | 2009-10-20 17:04:55 +0200 | [diff] [blame] | 29 | gen_image "$system_mke2fs" image_std || return 1 |
| 30 | gen_image "$bbox_mke2fs" image_bb || return 1 |
Denys Vlasenko | e840561 | 2009-10-18 20:57:52 +0200 | [diff] [blame] | 31 | |
| 32 | diff -ua image_bb.out image_std.out >image.out.diff || { |
| 33 | cat image.out.diff |
| 34 | return 1 |
| 35 | } |
Denys Vlasenko | 05647b5 | 2009-10-20 00:06:03 +0200 | [diff] [blame] | 36 | |
Denys Vlasenko | 82d6433 | 2009-10-20 17:04:55 +0200 | [diff] [blame] | 37 | e2fsck -f -n image_bb >image_bb_e2fsck.out 2>&1 || { |
Denys Vlasenko | 95484c8 | 2009-10-20 13:34:16 +0200 | [diff] [blame] | 38 | echo "e2fsck error on image_bb" |
Denys Vlasenko | 82d6433 | 2009-10-20 17:04:55 +0200 | [diff] [blame] | 39 | cat image_bb_e2fsck.out |
Denys Vlasenko | 95484c8 | 2009-10-20 13:34:16 +0200 | [diff] [blame] | 40 | exit 1 |
| 41 | } |
Denys Vlasenko | e840561 | 2009-10-18 20:57:52 +0200 | [diff] [blame] | 42 | } |
| 43 | |
Denys Vlasenko | 82d6433 | 2009-10-20 17:04:55 +0200 | [diff] [blame] | 44 | # -:bbox +:standard |
| 45 | |
Denys Vlasenko | c708a6d | 2009-10-20 17:47:23 +0200 | [diff] [blame] | 46 | # kilobytes=60 is the minimal allowed size |
Denys Vlasenko | cbeb452 | 2009-10-20 16:21:29 +0200 | [diff] [blame] | 47 | kilobytes=60 |
Denys Vlasenko | 95484c8 | 2009-10-20 13:34:16 +0200 | [diff] [blame] | 48 | while true; do |
Denys Vlasenko | 82d6433 | 2009-10-20 17:04:55 +0200 | [diff] [blame] | 49 | test_mke2fs || exit 1 |
Denys Vlasenko | 08dfafc | 2017-07-15 19:18:58 +0200 | [diff] [blame] | 50 | kilobytes=$((kilobytes+1)) |
Denys Vlasenko | c708a6d | 2009-10-20 17:47:23 +0200 | [diff] [blame] | 51 | test $kilobytes = 200 && break |
| 52 | done |
| 53 | |
| 54 | # Transition from one block group to two |
Denys Vlasenko | 1d6e447 | 2009-10-21 14:14:51 +0200 | [diff] [blame] | 55 | # fails in [8378..8410] range unless -O ^resize_inode |
Denys Vlasenko | 5e1dbd5 | 2009-10-20 22:12:11 +0200 | [diff] [blame] | 56 | kilobytes=$((1 * 8*1024 - 50)) |
Denys Vlasenko | c708a6d | 2009-10-20 17:47:23 +0200 | [diff] [blame] | 57 | while true; do |
Denys Vlasenko | 1d6e447 | 2009-10-21 14:14:51 +0200 | [diff] [blame] | 58 | test_mke2fs || exit 1 |
Denys Vlasenko | 08dfafc | 2017-07-15 19:18:58 +0200 | [diff] [blame] | 59 | kilobytes=$((kilobytes+1)) |
Denys Vlasenko | 5e1dbd5 | 2009-10-20 22:12:11 +0200 | [diff] [blame] | 60 | test $kilobytes = $((1 * 8*1024 + 300)) && break |
Denys Vlasenko | c708a6d | 2009-10-20 17:47:23 +0200 | [diff] [blame] | 61 | done |
| 62 | |
Denys Vlasenko | 5e1dbd5 | 2009-10-20 22:12:11 +0200 | [diff] [blame] | 63 | # Transition from 2 block groups to 3 |
Denys Vlasenko | c708a6d | 2009-10-20 17:47:23 +0200 | [diff] [blame] | 64 | # works |
Denys Vlasenko | 5e1dbd5 | 2009-10-20 22:12:11 +0200 | [diff] [blame] | 65 | kilobytes=$((2 * 8*1024 - 50)) |
Denys Vlasenko | c708a6d | 2009-10-20 17:47:23 +0200 | [diff] [blame] | 66 | while true; do |
| 67 | test_mke2fs || exit 1 |
Denys Vlasenko | 08dfafc | 2017-07-15 19:18:58 +0200 | [diff] [blame] | 68 | kilobytes=$((kilobytes+1)) |
Denys Vlasenko | 5e1dbd5 | 2009-10-20 22:12:11 +0200 | [diff] [blame] | 69 | test $kilobytes = $((2 * 8*1024 + 400)) && break |
| 70 | done |
| 71 | |
| 72 | # Transition from 3 block groups to 4 |
Denys Vlasenko | 1d6e447 | 2009-10-21 14:14:51 +0200 | [diff] [blame] | 73 | # fails in [24825..24922] range unless -O ^resize_inode |
Denys Vlasenko | 5e1dbd5 | 2009-10-20 22:12:11 +0200 | [diff] [blame] | 74 | kilobytes=$((3 * 8*1024 - 50)) |
| 75 | while true; do |
Denys Vlasenko | 1d6e447 | 2009-10-21 14:14:51 +0200 | [diff] [blame] | 76 | test_mke2fs || exit 1 |
Denys Vlasenko | 08dfafc | 2017-07-15 19:18:58 +0200 | [diff] [blame] | 77 | kilobytes=$((kilobytes+1)) |
Denys Vlasenko | 5e1dbd5 | 2009-10-20 22:12:11 +0200 | [diff] [blame] | 78 | test $kilobytes = $((3 * 8*1024 + 500)) && break |
| 79 | done |
| 80 | |
| 81 | # Transition from 4 block groups to 5 |
| 82 | # works |
| 83 | kilobytes=$((4 * 8*1024 - 50)) |
| 84 | while true; do |
| 85 | test_mke2fs || exit 1 |
Denys Vlasenko | 08dfafc | 2017-07-15 19:18:58 +0200 | [diff] [blame] | 86 | kilobytes=$((kilobytes+1)) |
Denys Vlasenko | 5e1dbd5 | 2009-10-20 22:12:11 +0200 | [diff] [blame] | 87 | test $kilobytes = $((4 * 8*1024 + 600)) && break |
| 88 | done |
| 89 | |
| 90 | # Transition from 5 block groups to 6 |
Denys Vlasenko | 1d6e447 | 2009-10-21 14:14:51 +0200 | [diff] [blame] | 91 | # fails in [41230..41391] range unless -O ^resize_inode |
Denys Vlasenko | 5e1dbd5 | 2009-10-20 22:12:11 +0200 | [diff] [blame] | 92 | kilobytes=$((5 * 8*1024 - 50)) |
| 93 | while true; do |
Denys Vlasenko | 1d6e447 | 2009-10-21 14:14:51 +0200 | [diff] [blame] | 94 | test_mke2fs || exit 1 |
Denys Vlasenko | 08dfafc | 2017-07-15 19:18:58 +0200 | [diff] [blame] | 95 | kilobytes=$((kilobytes+1)) |
Denys Vlasenko | 5e1dbd5 | 2009-10-20 22:12:11 +0200 | [diff] [blame] | 96 | test $kilobytes = $((5 * 8*1024 + 700)) && break |
Denys Vlasenko | 95484c8 | 2009-10-20 13:34:16 +0200 | [diff] [blame] | 97 | done |
| 98 | exit |
| 99 | |
Denys Vlasenko | 5e1dbd5 | 2009-10-20 22:12:11 +0200 | [diff] [blame] | 100 | # Random sizes |
Denys Vlasenko | e840561 | 2009-10-18 20:57:52 +0200 | [diff] [blame] | 101 | while true; do |
Denys Vlasenko | 1d6e447 | 2009-10-21 14:14:51 +0200 | [diff] [blame] | 102 | kilobytes=$(( (RANDOM*RANDOM) % 5000000 + 60)) |
Denys Vlasenko | e840561 | 2009-10-18 20:57:52 +0200 | [diff] [blame] | 103 | test_mke2fs || exit 1 |
| 104 | done |