Home | History | Annotate | Download | only in f_detect_junk
      1 #!/bin/bash
      2 
      3 if [ "$(grep -c 'define HAVE_MAGIC_H' ../lib/config.h)" -gt 0 ]; then
      4 
      5 FSCK_OPT=-fn
      6 IMAGE=$test_dir/image.bz2
      7 
      8 bzip2 -d < $IMAGE > $TMPFILE
      9 dd if=/dev/zero of=$TMPFILE conv=notrunc oflag=append bs=1024k count=16 > /dev/null 2>&1
     10 
     11 # Run fsck to fix things?
     12 if [ -x $DEBUGFS_EXE ]; then
     13 	EXP=$test_dir/expect
     14 else
     15 	EXP=$test_dir/expect.nodebugfs
     16 fi
     17 OUT=$test_name.log
     18 rm -rf $test_name.failed $test_name.ok
     19 
     20 echo "*** e2fsck" > $OUT
     21 $FSCK $FSCK_OPT $TMPFILE >> $OUT 2>&1
     22 echo "*** debugfs" >> $OUT
     23 test -x $DEBUGFS_EXE && $DEBUGFS_EXE -R 'quit' $TMPFILE >> $OUT 2>&1
     24 echo "*** tune2fs" >> $OUT
     25 $TUNE2FS -i 0 $TMPFILE >> $OUT 2>&1
     26 echo "*** mke2fs" >> $OUT
     27 $MKE2FS -n $TMPFILE >> $OUT 2>&1
     28 
     29 sed -f $cmd_dir/filter.sed -e "s|$TMPFILE|test.img|g" < $OUT > $OUT.new
     30 mv $OUT.new $OUT
     31 
     32 # Figure out what happened
     33 if cmp -s $EXP $OUT; then
     34 	echo "$test_name: $test_description: ok"
     35 	touch $test_name.ok
     36 else
     37 	echo "$test_name: $test_description: failed"
     38 	diff -u $EXP $OUT >> $test_name.failed
     39 fi
     40 unset EXP OUT FSCK_OPT IMAGE
     41 
     42 else #if HAVE_MAGIC_H
     43 	echo "$test_name: $test_description: skipped"
     44 fi
     45