tests: add regression tests for MMP blocks with bad checksums

Add regression tests to examine how e2fsck deals with MMP blocks with
(a) a bad magic number; and (b) an incorrect checksum.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
crypto
Darrick J. Wong 2014-08-02 23:49:41 -04:00 committed by Theodore Ts'o
parent 8e203507b3
commit a8a1ee1255
10 changed files with 92 additions and 1 deletions

View File

@ -1166,7 +1166,9 @@ check_error:
ext2fs_mmp_clear(fs);
retval = 0;
}
}
} else
com_err(ctx->program_name, retval, "%s",
_("while reading MMP block"));
return retval;
}

View File

@ -0,0 +1,9 @@
Superblock MMP block checksum does not match MMP block. Fix? yes
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
test_filesys: 11/128 files (0.0% non-contiguous), 19/512 blocks
Exit status is 0

Binary file not shown.

View File

@ -0,0 +1 @@
mmp with bad csum (metadata_csum)

View File

@ -0,0 +1,30 @@
# use current directory instead of /tmp becase tmpfs doesn't support DIO
rm -f $TMPFILE
TMPFILE=$(mktemp ./tmp-$test_name.XXXXXX)
stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ]; then
rm -f $TMPFILE
echo "$test_name: $test_description: skipped for tmpfs (no O_DIRECT)"
return 0
fi
gzip -dc < $test_dir/image.gz > $TMPFILE
OUT=$test_dir.log
EXP=$test_dir/expect
$FSCK -fy $TMPFILE 2>&1 | sed -f $cmd_dir/filter.sed > $OUT
echo Exit status is $? >> $OUT
rm -f $TMPFILE
cmp -s $OUT $EXP
status=$?
if [ "$status" = 0 ] ; then
echo "$test_name: $test_description: ok"
touch $test_name.ok
else
echo "$test_name: $test_description: failed"
diff $DIFF_OPTS $EXP $OUT > $test_name.failed
rm -f $test_name.tmp
fi
unset OUT EXP

View File

@ -0,0 +1,9 @@
Superblock has invalid MMP magic. Fix? yes
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
test_filesys: 11/128 files (0.0% non-contiguous), 19/512 blocks
Exit status is 0

View File

@ -0,0 +1,9 @@
Superblock has invalid MMP magic. Fix? yes
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
test_filesys: 11/128 files (0.0% non-contiguous), 19/512 blocks
Exit status is 0

Binary file not shown.

View File

@ -0,0 +1 @@
mmp with bad magic (metadata_csum)

View File

@ -0,0 +1,30 @@
# use current directory instead of /tmp becase tmpfs doesn't support DIO
rm -f $TMPFILE
TMPFILE=$(mktemp ./tmp-$test_name.XXXXXX)
stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ]; then
rm -f $TMPFILE
echo "$test_name: $test_description: skipped for tmpfs (no O_DIRECT)"
return 0
fi
gzip -dc < $test_dir/image.gz > $TMPFILE
OUT=$test_dir.log
EXP=$test_dir/expect
$FSCK -fy $TMPFILE 2>&1 | sed -f $cmd_dir/filter.sed > $OUT
echo Exit status is $? >> $OUT
rm -f $TMPFILE
cmp -s $OUT $EXP
status=$?
if [ "$status" = 0 ] ; then
echo "$test_name: $test_description: ok"
touch $test_name.ok
else
echo "$test_name: $test_description: failed"
diff $DIFF_OPTS $EXP $OUT > $test_name.failed
rm -f $test_name.tmp
fi
unset OUT EXP