• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1test_description="mke2fs with error behavior"
2
3conf=$TMPFILE.conf
4write_defaults_conf()
5{
6	errors="$1"
7	cat > $conf << ENDL
8[defaults]
9	errors = $errors
10ENDL
11}
12
13write_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	}
24ENDL
25}
26
27trap "rm -f $TMPFILE $TMPFILE.conf" EXIT INT QUIT
28dd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1
29OUT=$test_name.log
30EXP=$test_dir/expect
31rm -f $OUT
32
33# Test command line option
34echo "error default" >> $OUT
35$MKE2FS -F $TMPFILE > /dev/null 2>&1
36$DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
37
38echo "error continue" >> $OUT
39$MKE2FS -e continue -F $TMPFILE > /dev/null 2>&1
40$DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
41
42echo "error panic" >> $OUT
43$MKE2FS -e panic -F $TMPFILE > /dev/null 2>&1
44$DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
45
46echo "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
50echo "error garbage" >> $OUT
51dd 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
56echo "error default profile continue" >> $OUT
57write_defaults_conf continue
58MKE2FS_CONFIG=$conf $MKE2FS -F $TMPFILE > /dev/null 2>&1
59$DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
60
61echo "error default profile panic" >> $OUT
62write_defaults_conf panic
63MKE2FS_CONFIG=$conf $MKE2FS -F $TMPFILE > /dev/null 2>&1
64$DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
65
66echo "error default profile remount-ro" >> $OUT
67write_defaults_conf remount-ro
68MKE2FS_CONFIG=$conf $MKE2FS -F $TMPFILE > /dev/null 2>&1
69$DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
70
71echo "error default profile broken" >> $OUT
72write_defaults_conf broken
73dd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1
74MKE2FS_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
78echo "error fs_types profile continue" >> $OUT
79write_section_conf continue
80MKE2FS_CONFIG=$conf $MKE2FS -T test_suite -F $TMPFILE > /dev/null 2>&1
81$DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
82
83echo "error fs_types profile panic" >> $OUT
84write_section_conf panic
85MKE2FS_CONFIG=$conf $MKE2FS -T test_suite -F $TMPFILE > /dev/null 2>&1
86$DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
87
88echo "error fs_types profile remount-ro" >> $OUT
89write_section_conf remount-ro
90MKE2FS_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
94echo "error fs_types profile remount-ro" >> $OUT
95write_section_conf remount-ro
96MKE2FS_CONFIG=$conf $MKE2FS -T test_suite -e panic -F $TMPFILE > /dev/null 2>&1
97$DUMPE2FS $TMPFILE 2>&1 | grep 'Errors behavior' >> $OUT
98
99cmp -s $OUT $EXP
100status=$?
101
102if [ "$status" = 0 ] ; then
103	echo "$test_name: $test_description: ok"
104	touch $test_name.ok
105else
106	echo "$test_name: $test_description: failed"
107	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
108	rm -f $test_name.tmp
109fi
110
111