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