1if test -x $DEBUGFS_EXE -a -x $RESIZE2FS_EXE; then 2 3test_description="create fs image from dir, then minimize it" 4MKFS_DIR=$TMPFILE.dir 5OUT=$test_name.log 6EXP=$test_dir/expect 7 8rm -rf $MKFS_DIR 9mkdir -p $MKFS_DIR 10mkdir $MKFS_DIR/dir 11mkdir $MKFS_DIR/emptydir 12dd if=/dev/zero of=$MKFS_DIR/bigzerofile bs=1 count=1 seek=1073741824 2> /dev/null 13echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1024 2> /dev/null 14echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=524288 conv=notrunc 2> /dev/null 15echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1048576 conv=notrunc 2> /dev/null 16echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=536870912 conv=notrunc 2> /dev/null 17echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1073741824 conv=notrunc 2> /dev/null 18dd if=/dev/zero bs=1024 count=32 2> /dev/null | tr '\0' 'a' > $MKFS_DIR/bigfile 19touch $MKFS_DIR/emptyfile 20echo "Test me" > $MKFS_DIR/dir/file 21 22echo "create fs" > $OUT 23$MKE2FS -q -F -o Linux -T ext4 -O ^has_journal,metadata_csum,64bit,^resize_inode -E lazy_itable_init=1 -b 1024 -d $MKFS_DIR $TMPFILE 16384 >> $OUT 2>&1 24 25$DUMPE2FS $TMPFILE >> $OUT 2>&1 26cat > $TMPFILE.cmd << ENDL 27stat /emptyfile 28stat /bigfile 29stat /sparsefile 30stat /bigzerofile 31stat /fifo 32stat /emptydir 33stat /dir 34stat /dir/file 35ENDL 36$DEBUGFS -f $TMPFILE.cmd $TMPFILE 2>&1 | egrep "(stat|Size:|Type:)" | sed -f $test_dir/output.sed >> $OUT 37 38cat > $TMPFILE.cmd << ENDL 39ex /emptyfile 40ex /bigfile 41ex /sparsefile 42ex /bigzerofile 43ex /dir 44ex /dir/file 45ENDL 46$DEBUGFS -f $TMPFILE.cmd $TMPFILE 2>&1 | sed -f $test_dir/output.sed >> $OUT 47$FSCK -f -n $TMPFILE >> $OUT 2>&1 48 49echo "minify fs" >> $OUT 50$TUNE2FS -m 0 $TMPFILE >> $OUT 2>&1 51$RESIZE2FS -M $TMPFILE >> $OUT 2>&1 52$DUMPE2FS $TMPFILE >> $OUT 2>&1 53$FSCK -f -n $TMPFILE >> $OUT 2>&1 54 55echo "minify fs (2)" >> $OUT 56$TUNE2FS -m 0 $TMPFILE >> $OUT 2>&1 57$RESIZE2FS -M $TMPFILE >> $OUT 2>&1 58$DUMPE2FS $TMPFILE >> $OUT 2>&1 59$FSCK -f -n $TMPFILE >> $OUT 2>&1 60 61sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" < $OUT > $OUT.tmp 62mv $OUT.tmp $OUT 63 64# Do the verification 65cmp -s $OUT $EXP 66status=$? 67 68if [ "$status" = 0 ] ; then 69 echo "$test_name: $test_description: ok" 70 touch $test_name.ok 71else 72 echo "$test_name: $test_description: failed" 73 diff $DIFF_OPTS $EXP $OUT > $test_name.failed 74fi 75 76rm -rf $TMPFILE.cmd $MKFS_DIR $OUT.sed 77unset MKFS_DIR OUT EXP 78 79else #if test -x $DEBUGFS_EXE -a -x RESIZE2FS_EXE; then 80 echo "$test_name: $test_description: skipped" 81fi 82