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