blob: 76c6476b713e7b05112096ee70ec9ab2667b10a0 (
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
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
#!/bin/bash
mydir="`dirname $0`"
status=0
[ x"$1" = x"-pass-thresh" ] && pass_thresh=$2 && shift 2
if [ $# != 2 ]
then
echo "Usage: $0 [-pass-thresh pass-ratio-threshold] ref_logs new_logs"
exit 1
fi
ref_logs=$1
new_logs=$2
tmptargets=/tmp/targets.$$
trap "rm -f ${tmptargets}" 0 1 2 3 5 9 13 15
rm -f ${tmptargets}
function html_report_print_row
{
local target=${1?}
local status=${2?}
local message=${3?}
local log_url=diff-${target}.txt
cat <<EOF
<tr>
<td>${target}</td>
<td class="$status"><a href="$log_url"><b>${message}</b></a></td>
</tr>
EOF
}
# Should be called for all HTML documents (e.g. report, log, ...)
function html_doc_print_header
{
cat <<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Report</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="report.css" />
</head>
<body>
EOF
}
function html_report_print_header
{
cat <<EOF
<h1>Results comparison ${ref_logs} vs ${new_logs}</h1>
<table border="1">
<tr>
<td><b>Target</b></td>
<td><b>Status</b></td>
</tr>
EOF
}
# Should be called for all HTML documents (e.g. report, log, ...)
function html_doc_print_footer
{
cat <<EOF
</body>
</html>
EOF
}
function html_report_print_footer
{
cat <<EOF
</table>
EOF
}
# For the time being, we expect different jobs to store their results
# in similar directories.
# Build list of all build-targets validated for ${ref_logs}
for dir in `find ${ref_logs}/ -mindepth 1 -maxdepth 1 -type d`
do
basename ${dir} >> ${tmptargets}
done
# Build list of all build-targets validated for ${new_logs}
for dir in `find ${new_logs}/ -mindepth 1 -maxdepth 1 -type d`
do
basename ${dir} >> ${tmptargets}
done
if [ -s ${tmptargets} ]; then
buildtargets=`sort -u ${tmptargets}`
fi
rm -f ${tmptargets}
HTML_REPORT=${mydir}/report.html
rm -f ${HTML_REPORT} ${HTML_REPORT}.part
html_doc_print_header > ${HTML_REPORT}.part
html_report_print_header >> ${HTML_REPORT}.part
# Gather all diffs, to concatenate them to the main report
difflog=${mydir}/alldiffs.txt
rm -f ${difflog}
touch ${difflog}
for buildtarget in ${buildtargets}
do
ref="${ref_logs}/${buildtarget}"
build="${new_logs}/${buildtarget}"
echo "REF = "${ref}
echo "BUILD = "${build}
failed=false
improved=false
mylog=${mydir}/diff-${buildtarget}.txt
target=`echo ${buildtarget} | cut -d. -f2`
printf "\t# ============================================================== #\n" > ${mylog}
printf "\t#\t\t*** ${buildtarget} ***\n" >> ${mylog}
printf "\t# ============================================================== #\n\n" >> ${mylog}
class=no-change
color=lightgreen
message=PASSED
ret=0
if [ -d "${build}" -a -d "${ref}" ]
then
printf "# Running on `hostname` in `pwd`\n" >> ${mylog}
${mydir}/compare_tests -target ${target} \
${pass_thresh:+-pass-thresh=${pass_thresh}} \
${ref} ${build} >> ${mylog}
ret=$?
fi
if [ ! -d "${ref}" ]; then
printf "\t# REF RESULTS NOT PRESENT: BUILD FAILED\n" >> ${mylog}
ret=5
fi
if [ ! -d "${build}" ]; then
printf "\t# BUILD RESULTS NOT PRESENT: BUILD FAILED\n" >> ${mylog}
ret=5
fi
case $ret in
0) # No change
;;
1) # Improvement
class=improvement
color=green
message=BETTER
;;
2) # Regression
class=regression
color=red
message=FAILED
failed=true
;;
3) # No common logs
class=no-common-logs
color=red
message=NO-COMMON-LOGS
failed=true
;;
4) # Extra logs
class=extra-logs
color=red
message=EXTRA-LOGS
failed=true
;;
5) # Build failed
class=build-failed
color=darkred
message=BUILDFAILED
failed=true
;;
esac
${failed} && status=1
html_report_print_row "${buildtarget}" "$class" "$message" >> $HTML_REPORT.part
cat ${mylog} >> ${difflog}
done
html_report_print_footer >> ${HTML_REPORT}.part
echo "<pre>" >> ${HTML_REPORT}.part
cat ${difflog} >> ${HTML_REPORT}.part
rm -f ${difflog}
echo "</pre>" >> ${HTML_REPORT}.part
html_doc_print_footer >> ${HTML_REPORT}.part
mv ${HTML_REPORT}.part ${HTML_REPORT}
exit ${status}
|