Whamcloud - gitweb
9202e1214f489774d56ec8e18f7219323c99a3da
[tools/e2fsprogs.git] / tests / run_e2fsck
1 if [ "$DESCRIPTION"x != x ]; then
2         printf "%s" "$DESCRIPTION: "
3 fi
4 if [ "$IMAGE"x = x ]; then
5         IMAGE=$test_dir/image.gz
6 fi
7
8 if [ "$FSCK_OPT"x = x ]; then
9         FSCK_OPT=-yf
10 fi
11
12 if [ "$SECOND_FSCK_OPT"x = x ]; then
13         SECOND_FSCK_OPT=-yf
14 fi
15
16 if [ "$OUT1"x = x ]; then
17         OUT1=$test_name.1.log
18 fi
19
20 if [ "$OUT2"x = x ]; then
21         OUT2=$test_name.2.log
22 fi
23
24 if [ "$EXP1"x = x ]; then
25         if [ -f $test_dir/expect.1.gz ]; then
26                 EXP1=tmp_expect
27                 gunzip < $test_dir/expect.1.gz > $EXP1
28         else
29                 EXP1=$test_dir/expect.1
30         fi
31 fi
32
33 if [ "$EXP2"x = x ]; then
34         if [ -f $test_dir/expect.2.gz ]; then
35                 EXP2=tmp_expect
36                 gunzip < $test_dir/expect.2.gz > $EXP2
37         else
38                 EXP2=$test_dir/expect.2
39         fi
40 fi
41
42 if [ "$SKIP_GUNZIP" != "true" ] ; then
43         gunzip < $IMAGE > $TMPFILE
44 fi
45
46 cp /dev/null $OUT1
47
48 eval $PREP_CMD
49
50 $FSCK $FSCK_OPT  -N test_filesys $TMPFILE > $OUT1.new 2>&1
51 status=$?
52 echo Exit status is $status >> $OUT1.new
53 sed -e '1d' $OUT1.new | sed -e '/^JFS DEBUG:/d' | \
54             sed -e "s;$TMPFILE;test.img;" | tr -d \\015 >> $OUT1
55 rm -f $OUT1.new
56
57 if [ "$ONE_PASS_ONLY" != "true" ]; then
58         $FSCK $SECOND_FSCK_OPT -N test_filesys $TMPFILE > $OUT2.new 2>&1 
59         status=$?
60         echo Exit status is $status >> $OUT2.new
61         sed -e '1d' $OUT2.new | sed -e '/^JFS DEBUG:/d' | \
62             sed -e "s;$TMPFILE;test.img;" > $OUT2
63         rm -f $OUT2.new
64 fi
65
66 eval $AFTER_CMD
67
68 if [ "$SKIP_UNLINK" != "true" ] ; then
69         rm $TMPFILE
70 fi
71
72 if [ "$SKIP_VERIFY" != "true" ] ; then
73         rm -f $test_name.ok $test_name.failed
74         cmp -s $OUT1 $EXP1
75         status1=$?
76         if [ "$ONE_PASS_ONLY" != "true" ]; then
77                 cmp -s $OUT2 $EXP2
78                 status2=$?
79         else
80                 status2=0
81         fi
82
83         if [ "$status1" = 0 -a "$status2" = 0 ] ; then
84                 echo "ok"
85                 touch $test_name.ok
86         else
87                 echo "failed"
88                 diff $DIFF_OPTS $EXP1 $OUT1 > $test_name.failed
89                 if [ "$ONE_PASS_ONLY" != "true" ]; then
90                         diff $DIFF_OPTS $EXP2 $OUT2 >> $test_name.failed
91                 fi
92         fi
93         rm -f tmp_expect
94 fi
95
96 if [ "$SKIP_CLEANUP" != "true" ] ; then
97         unset IMAGE FSCK_OPT SECOND_FSCK_OPT OUT1 OUT2 EXP1 EXP2 
98         unset SKIP_VERIFY SKIP_CLEANUP SKIP_GUNZIP ONE_PASS_ONLY PREP_CMD
99         unset DESCRIPTION SKIP_UNLINK AFTER_CMD
100 fi
101