Whamcloud - gitweb
misc: use libmagic when libblkid can't identify something
[tools/e2fsprogs.git] / tests / f_detect_junk / script
1 #!/bin/bash
2
3 if [ "$(grep -c 'define HAVE_MAGIC_H' $test_dir/../../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" -i $OUT
30
31 # Figure out what happened
32 if cmp -s $EXP $OUT; then
33         echo "$test_name: $test_description: ok"
34         touch $test_name.ok
35 else
36         echo "$test_name: $test_description: failed"
37         diff -u $EXP $OUT >> $test_name.failed
38 fi
39 unset EXP OUT FSCK_OPT IMAGE
40
41 else #if HAVE_MAGIC_H
42         echo "$test_name: $test_description: skipped"
43 fi