File: regression.core.sh

package info (click to toggle)
pacemaker 1.0.9.1%2Bhg15626-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 34,668 kB
  • ctags: 5,645
  • sloc: xml: 87,444; ansic: 57,853; python: 11,479; sh: 5,255; makefile: 663; perl: 387; sed: 262
file content (181 lines) | stat: -rwxr-xr-x 4,535 bytes parent folder | download
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash

 # Copyright (C) 2004 Andrew Beekhof <andrew@beekhof.net>
 # 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public
 # License as published by the Free Software Foundation; either
 # version 2.1 of the License, or (at your option) any later version.
 # 
 # This software is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # General Public License for more details.
 # 
 # You should have received a copy of the GNU General Public
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #

verbose=$1
io_dir=test10
diff_opts="--ignore-all-space -u -N"
failed=.regression.failed.diff
# zero out the error log
> $failed

num_failed=0
function ptest() {
    if [ "x$VALGRIND_CMD" != "x" ]; then
	ptest_cmd=`which ptest`

    elif [ -x ptest ]; then
	ptest_cmd=./ptest

    else
	echo No ptest executable in current directory using installed version
	ptest_cmd=`which ptest`
    fi
    #echo $VALGRIND_CMD $ptest_cmd $*
    $VALGRIND_CMD $ptest_cmd $*
}

function do_test {

    expected_rc=0

    base=$1; shift
    name=$1; shift
    input=$io_dir/${base}.xml
    output=$io_dir/${base}.pe.out
    expected=$io_dir/${base}.exp
    te_output=$io_dir/${base}.te.out
    te_expected=$io_dir/${base}.te.exp
    dot_output=$io_dir/${base}.pe.dot
    dot_expected=$io_dir/${base}.dot
    dot_png=$io_dir/${base}.png
    scores=$io_dir/${base}.scores
    score_output=$io_dir/${base}.pe.scores

    if [ "x$1" = "x--rc" ]; then
	expected_rc=$2
	shift; shift;
    fi

    if [ ! -f $input ]; then
	echo "Test $name	($base)...	Error (PE : input)";
	num_failed=`expr $num_failed + 1`
	return;
    fi

    echo "Test $base	:	$name";
    if [ "$create_mode" != "true" -a ! -f $expected ]; then
	echo "	Error (PE : expected)";
#	return;
    fi

#    ../admin/crm_verify -X $input
    ptest -x $input -D $dot_output -G $output -S -s $* > $score_output
    rc=$?
    if [ $rc != $expected_rc ]; then
	echo "	* Failed (PE : rc=$rc)";
	num_failed=`expr $num_failed + 1`
    fi

    if [ -s core ]; then
	echo "	Moved core to core.${base}";
	num_failed=`expr $num_failed + 1`
	rm -f core.$base
	mv core core.$base
    fi

    if [ ! -s $output ]; then
	echo "	Error (PE : no graph)";
	num_failed=`expr $num_failed + 1`
	rm $output
	return;
#    else
#	mv $output $output.sed
#	cat $output.sed | sed 's/id=.[0-9]*.\ //g' >> $output
    fi

    if [ ! -s $dot_output ]; then
	echo "	Error (PE : no dot-file)";
	num_failed=`expr $num_failed + 1`
	rm $output
	return;
    else
	echo "digraph \"g\" {" > $dot_output.sort
	LC_ALL=POSIX sort -u $dot_output | grep -v -e ^}$ -e digraph >> $dot_output.sort
	echo "}" >> $dot_output.sort
	mv -f $dot_output.sort $dot_output
    fi

    if [ ! -s $score_output ]; then
	echo "	Error (PE : no scores)";
	num_failed=`expr $num_failed + 1`
	rm $output
	return;
    fi

    if [ "$create_mode" = "true" ]; then
	cp "$output" "$expected"
	cp "$dot_output" "$dot_expected"
	cp "$score_output" "$scores"
	echo "	Created expected output (PE)" 
    fi

    diff $diff_opts $dot_expected $dot_output >/dev/null
    rc=$?
    if [ $rc != 0 ]; then
	echo "	* Failed (PE : dot)";
	diff $diff_opts $dot_expected $dot_output 2>/dev/null >> $failed
	echo "" >> $failed
	num_failed=`expr $num_failed + 1`
    else 
	rm $dot_output
    fi

    diff $diff_opts $expected $output >/dev/null
    rc2=$?
    if [ $rc2 != 0 ]; then
	echo "	* Failed (PE : raw)";
	diff $diff_opts $expected $output 2>/dev/null >> $failed
	echo "" >> $failed
	num_failed=`expr $num_failed + 1`
    else 
	rm $output
    fi
    
    diff $diff_opts $scores $score_output >/dev/null
    rc=$?
    if [ $rc != 0 ]; then
	echo "	* Failed (PE : scores)";
	diff $diff_opts $scores $score_output 2>/dev/null >> $failed
	echo "" >> $failed
	num_failed=`expr $num_failed + 1`
    else 
	rm $score_output
    fi

    rm -f $output
}

function test_results {
    if [ $num_failed != 0 ]; then
	if [ -s $failed ]; then
	    if [ "$verbose" = "-v" ]; then
		echo "Results of $num_failed failed tests...."
		less $failed
	    else
		echo "Results of $num_failed failed tests are in $failed...."
		echo "Use $0 -v to display them automatically."
	    fi
	else
	    echo "$num_failed tests failed (no diff results)"
	    rm $failed
	fi
    fi
    exit $num_failed
}