blob: ea926569a28da8a3a6e3bbd6789b1feac5153d9a [file] [log] [blame]
Christophe Lyonbff39612015-11-18 16:29:11 +01001#!/bin/bash
2
3mydir="`dirname $0`"
4status=0
5
Christophe Lyonca9d8302017-05-22 12:04:00 +00006[ x"$1" = x"-pass-thresh" ] && pass_thresh=$2 && shift 2
7
Christophe Lyonbff39612015-11-18 16:29:11 +01008if [ $# != 2 ]
9then
Christophe Lyonca9d8302017-05-22 12:04:00 +000010 echo "Usage: $0 [-pass-thresh pass-ratio-threshold] ref_logs new_logs"
Christophe Lyonbff39612015-11-18 16:29:11 +010011 exit 1
12fi
13
14ref_logs=$1
15new_logs=$2
16
17tmptargets=/tmp/targets.$$
18trap "rm -f ${tmptargets}" 0 1 2 3 5 9 13 15
19
20rm -f ${tmptargets}
21
Christophe Lyonbff39612015-11-18 16:29:11 +010022function html_report_print_row
23{
24 local target=${1?}
Christophe Lyon473c8162016-01-13 14:40:27 +010025 local status=${2?}
Christophe Lyon8fbc2a92015-12-02 17:46:22 +010026 local message=${3?}
Christophe Lyon803277b2017-10-16 21:39:59 +000027 local log_url=1-diff-${target}.txt
Christophe Lyonbff39612015-11-18 16:29:11 +010028 cat <<EOF
29 <tr>
30 <td>${target}</td>
Christophe Lyon473c8162016-01-13 14:40:27 +010031 <td class="$status"><a href="$log_url"><b>${message}</b></a></td>
Christophe Lyonbff39612015-11-18 16:29:11 +010032 </tr>
33EOF
34}
35
Christophe Lyon473c8162016-01-13 14:40:27 +010036# Should be called for all HTML documents (e.g. report, log, ...)
37function html_doc_print_header
38{
39 cat <<EOF
40<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
41 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
42<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
43<head>
44 <title>Report</title>
45 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
46 <link rel="stylesheet" type="text/css" href="report.css" />
47</head>
48<body>
49EOF
50}
51
Christophe Lyonbff39612015-11-18 16:29:11 +010052function html_report_print_header
53{
54 cat <<EOF
55<h1>Results comparison ${ref_logs} vs ${new_logs}</h1>
56<table border="1">
57 <tr>
58 <td><b>Target</b></td>
59 <td><b>Status</b></td>
60 </tr>
61EOF
62}
63
Christophe Lyon473c8162016-01-13 14:40:27 +010064# Should be called for all HTML documents (e.g. report, log, ...)
65function html_doc_print_footer
66{
67 cat <<EOF
68</body>
69</html>
70EOF
71}
72
Christophe Lyonbff39612015-11-18 16:29:11 +010073function html_report_print_footer
74{
75 cat <<EOF
76</table>
77EOF
78}
79
Christophe Lyonbff39612015-11-18 16:29:11 +010080# For the time being, we expect different jobs to store their results
81# in similar directories.
82
83# Build list of all build-targets validated for ${ref_logs}
84for dir in `find ${ref_logs}/ -mindepth 1 -maxdepth 1 -type d`
85do
86 basename ${dir} >> ${tmptargets}
87done
88
89# Build list of all build-targets validated for ${new_logs}
90for dir in `find ${new_logs}/ -mindepth 1 -maxdepth 1 -type d`
91do
92 basename ${dir} >> ${tmptargets}
93done
94
95if [ -s ${tmptargets} ]; then
96 buildtargets=`sort -u ${tmptargets}`
97fi
98rm -f ${tmptargets}
99
Christophe Lyon803277b2017-10-16 21:39:59 +0000100HTML_REPORT=${mydir}/0-report.html
Christophe Lyonbff39612015-11-18 16:29:11 +0100101rm -f ${HTML_REPORT} ${HTML_REPORT}.part
Christophe Lyonbff39612015-11-18 16:29:11 +0100102
Christophe Lyon473c8162016-01-13 14:40:27 +0100103html_doc_print_header > ${HTML_REPORT}.part
104html_report_print_header >> ${HTML_REPORT}.part
Christophe Lyonbff39612015-11-18 16:29:11 +0100105
Christophe Lyonabeb4f92016-01-12 14:42:02 +0100106# Gather all diffs, to concatenate them to the main report
107difflog=${mydir}/alldiffs.txt
108rm -f ${difflog}
109touch ${difflog}
110
Christophe Lyonbff39612015-11-18 16:29:11 +0100111for buildtarget in ${buildtargets}
112do
113 ref="${ref_logs}/${buildtarget}"
114 build="${new_logs}/${buildtarget}"
115 echo "REF = "${ref}
116 echo "BUILD = "${build}
117 failed=false
Christophe Lyona8755e82015-11-20 00:40:34 +0100118 improved=false
Christophe Lyon803277b2017-10-16 21:39:59 +0000119 mylog=${mydir}/1-diff-${buildtarget}.txt
Christophe Lyonbff39612015-11-18 16:29:11 +0100120 target=`echo ${buildtarget} | cut -d. -f2`
121 printf "\t# ============================================================== #\n" > ${mylog}
122 printf "\t#\t\t*** ${buildtarget} ***\n" >> ${mylog}
123 printf "\t# ============================================================== #\n\n" >> ${mylog}
Christophe Lyon8fbc2a92015-12-02 17:46:22 +0100124
Christophe Lyon473c8162016-01-13 14:40:27 +0100125 class=no-change
Christophe Lyon8fbc2a92015-12-02 17:46:22 +0100126 color=lightgreen
127 message=PASSED
Christophe Lyone0075272016-02-04 11:09:58 +0100128 ret=0
Christophe Lyon8fbc2a92015-12-02 17:46:22 +0100129
Christophe Lyone0075272016-02-04 11:09:58 +0100130 if [ -d "${build}" -a -d "${ref}" ]
131 then
132 printf "# Running on `hostname` in `pwd`\n" >> ${mylog}
133 ${mydir}/compare_tests -target ${target} \
Christophe Lyon20e676d2017-06-02 07:21:38 +0000134 ${pass_thresh:+-pass-thresh ${pass_thresh}} \
Christophe Lyone0075272016-02-04 11:09:58 +0100135 ${ref} ${build} >> ${mylog}
136 ret=$?
137 fi
Christophe Lyon8fbc2a92015-12-02 17:46:22 +0100138 if [ ! -d "${ref}" ]; then
139 printf "\t# REF RESULTS NOT PRESENT: BUILD FAILED\n" >> ${mylog}
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100140 ret=5
Christophe Lyon8fbc2a92015-12-02 17:46:22 +0100141 fi
142 if [ ! -d "${build}" ]; then
143 printf "\t# BUILD RESULTS NOT PRESENT: BUILD FAILED\n" >> ${mylog}
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100144 ret=5
Christophe Lyon8fbc2a92015-12-02 17:46:22 +0100145 fi
Christophe Lyona8755e82015-11-20 00:40:34 +0100146 case $ret in
147 0) # No change
148 ;;
149 1) # Improvement
Christophe Lyon473c8162016-01-13 14:40:27 +0100150 class=improvement
151 color=green
Christophe Lyon8fbc2a92015-12-02 17:46:22 +0100152 message=BETTER
Christophe Lyona8755e82015-11-20 00:40:34 +0100153 ;;
154 2) # Regression
Christophe Lyon473c8162016-01-13 14:40:27 +0100155 class=regression
Christophe Lyon8fbc2a92015-12-02 17:46:22 +0100156 color=red
157 message=FAILED
Christophe Lyonae7e47a2016-01-07 18:29:50 +0100158 failed=true
Christophe Lyona8755e82015-11-20 00:40:34 +0100159 ;;
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100160 3) # No common logs
Christophe Lyon473c8162016-01-13 14:40:27 +0100161 class=no-common-logs
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100162 color=red
163 message=NO-COMMON-LOGS
164 failed=true
165 ;;
166 4) # Extra logs
Christophe Lyon473c8162016-01-13 14:40:27 +0100167 class=extra-logs
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100168 color=red
169 message=EXTRA-LOGS
170 failed=true
171 ;;
172 5) # Build failed
Christophe Lyon473c8162016-01-13 14:40:27 +0100173 class=build-failed
Christophe Lyon8fbc2a92015-12-02 17:46:22 +0100174 color=darkred
175 message=BUILDFAILED
Christophe Lyonae7e47a2016-01-07 18:29:50 +0100176 failed=true
Christophe Lyonf02cb6b2016-01-12 14:32:24 +0100177 ;;
Christophe Lyona8755e82015-11-20 00:40:34 +0100178 esac
Christophe Lyonbff39612015-11-18 16:29:11 +0100179
180 ${failed} && status=1
Christophe Lyon473c8162016-01-13 14:40:27 +0100181 html_report_print_row "${buildtarget}" "$class" "$message" >> $HTML_REPORT.part
Christophe Lyonabeb4f92016-01-12 14:42:02 +0100182
183 cat ${mylog} >> ${difflog}
Christophe Lyonbff39612015-11-18 16:29:11 +0100184done
185
Christophe Lyonbff39612015-11-18 16:29:11 +0100186html_report_print_footer >> ${HTML_REPORT}.part
Christophe Lyonabeb4f92016-01-12 14:42:02 +0100187
188echo "<pre>" >> ${HTML_REPORT}.part
189cat ${difflog} >> ${HTML_REPORT}.part
190rm -f ${difflog}
191echo "</pre>" >> ${HTML_REPORT}.part
192
Christophe Lyon473c8162016-01-13 14:40:27 +0100193html_doc_print_footer >> ${HTML_REPORT}.part
Christophe Lyon473c8162016-01-13 14:40:27 +0100194
Christophe Lyonbff39612015-11-18 16:29:11 +0100195mv ${HTML_REPORT}.part ${HTML_REPORT}
Christophe Lyonbff39612015-11-18 16:29:11 +0100196
197exit ${status}