source: MondoRescue/branches/3.0/mindi-busybox/util-linux/mkfs_ext2_test.sh@ 2899

Last change on this file since 2899 was 2725, checked in by Bruno Cornec, 13 years ago
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#!/bin/sh
2
3# Disabling features we do not match exactly:
4system_mke2fs='/sbin/mke2fs -O ^resize_inode'
5bbox_mke2fs='./busybox mke2fs'
6
7gen_image() { # params: mke2fs_invocation image_name
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' \
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
26test_mke2fs() {
27 echo Testing $kilobytes
28
29 gen_image "$system_mke2fs" image_std || return 1
30 gen_image "$bbox_mke2fs" image_bb || return 1
31
32 diff -ua image_bb.out image_std.out >image.out.diff || {
33 cat image.out.diff
34 return 1
35 }
36
37 e2fsck -f -n image_bb >image_bb_e2fsck.out 2>&1 || {
38 echo "e2fsck error on image_bb"
39 cat image_bb_e2fsck.out
40 exit 1
41 }
42}
43
44# -:bbox +:standard
45
46# kilobytes=60 is the minimal allowed size
47kilobytes=60
48while true; do
49 test_mke2fs || exit 1
50 : $((kilobytes++))
51 test $kilobytes = 200 && break
52done
53
54# Transition from one block group to two
55# fails in [8378..8410] range unless -O ^resize_inode
56kilobytes=$((1 * 8*1024 - 50))
57while true; do
58 test_mke2fs || exit 1
59 : $((kilobytes++))
60 test $kilobytes = $((1 * 8*1024 + 300)) && break
61done
62
63# Transition from 2 block groups to 3
64# works
65kilobytes=$((2 * 8*1024 - 50))
66while true; do
67 test_mke2fs || exit 1
68 : $((kilobytes++))
69 test $kilobytes = $((2 * 8*1024 + 400)) && break
70done
71
72# Transition from 3 block groups to 4
73# fails in [24825..24922] range unless -O ^resize_inode
74kilobytes=$((3 * 8*1024 - 50))
75while true; do
76 test_mke2fs || exit 1
77 : $((kilobytes++))
78 test $kilobytes = $((3 * 8*1024 + 500)) && break
79done
80
81# Transition from 4 block groups to 5
82# works
83kilobytes=$((4 * 8*1024 - 50))
84while true; do
85 test_mke2fs || exit 1
86 : $((kilobytes++))
87 test $kilobytes = $((4 * 8*1024 + 600)) && break
88done
89
90# Transition from 5 block groups to 6
91# fails in [41230..41391] range unless -O ^resize_inode
92kilobytes=$((5 * 8*1024 - 50))
93while true; do
94 test_mke2fs || exit 1
95 : $((kilobytes++))
96 test $kilobytes = $((5 * 8*1024 + 700)) && break
97done
98exit
99
100# Random sizes
101while true; do
102 kilobytes=$(( (RANDOM*RANDOM) % 5000000 + 60))
103 test_mke2fs || exit 1
104done
Note: See TracBrowser for help on using the repository browser.