summaryrefslogtreecommitdiffstats
path: root/tests/f_mmp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/f_mmp/is_slow_test0
-rw-r--r--tests/f_mmp/name1
-rw-r--r--tests/f_mmp/script71
-rw-r--r--tests/f_mmp_garbage/expect.19
-rw-r--r--tests/f_mmp_garbage/expect.27
-rw-r--r--tests/f_mmp_garbage/is_slow_test0
-rw-r--r--tests/f_mmp_garbage/name1
-rw-r--r--tests/f_mmp_garbage/script17
8 files changed, 106 insertions, 0 deletions
diff --git a/tests/f_mmp/is_slow_test b/tests/f_mmp/is_slow_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/f_mmp/is_slow_test
diff --git a/tests/f_mmp/name b/tests/f_mmp/name
new file mode 100644
index 0000000..20d66d6
--- /dev/null
+++ b/tests/f_mmp/name
@@ -0,0 +1 @@
+disable MMP with tune2fs after e2fsck killed
diff --git a/tests/f_mmp/script b/tests/f_mmp/script
new file mode 100644
index 0000000..f433bd5
--- /dev/null
+++ b/tests/f_mmp/script
@@ -0,0 +1,71 @@
+FSCK_OPT=-yf
+
+echo "make the test image ..." > $test_name.log
+$MKE2FS -q -F -o Linux -b 4096 -O mmp -E mmp_update_interval=1 $TMPFILE 100 >> $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "mke2fs -O mmp failed" > $test_name.failed
+ echo "$test_name: $test_description: failed"
+ return $status
+fi
+
+kill_debugfs() {
+ trap 0
+ PID=$(ps -o pid,command | grep -v grep |
+ grep "debugfs -w $TMPFILE" | awk "{ print \$1 }")
+ [ "x$PID" != "x" ] && kill -9 $PID
+}
+
+# this will cause debugfs to create the $test_name.mark file once it has
+# passed the MMP startup, then continue reading input until it is killed
+MARKFILE=$test_name.new
+rm -f $MARKFILE
+trap kill_debugfs EXIT
+echo "set mmp sequence to EXT2_MMP_SEQ_FSCK..." >> $test_name.log
+( { echo dump_mmp; echo "dump_inode <2> $MARKFILE"; cat /dev/zero; } |
+ $DEBUGFS -w $TMPFILE >> $test_name.log 2>&1 & ) > /dev/null 2>&1 &
+echo "wait until debugfs has started ..." >> $test_name.log
+while [ ! -e $MARKFILE ]; do
+ sleep 1
+done
+rm -f $MARKFILE
+echo "kill debugfs abruptly (simulates e2fsck failure) ..." >> $test_name.log
+kill_debugfs
+
+$E2MMPSTATUS $TMPFILE > $test_name.log 2>&1
+status=$?
+if [ "$status" != 1 ] ; then
+ echo "$E2MMPSTATUS with EXT2_MMP_SEQ_FSCK passed!" > $test_name.failed
+ echo "$test_name: $test_description: failed"
+ return 1
+fi
+
+echo "e2fsck (should fail mmp_seq = EXT2_MMP_SEQ_FSCK) ..." >> $test_name.log
+$FSCK $FSCK_OPT $TMPFILE >> $test_name.log 2>&1
+status=$?
+if [ "$status" = 0 ] ; then
+ echo "e2fsck with MMP as EXT2_MMP_SEQ_FSCK ran!" > $test_name.failed
+ echo "$test_name: $test_description: failed"
+ return 1
+fi
+
+echo "clear mmp_seq with tune2fs ..." >> $test_name.log
+$TUNE2FS -f -E clear_mmp $TMPFILE >> $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "tune2fs clearing EXT2_MMP_SEQ_FSCK failed" > $test_name.failed
+ echo "$test_name: $test_description: failed"
+ return 1
+fi
+
+echo "run e2fsck again (should pass with clean mmp_seq) ..." >> $test_name.log
+$FSCK $FSCK_OPT $TMPFILE >> $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "e2fsck after clearing EXT2_MMP_SEQ_FSCK failed"> $test_name.failed
+ echo "$test_name: $test_description: failed"
+ return $status
+fi
+
+echo "$test_name: $test_description: ok"
+rm -f $TMPFILE
diff --git a/tests/f_mmp_garbage/expect.1 b/tests/f_mmp_garbage/expect.1
new file mode 100644
index 0000000..4134eae
--- /dev/null
+++ b/tests/f_mmp_garbage/expect.1
@@ -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/64 files (0.0% non-contiguous), 15/100 blocks
+Exit status is 0
diff --git a/tests/f_mmp_garbage/expect.2 b/tests/f_mmp_garbage/expect.2
new file mode 100644
index 0000000..3bca182
--- /dev/null
+++ b/tests/f_mmp_garbage/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/64 files (0.0% non-contiguous), 15/100 blocks
+Exit status is 0
diff --git a/tests/f_mmp_garbage/is_slow_test b/tests/f_mmp_garbage/is_slow_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/f_mmp_garbage/is_slow_test
diff --git a/tests/f_mmp_garbage/name b/tests/f_mmp_garbage/name
new file mode 100644
index 0000000..17e0b14
--- /dev/null
+++ b/tests/f_mmp_garbage/name
@@ -0,0 +1 @@
+repair MMP when it is corrupted
diff --git a/tests/f_mmp_garbage/script b/tests/f_mmp_garbage/script
new file mode 100644
index 0000000..69be338
--- /dev/null
+++ b/tests/f_mmp_garbage/script
@@ -0,0 +1,17 @@
+FSCK_OPT=-yf
+
+echo "make the test image ..." > $test_name.log
+$MKE2FS -q -F -o Linux -b 4096 -O mmp -E mmp_update_interval=1 $TMPFILE 100 >> $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "mke2fs -O mmp failed" > $test_name.failed
+ echo "$test_name: $test_description: failed"
+ return $status
+fi
+
+# create a corrupted image
+echo "modify the mmp sequence ..." >> $test_name.log
+$DEBUGFS -w -R "set_mmp_value magic 0x12345678" $TMPFILE >> $test_name.log 2>&1
+
+SKIP_GUNZIP=true
+. $cmd_dir/run_e2fsck