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