Whamcloud - gitweb
LU-13197 e2fsck: consistently use ext2fs_get_mem()
[tools/e2fsprogs.git] / tests / run_e2fsck
1 if [ "$DESCRIPTION"x != x ]; then
2         test_description="$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=$test_name.1.tmp
27                 gunzip < $test_dir/expect.1.gz > $EXP1
28         else
29                 EXP1=$test_dir/expect.1
30                 [ "$CHECK_RHEL7" = "true" -a -f $test_dir/expect_rhel7.1 ] &&
31                         EXP1=$test_dir/expect_rhel7.1 || true
32         fi
33 fi
34
35 if [ "$EXP2"x = x ]; then
36         if [ -f $test_dir/expect.2.gz ]; then
37                 EXP2=$test_name.2.tmp
38                 gunzip < $test_dir/expect.2.gz > $EXP2
39         else
40                 EXP2=$test_dir/expect.2
41                 [ "$CHECK_RHEL7" = "true" -a -f $test_dir/expect_rhel7.2 ] &&
42                         EXP2=$test_dir/expect_rhel7.2 || true
43         fi
44 fi
45
46 if [ "$SKIP_GUNZIP" != "true" ] ; then
47         gunzip < $IMAGE > $TMPFILE
48 fi
49
50 cp /dev/null $OUT1
51
52 eval $PREP_CMD
53
54 $FSCK $FSCK_OPT  -N test_filesys $TMPFILE >> $OUT1.new 2>&1
55 status=$?
56 echo Exit status is $status >> $OUT1.new
57 sed -f $cmd_dir/filter.sed $OUT1.new >> $OUT1
58 rm -f $OUT1.new
59
60 if [ "$ONE_PASS_ONLY" != "true" ]; then
61         $FSCK $SECOND_FSCK_OPT -N test_filesys $TMPFILE > $OUT2.new 2>&1 
62         status=$?
63         echo Exit status is $status >> $OUT2.new
64         sed -f $cmd_dir/filter.sed $OUT2.new > $OUT2
65         rm -f $OUT2.new
66 fi
67
68 eval $AFTER_CMD
69
70 if [ "$SKIP_VERIFY" != "true" ] ; then
71         rm -f $test_name.ok $test_name.failed
72         cmp -s $OUT1 $EXP1
73         status1=$?
74         if [ "$ONE_PASS_ONLY" != "true" ]; then
75                 cmp -s $OUT2 $EXP2
76                 status2=$?
77         else
78                 status2=0
79         fi
80         if [ "$PASS_ZERO" = "true" ]; then
81                 cmp -s $test_name.0.log $test_dir/expect.0
82                 status3=$?
83         else
84                 status3=0
85         fi
86
87         if [ -z "$test_description" ] ; then
88                 description="$test_name"
89         else
90                 description="$test_name: $test_description"
91         fi
92
93         if [ "$status1" -eq 0 -a "$status2" -eq 0 -a "$status3" -eq 0 ] ; then
94                 echo "$description: ok"
95                 touch $test_name.ok
96         else
97                 echo "$description: failed"
98                 rm -f $test_name.failed
99                 if [ "$PASS_ZERO" = "true" ]; then
100                         diff $DIFF_OPTS $test_dir/expect.0 \
101                                 $test_name.0.log >> $test_name.failed
102                 fi
103                 diff $DIFF_OPTS $EXP1 $OUT1 >> $test_name.failed
104                 if [ "$ONE_PASS_ONLY" != "true" ]; then
105                         diff $DIFF_OPTS $EXP2 $OUT2 >> $test_name.failed
106                 fi
107         fi
108         rm -f tmp_expect
109 fi
110
111 if [ "$SKIP_CLEANUP" != "true" ] ; then
112         unset IMAGE FSCK_OPT SECOND_FSCK_OPT OUT1 OUT2 EXP1 EXP2 
113         unset SKIP_VERIFY SKIP_CLEANUP SKIP_GUNZIP ONE_PASS_ONLY PREP_CMD
114         unset DESCRIPTION SKIP_UNLINK AFTER_CMD PASS_ZERO
115 fi
116