1if test -x $RESIZE2FS_EXE -a -x $DEBUGFS_EXE; then
2if [ $(uname -s) = "Darwin" ]; then
3	# creates a 3GB filesystem
4	echo "$test_name: $DESCRIPTION: skipped for HFS+ (no sparse files)"
5	return 0
6fi
7
8FSCK_OPT=-fn
9OUT=$test_name.log
10EXP=$test_dir/expect
11CONF=$TMPFILE.conf
12
13#gzip -d < $EXP.gz > $EXP
14
15cat > $CONF << ENDL
16[fs_types]
17	ext4h = {
18		features = has_journal,extent,huge_file,uninit_bg,dir_nlink,extra_isize,sparse_super,filetype,dir_index,ext_attr,^resize_inode,^meta_bg,^flex_bg,^metadata_csum,64bit
19		blocksize = 1024
20		inode_size = 256
21		make_hugefiles = true
22		hugefiles_dir = /
23		hugefiles_slack = 16000K
24		hugefiles_name = aaaaa
25		hugefiles_digits = 4
26		hugefiles_size = 117K
27		zero_hugefiles = false
28	}
29ENDL
30
31echo "tune2fs test" > $OUT
32
33MKE2FS_CONFIG=$CONF $MKE2FS -F -T ext4h -I 128 $TMPFILE 786432 >> $OUT 2>&1
34rm -rf $CONF
35
36# dump and check
37($DUMPE2FS -h $TMPFILE | grep -v '^Free blocks:'; $DUMPE2FS -g $TMPFILE) 2>&1 | sed -f $cmd_dir/filter.sed -e '/^Checksum:.*/d' >> $OUT.before 2> /dev/null
38$FSCK $FSCK_OPT -N test_filesys $TMPFILE >> $OUT 2>&1
39status=$?
40echo Exit status is $status >> $OUT
41
42# convert it
43echo "tune2fs -I 256 -O metadata_csum test.img" >> $OUT
44dd if=/dev/zero of=$TMPFILE conv=notrunc bs=1 count=1 seek=3221225471 2> /dev/null
45$TUNE2FS -I 256 -O metadata_csum $TMPFILE >> $OUT 2>&1
46status=$?
47echo Exit status is $status >> $OUT
48$FSCK -N test_filesys -y -f -D $TMPFILE >> $OUT 2>&1
49
50# dump and check
51($DUMPE2FS -h $TMPFILE | grep -v '^Free blocks:'; $DUMPE2FS -g $TMPFILE) 2>&1 | sed -f $cmd_dir/filter.sed -e '/^Checksum:.*/d' >> $OUT.after 2> /dev/null
52echo "Change in FS metadata:" >> $OUT
53diff -U 0 $OUT.before $OUT.after | sed -e '/^---.*/d' -e '/^+++.*/d' >> $OUT
54$FSCK $FSCK_OPT -N test_filesys $TMPFILE >> $OUT 2>&1
55status=$?
56echo Exit status is $status >> $OUT
57
58rm $TMPFILE
59
60#
61# Do the verification
62#
63
64sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" -e 's/test_filesys:.*//g' < $OUT > $OUT.new
65mv $OUT.new $OUT
66
67cmp -s $OUT $EXP
68status=$?
69
70if [ "$status" = 0 ] ; then
71	echo "$test_name: $test_description: ok"
72	touch $test_name.ok
73else
74	echo "$test_name: $test_description: failed"
75	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
76fi
77
78rm $OUT.before $OUT.after
79
80unset IMAGE FSCK_OPT OUT EXP CONF
81
82else #if test -x $RESIZE2FS_EXE -a -x $DEBUGFS_EXE; then
83	echo "$test_name: $test_description: skipped"
84fi
85
86