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