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