]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blame - tests/f_mmp/script
libext2fs: don't use O_DIRECT for files on tmpfs
[thirdparty/e2fsprogs.git] / tests / f_mmp / script
CommitLineData
d9c60e04
AD
1FSCK_OPT=-yf
2
d9c60e04 3echo "make the test image ..." > $test_name.log
6d268879 4$MKE2FS -q -F -o Linux -b 4096 -O mmp -E mmp_update_interval=1 $TMPFILE 100 >> $test_name.log 2>&1
d9c60e04
AD
5status=$?
6if [ "$status" != 0 ] ; then
7 echo "mke2fs -O mmp failed" > $test_name.failed
f3331df6 8 echo "$test_name: $test_description: failed"
d9c60e04
AD
9 return $status
10fi
11
12f48b0c
AD
12kill_debugfs() {
13 trap 0
358c94ab
TT
14 PID=$(ps -o pid,command | grep -v grep |
15 grep "debugfs -w $TMPFILE" | awk "{ print \$1 }")
12f48b0c
AD
16 [ "x$PID" != "x" ] && kill -9 $PID
17}
18
d9c60e04
AD
19# this will cause debugfs to create the $test_name.mark file once it has
20# passed the MMP startup, then continue reading input until it is killed
21MARKFILE=$test_name.new
22rm -f $MARKFILE
12f48b0c 23trap kill_debugfs EXIT
d9c60e04
AD
24echo "set mmp sequence to EXT2_MMP_SEQ_FSCK..." >> $test_name.log
25( { echo dump_mmp; echo "dump_inode <2> $MARKFILE"; cat /dev/zero; } |
26 $DEBUGFS -w $TMPFILE >> $test_name.log 2>&1 & ) > /dev/null 2>&1 &
27echo "wait until debugfs has started ..." >> $test_name.log
28while [ ! -e $MARKFILE ]; do
29 sleep 1
30done
31rm -f $MARKFILE
32echo "kill debugfs abruptly (simulates e2fsck failure) ..." >> $test_name.log
12f48b0c 33kill_debugfs
d9c60e04 34
32b8802a
SI
35$E2MMPSTATUS $TMPFILE > $test_name.log 2>&1
36status=$?
37if [ "$status" != 1 ] ; then
38 echo "$E2MMPSTATUS with EXT2_MMP_SEQ_FSCK passed!" > $test_name.failed
39 echo "$test_name: $test_description: failed"
40 return 1
41fi
d9c60e04
AD
42
43echo "e2fsck (should fail mmp_seq = EXT2_MMP_SEQ_FSCK) ..." >> $test_name.log
44$FSCK $FSCK_OPT $TMPFILE >> $test_name.log 2>&1
45status=$?
21af16f4 46if [ "$status" = 0 ] ; then
d9c60e04 47 echo "e2fsck with MMP as EXT2_MMP_SEQ_FSCK ran!" > $test_name.failed
f3331df6 48 echo "$test_name: $test_description: failed"
d9c60e04
AD
49 return 1
50fi
51
52echo "clear mmp_seq with tune2fs ..." >> $test_name.log
53$TUNE2FS -f -E clear_mmp $TMPFILE >> $test_name.log 2>&1
54status=$?
55if [ "$status" != 0 ] ; then
56 echo "tune2fs clearing EXT2_MMP_SEQ_FSCK failed" > $test_name.failed
f3331df6 57 echo "$test_name: $test_description: failed"
d9c60e04
AD
58 return 1
59fi
60
61echo "run e2fsck again (should pass with clean mmp_seq) ..." >> $test_name.log
62$FSCK $FSCK_OPT $TMPFILE >> $test_name.log 2>&1
63status=$?
64if [ "$status" != 0 ] ; then
65 echo "e2fsck after clearing EXT2_MMP_SEQ_FSCK failed"> $test_name.failed
f3331df6 66 echo "$test_name: $test_description: failed"
d9c60e04
AD
67 return $status
68fi
69
f3331df6 70echo "$test_name: $test_description: ok"
d9c60e04 71rm -f $TMPFILE