diff mbox

[17/19] tests: add regression tests for superblocks with bad checksums

Message ID 20140801181336.12496.46953.stgit@birch.djwong.org
State Accepted, archived
Headers show

Commit Message

Darrick Wong Aug. 1, 2014, 6:13 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Add regression tests to examine how e2fsck deals with random
superblock corruption such as obviously wrong fields and the checksum
itself being incorrect.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/f_super_bad_csum/expect.1  |   13 +++++++++++++
 tests/f_super_bad_csum/expect.2  |    7 +++++++
 tests/f_super_bad_csum/image.bz2 |  Bin
 tests/f_super_bad_csum/name      |    1 +
 tests/f_super_bad_csum/script    |   33 +++++++++++++++++++++++++++++++++
 5 files changed, 54 insertions(+)
 create mode 100644 tests/f_super_bad_csum/expect.1
 create mode 100644 tests/f_super_bad_csum/expect.2
 create mode 100644 tests/f_super_bad_csum/image.bz2
 create mode 100644 tests/f_super_bad_csum/name
 create mode 100755 tests/f_super_bad_csum/script


--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Theodore Ts'o Aug. 3, 2014, 3:50 a.m. UTC | #1
On Fri, Aug 01, 2014 at 11:13:36AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Add regression tests to examine how e2fsck deals with random
> superblock corruption such as obviously wrong fields and the checksum
> itself being incorrect.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/tests/f_super_bad_csum/expect.1 b/tests/f_super_bad_csum/expect.1
new file mode 100644
index 0000000..25ced5c
--- /dev/null
+++ b/tests/f_super_bad_csum/expect.1
@@ -0,0 +1,13 @@ 
+ext2fs_open2: Superblock checksum does not match superblock
+../e2fsck/e2fsck: Superblock invalid, trying backup blocks...
+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
+Inode bitmap differences: Group 1 inode bitmap does not match checksum.
+FIXED.
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 11/1024 files (0.0% non-contiguous), 1557/16384 blocks
+Exit status is 0
diff --git a/tests/f_super_bad_csum/expect.2 b/tests/f_super_bad_csum/expect.2
new file mode 100644
index 0000000..dd20919
--- /dev/null
+++ b/tests/f_super_bad_csum/expect.2
@@ -0,0 +1,7 @@ 
+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/1024 files (0.0% non-contiguous), 1557/16384 blocks
+Exit status is 0
diff --git a/tests/f_super_bad_csum/image.bz2 b/tests/f_super_bad_csum/image.bz2
new file mode 100644
index 0000000000000000000000000000000000000000..cd80d4b837fd0e966595e70d4bb0854b8b63a78b
GIT binary patch
literal 1181
zcmZ>Y%CIzaj8qGbG&$qO$-t0W{~rU~v2+!vn5cJQvuwM{xqY@5Sn7D6eNd27s1g;G
zG&H%mOmO0|9?s6m$^s`+F1}FXIM61nHq$79!N)Db*=JUQ56k8MUtJw~W*SN{Ge}MH
zUBbY?_{xNrts&!t5d$1#fLXjO{$GPu<@&&dQ5jq-m-PobE;zyL?B?UZ);NKe&6h{O
z$b=zLO3LKo0uzP|Heacf%MKUVdKnlvrgRzwA6s!GagoX8REaB<raTTAQj81O8W@1e
zdVEbTNJ&-onk2E!GRffOHL98=w|sKY?nTd2FVB&=G2`3JBcZ7~_09$a9f+MOD#jg>
zZLq%H&hN|D(@j@i_Pq2JoHFIin{Q>N$HFG%*Y97o=tE~h!$lw7XKJ4gtxIW|<8$`;
zo_lp&;d57YXvpWdI7D}>(3<u@X;s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KC`bZuyzg$csS8j
hgn?P_V=I@(%tyK$eZ1yBZN&cn7cX+P2$%pWjsRs0<w^hm

literal 0
HcmV?d00001

diff --git a/tests/f_super_bad_csum/name b/tests/f_super_bad_csum/name
new file mode 100644
index 0000000..745562f
--- /dev/null
+++ b/tests/f_super_bad_csum/name
@@ -0,0 +1 @@ 
+bad csum in superblock (metadata_csum)
diff --git a/tests/f_super_bad_csum/script b/tests/f_super_bad_csum/script
new file mode 100755
index 0000000..cfd4189
--- /dev/null
+++ b/tests/f_super_bad_csum/script
@@ -0,0 +1,33 @@ 
+#!/bin/bash
+
+FSCK_OPT=-fy
+IMAGE=$test_dir/image.bz2
+
+bzip2 -d < $IMAGE > $TMPFILE
+#e2label $TMPFILE test_filesys
+
+# Run fsck to fix things?
+EXP1=$test_dir/expect.1
+OUT1=$test_name.1.log
+rm -rf $test_name.failed $test_name.ok
+
+$FSCK $FSCK_OPT $TMPFILE 2>&1 | head -n 1000 | tail -n +2 > $OUT1
+echo "Exit status is $?" >> $OUT1
+
+# Run a second time
+EXP2=$test_dir/expect.2
+OUT2=$test_name.2.log
+
+$FSCK $FSCK_OPT $TMPFILE 2>&1 | head -n 1000 | tail -n +2 > $OUT2
+echo "Exit status is $?" >> $OUT2
+
+# Figure out what happened
+if cmp -s $EXP1 $OUT1 && cmp -s $EXP2 $OUT2; then
+	echo "$test_name: $test_description: ok"
+	touch $test_name.ok
+else
+	echo "$test_name: $test_description: failed"
+	diff -u $EXP1 $OUT1 >> $test_name.failed
+	diff -u $EXP2 $OUT2 >> $test_name.failed
+fi
+unset EXP1 OUT1 EXP2 OUT2 FSCK_OPT IMAGE