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