Whamcloud - gitweb
e2fsck: regression tests for INCOMPAT_MMP feature
[tools/e2fsprogs.git] / tests / f_mmp / script
1 FSCK_OPT=-yf
2
3 TMPFILE=test.img
4 rm -f $test_name.failed $test_name.ok
5 > $TMPFILE
6
7 stat -f $TMPFILE | grep -q "Type: tmpfs"
8 if [ $? == 0 ]; then
9         rm -f $TMPFILE
10         echo "skipped for tmpfs (no O_DIRECT support)"
11         return 0
12 fi
13
14 echo "make the test image ..." > $test_name.log
15 $MKE2FS -q -F -o Linux -b 1024 -O mmp -E mmp_update_interval=1 $TMPFILE 100 >> $test_name.log 2>&1
16 status=$?
17 if [ "$status" != 0 ] ; then
18         echo "mke2fs -O mmp failed" > $test_name.failed
19         echo "failed"
20         return $status
21 fi
22
23 # this will cause debugfs to create the $test_name.mark file once it has
24 # passed the MMP startup, then continue reading input until it is killed
25 MARKFILE=$test_name.new
26 rm -f $MARKFILE
27 echo "set mmp sequence to EXT2_MMP_SEQ_FSCK..." >> $test_name.log
28 ( { echo dump_mmp; echo "dump_inode <2> $MARKFILE"; cat /dev/zero; } |
29         $DEBUGFS -w $TMPFILE >> $test_name.log 2>&1 & ) > /dev/null 2>&1 &
30 echo "wait until debugfs has started ..." >> $test_name.log
31 while [ ! -e $MARKFILE ]; do
32         sleep 1
33 done
34 rm -f $MARKFILE
35 echo "kill debugfs abruptly (simulates e2fsck failure) ..." >> $test_name.log
36 killall -9 debugfs >> $test_name.log
37
38
39 echo "e2fsck (should fail mmp_seq = EXT2_MMP_SEQ_FSCK) ..." >> $test_name.log
40 $FSCK $FSCK_OPT $TMPFILE >> $test_name.log 2>&1
41 status=$?
42 if [ "$status" == 0 ] ; then
43         echo "e2fsck with MMP as EXT2_MMP_SEQ_FSCK ran!" > $test_name.failed
44         echo "failed"
45         return 1
46 fi
47
48 echo "clear mmp_seq with tune2fs ..." >> $test_name.log
49 $TUNE2FS -f -E clear_mmp $TMPFILE >> $test_name.log 2>&1
50 status=$?
51 if [ "$status" != 0 ] ; then
52         echo "tune2fs clearing EXT2_MMP_SEQ_FSCK failed" > $test_name.failed
53         echo "failed"
54         return 1
55 fi
56
57 echo "run e2fsck again (should pass with clean mmp_seq) ..." >> $test_name.log
58 $FSCK $FSCK_OPT $TMPFILE >> $test_name.log 2>&1
59 status=$?
60 if [ "$status" != 0 ] ; then
61         echo "e2fsck after clearing EXT2_MMP_SEQ_FSCK failed"> $test_name.failed
62         echo "failed"
63         return $status
64 fi
65
66 echo "ok"
67 rm -f $TMPFILE