summaryrefslogtreecommitdiffstats
path: root/tests/f_convert_bmap_and_extent/script
blob: f61c8e2e3448d833bbb07b98ba0857f1f05c230f (plain)
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
110
111
112
113
114
115
116
117
if [ "$DESCRIPTION"x != x ]; then
	test_description="$DESCRIPTION"
fi
if [ "$IMAGE"x = x ]; then
	IMAGE=$test_dir/image.gz
fi

if [ "$FSCK_OPT"x = x ]; then
	FSCK_OPT=-yf
fi

if [ "$SECOND_FSCK_OPT"x = x ]; then
	SECOND_FSCK_OPT=-yf
fi

if [ "$OUT1"x = x ]; then
	OUT1=$test_name.1.log
fi

if [ "$OUT2"x = x ]; then
	OUT2=$test_name.2.log
fi

if [ "$EXP1"x = x ]; then
	if [ -f $test_dir/expect.1.gz ]; then
		EXP1=$test_name.1.tmp
		gunzip < $test_dir/expect.1.gz > $EXP1
	else
		EXP1=$test_dir/expect.1
	fi
fi

if [ "$EXP2"x = x ]; then
	if [ -f $test_dir/expect.2.gz ]; then
		EXP2=$test_name.2.tmp
		gunzip < $test_dir/expect.2.gz > $EXP2
	else
		EXP2=$test_dir/expect.2
	fi
fi

if [ "$SKIP_GUNZIP" != "true" ] ; then
	gunzip < $IMAGE > $TMPFILE
fi

cp /dev/null $OUT1

eval $PREP_CMD

echo 'stat /a' > $TMPFILE.cmd
echo 'ex /zero' >> $TMPFILE.cmd
$DEBUGFS -f $TMPFILE.cmd $TMPFILE > $OUT1.new 2>&1
rm -f $TMPFILE.cmd
$TUNE2FS -O extent $TMPFILE >> $OUT1.new 2>&1
$FSCK $FSCK_OPT -E bmap2extent -N test_filesys $TMPFILE >> $OUT1.new 2>&1
status=$?
echo Exit status is $status >> $OUT1.new
sed -f $cmd_dir/filter.sed $OUT1.new > $OUT1

$FSCK $SECOND_FSCK_OPT -N test_filesys $TMPFILE > $OUT2.new 2>&1 
status=$?
echo Exit status is $status >> $OUT2.new
echo 'ex /a' > $TMPFILE.cmd
echo 'ex /zero' >> $TMPFILE.cmd
$DEBUGFS -f $TMPFILE.cmd $TMPFILE >> $OUT2.new 2>&1
sed -f $cmd_dir/filter.sed $OUT2.new > $OUT2
rm -f $TMPFILE.cmd $OUT1.new $OUT2.new

eval $AFTER_CMD

if [ "$SKIP_VERIFY" != "true" ] ; then
	rm -f $test_name.ok $test_name.failed
	cmp -s $OUT1 $EXP1
	status1=$?
	if [ "$ONE_PASS_ONLY" != "true" ]; then
		cmp -s $OUT2 $EXP2
		status2=$?
	else
		status2=0
	fi
	if [ "$PASS_ZERO" = "true" ]; then
		cmp -s $test_name.0.log	$test_dir/expect.0
		status3=$?
	else
		status3=0
	fi

	if [ -z "$test_description" ] ; then
		description="$test_name"
	else
		description="$test_name: $test_description"
	fi

	if [ "$status1" -eq 0 -a "$status2" -eq 0 -a "$status3" -eq 0 ] ; then
		echo "$description: ok"
		touch $test_name.ok
	else
		echo "$description: failed"
		rm -f $test_name.failed
		if [ "$PASS_ZERO" = "true" ]; then
			diff $DIFF_OPTS $test_dir/expect.0 \
				$test_name.0.log >> $test_name.failed
		fi
		diff $DIFF_OPTS $EXP1 $OUT1 >> $test_name.failed
		if [ "$ONE_PASS_ONLY" != "true" ]; then
			diff $DIFF_OPTS $EXP2 $OUT2 >> $test_name.failed
		fi
	fi
	rm -f tmp_expect
fi

if [ "$SKIP_CLEANUP" != "true" ] ; then
	unset IMAGE FSCK_OPT SECOND_FSCK_OPT OUT1 OUT2 EXP1 EXP2 
	unset SKIP_VERIFY SKIP_CLEANUP SKIP_GUNZIP ONE_PASS_ONLY PREP_CMD
	unset DESCRIPTION SKIP_UNLINK AFTER_CMD PASS_ZERO
fi