Whamcloud - gitweb
LU-12226 debian: fix debhelper level requirement
[tools/e2fsprogs.git] / tests / m_error_behavior / script
1 test_description="mke2fs with error behavior"
2
3 conf=$TMPFILE.conf
4 write_defaults_conf()
5 {
6         errors="$1"
7         cat > $conf << ENDL
8 [defaults]
9         errors = $errors
10 ENDL
11 }
12
13 write_section_conf()
14 {
15         errors="$1"
16         cat > $conf << ENDL
17 [defaults]
18         errors = broken
19
20 [fs_types]
21         test_suite = {
22                 errors = $errors
23         }
24 ENDL
25 }
26
27 trap "rm -f $TMPFILE $TMPFILE.conf" EXIT INT QUIT
28 dd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1
29 OUT=$test_name.log
30 EXP=$test_dir/expect
31 rm -f $OUT
32
33 # Test command line option
34 echo "error default" >> $OUT
35 $MKE2FS -F $TMPFILE > /dev/null 2>&1
36 $DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
37
38 echo "error continue" >> $OUT
39 $MKE2FS -e continue -F $TMPFILE > /dev/null 2>&1
40 $DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
41
42 echo "error panic" >> $OUT
43 $MKE2FS -e panic -F $TMPFILE > /dev/null 2>&1
44 $DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
45
46 echo "error remount-ro" >> $OUT
47 $MKE2FS -e remount-ro -F $TMPFILE > /dev/null 2>&1
48 $DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
49
50 echo "error garbage" >> $OUT
51 dd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1
52 $MKE2FS -e broken -F $TMPFILE > /dev/null 2>&1
53 $DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
54
55 # Test errors= in default
56 echo "error default profile continue" >> $OUT
57 write_defaults_conf continue
58 MKE2FS_CONFIG=$conf $MKE2FS -F $TMPFILE > /dev/null 2>&1
59 $DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
60
61 echo "error default profile panic" >> $OUT
62 write_defaults_conf panic
63 MKE2FS_CONFIG=$conf $MKE2FS -F $TMPFILE > /dev/null 2>&1
64 $DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
65
66 echo "error default profile remount-ro" >> $OUT
67 write_defaults_conf remount-ro
68 MKE2FS_CONFIG=$conf $MKE2FS -F $TMPFILE > /dev/null 2>&1
69 $DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
70
71 echo "error default profile broken" >> $OUT
72 write_defaults_conf broken
73 dd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1
74 MKE2FS_CONFIG=$conf $MKE2FS -F $TMPFILE > /dev/null 2>&1
75 $DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
76
77 # Test errors= in a fs type
78 echo "error fs_types profile continue" >> $OUT
79 write_section_conf continue
80 MKE2FS_CONFIG=$conf $MKE2FS -T test_suite -F $TMPFILE > /dev/null 2>&1
81 $DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
82
83 echo "error fs_types profile panic" >> $OUT
84 write_section_conf panic
85 MKE2FS_CONFIG=$conf $MKE2FS -T test_suite -F $TMPFILE > /dev/null 2>&1
86 $DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
87
88 echo "error fs_types profile remount-ro" >> $OUT
89 write_section_conf remount-ro
90 MKE2FS_CONFIG=$conf $MKE2FS -T test_suite -F $TMPFILE > /dev/null 2>&1
91 $DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
92
93 # Test command line override
94 echo "error fs_types profile remount-ro" >> $OUT
95 write_section_conf remount-ro
96 MKE2FS_CONFIG=$conf $MKE2FS -T test_suite -e panic -F $TMPFILE > /dev/null 2>&1
97 $DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
98
99 cmp -s $OUT $EXP
100 status=$?
101
102 if [ "$status" = 0 ] ; then
103         echo "$test_name: $test_description: ok"
104         touch $test_name.ok
105 else
106         echo "$test_name: $test_description: failed"
107         diff $DIFF_OPTS $EXP $OUT > $test_name.failed
108         rm -f $test_name.tmp
109 fi
110