1if [ $(uname -s) = "FreeBSD" ]; then
2       # creates a 96GB filesystem
3       echo "$test_name: $DESCRIPTION: skipped for FreeBSD (no sparse files)"
4       return 0
5fi
6
7if [ $(uname -s) = "Darwin" ]; then
8	# creates a 96GB filesystem
9	echo "$test_name: $DESCRIPTION: skipped for HFS+ (no sparse files)"
10	return 0
11fi
12
13if ! test -x $RESIZE2FS_EXE -o ! -x $DEBUGFS_EXE; then
14	echo "$test_name: $test_description: skipped (no debugfs/resize2fs)"
15	return 0
16fi
17
18FSCK_OPT=-yf
19OUT=$test_name.log
20if [ -f $test_dir/expect.gz ]; then
21	EXP=$test_name.tmp
22	gunzip < $test_dir/expect.gz > $EXP1
23else
24	EXP=$test_dir/expect
25fi
26
27dd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1
28
29echo mke2fs -q -F -o Linux -b 1024 -i 1024 -E stride=8192 -t ext4 test.img 1024000 > $OUT
30$MKE2FS -q -F -o Linux -b 1024 -i 1024 -E stride=8192 -t ext4 \
31	$TMPFILE 1024000 >> $OUT 2>&1
32
33echo resize2fs -p test.img 10240000 >> $OUT
34$RESIZE2FS -p $TMPFILE 100000000 >> $OUT 2>&1
35
36$FSCK $FSCK_OPT  -N test_filesys $TMPFILE >> $OUT 2>&1
37status=$?
38echo Exit status is $status >> $OUT
39
40$DEBUGFS -R "set_super_value lastcheck 0" -w $TMPFILE >/dev/null 2>&1
41$DEBUGFS -R "set_super_value hash_seed null" -w $TMPFILE >/dev/null 2>&1
42$DEBUGFS -R "set_super_value mkfs_time 0" -w $TMPFILE >/dev/null 2>&1
43$TUNE2FS -c 20 -U clear $TMPFILE  >/dev/null 2>&1
44
45echo dumpe2fs -h test.img >> $OUT
46$DUMPE2FS -h $TMPFILE >> $OUT 2>&1
47sed -f $cmd_dir/filter.sed -e '/Block bitmap.*$/N;s/\n  Inode bitmap/, Inode bitmap/g' < $OUT > $OUT.new
48mv $OUT.new $OUT
49rm -f $TMPFILE
50
51cmp -s $OUT $EXP
52status=$?
53
54if [ "$status" = 0 ] ; then
55	echo "$test_name: $test_description: ok"
56	touch $test_name.ok
57else
58	echo "$test_name: $test_description: failed"
59	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
60	rm -f $test_name.tmp
61fi
62
63unset IMAGE FSCK_OPT OUT EXP
64