Home | History | Annotate | Download | only in d_punch
      1 if test -x $DEBUGFS_EXE; then
      2 
      3 FSCK_OPT=-fy
      4 OUT=$test_name.log
      5 if [ -f $test_dir/expect.gz ]; then
      6 	EXP=$test_name.tmp
      7 	gunzip < $test_dir/expect.gz > $EXP1
      8 else
      9 	EXP=$test_dir/expect
     10 fi
     11 
     12 cp /dev/null $OUT
     13 
     14 cat > $TMPFILE.conf << ENDL
     15 [fs_types]
     16 ext4 = {
     17         base_features = sparse_super,filetype,resize_inode,dir_index,ext_attr,^has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,64bit
     18         blocksize = 1024
     19         inode_size = 256
     20         inode_ratio = 16384
     21 }
     22 ENDL
     23 MKE2FS_CONFIG=$TMPFILE.conf $MKE2FS -F -o Linux -b 1024 -O ^bigalloc -T ext4 $TMPFILE 65536 2>&1 | sed -f $cmd_dir/filter.sed >> $OUT 2>&1
     24 rm -rf $TMPFILE.conf
     25 
     26 $FSCK -fy -N test_filesys $TMPFILE > $OUT.new 2>&1
     27 status=$?
     28 echo Exit status is $status >> $OUT.new
     29 sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new >> $OUT
     30 rm -f $OUT.new
     31 
     32 echo "debugfs write files" >> $OUT
     33 make_file() {
     34 	name="$1"
     35 	start="$2"
     36 	flag="$3"
     37 
     38 	cat << ENDL
     39 write /dev/null $name
     40 fallocate /$name 0 39
     41 punch /$name 10 10
     42 punch /$name 13 13
     43 punch /$name 26 26
     44 punch /$name 29 29
     45 ENDL
     46 }
     47 
     48 #Files we create:
     49 # a: punch a 40k file
     50 # b*: punch sparse file starting at b*
     51 # c*: punch spare file ending at c*
     52 # d: midcluster to midcluster, surrounding sparse
     53 # e: partial middle cluster alloc
     54 # f: one big file
     55 base=5000
     56 cat > $TMPFILE.cmd << ENDL
     57 write /dev/null a
     58 fallocate /a 0 39
     59 punch /a 0 39
     60 ENDL
     61 echo "ex /a" >> $TMPFILE.cmd2
     62 
     63 make_file sample $base --uninit >> $TMPFILE.cmd
     64 echo "ex /sample" >> $TMPFILE.cmd2
     65 base=10000
     66 
     67 for i in 8 9 10 11 12 13 14 15; do
     68 	make_file b$i $(($base + (40 * ($i - 8)))) --uninit >> $TMPFILE.cmd
     69 	echo "punch /b$i $i 39" >> $TMPFILE.cmd
     70 	echo "ex /b$i" >> $TMPFILE.cmd2
     71 done
     72 
     73 for i in 24 25 26 27 28 29 30 31; do
     74 	make_file c$i $(($base + 320 + (40 * ($i - 24)))) --uninit >> $TMPFILE.cmd
     75 	echo "punch /c$i 0 $i" >> $TMPFILE.cmd
     76 	echo "ex /c$i" >> $TMPFILE.cmd2
     77 done
     78 
     79 make_file d $(($base + 640)) --uninit >> $TMPFILE.cmd
     80 echo "punch /d 4 35" >> $TMPFILE.cmd
     81 echo "ex /d" >> $TMPFILE.cmd2
     82 
     83 make_file e $(($base + 680)) --uninit >> $TMPFILE.cmd
     84 echo "punch /e 19 20" >> $TMPFILE.cmd
     85 echo "ex /e" >> $TMPFILE.cmd2
     86 
     87 cat >> $TMPFILE.cmd << ENDL
     88 write /dev/null f
     89 sif /f size 1024
     90 eo /f
     91 set_bmap --uninit 0 9000
     92 ec
     93 sif /f blocks 2
     94 setb 9000
     95 fallocate /f 0 8999
     96 punch /f 1 8998
     97 ENDL
     98 echo "ex /f" >> $TMPFILE.cmd2
     99 
    100 $DEBUGFS_EXE -w -f $TMPFILE.cmd $TMPFILE > /dev/null 2>&1
    101 $DEBUGFS_EXE -f $TMPFILE.cmd2 $TMPFILE >> $OUT.new 2>&1
    102 sed -f $cmd_dir/filter.sed < $OUT.new >> $OUT
    103 rm -rf $OUT.new $TMPFILE.cmd $TMPFILE.cmd2
    104 
    105 $FSCK -fy -N test_filesys $TMPFILE > $OUT.new 2>&1
    106 status=$?
    107 echo Exit status is $status >> $OUT.new
    108 sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new >> $OUT
    109 rm -f $OUT.new
    110 
    111 rm -f $TMPFILE
    112 
    113 cmp -s $OUT $EXP
    114 status=$?
    115 
    116 if [ "$status" = 0 ] ; then
    117 	echo "$test_name: $test_description: ok"
    118 	touch $test_name.ok
    119 else
    120 	echo "$test_name: $test_description: failed"
    121 	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
    122 	rm -f $test_name.tmp
    123 fi
    124 
    125 unset IMAGE FSCK_OPT OUT EXP
    126 
    127 else #if test -x $DEBUGFS_EXE; then
    128 	echo "$test_name: $test_description: skipped"
    129 fi
    130