Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | mydir="`dirname $0`" |
| 4 | status=0 |
| 5 | |
Laurent Alfonsi | df859d3 | 2022-11-21 14:59:49 +0100 | [diff] [blame] | 6 | while true |
| 7 | do |
| 8 | case "x$1" in |
| 9 | "x-pass-thresh") |
| 10 | pass_thresh=$2 |
| 11 | shift 2 |
| 12 | ;; |
| 13 | "x-compr") |
| 14 | compr=$2 |
| 15 | shift 2 |
| 16 | ;; |
| 17 | *) |
| 18 | break |
| 19 | ;; |
| 20 | esac |
| 21 | done |
Christophe Lyon | ca9d830 | 2017-05-22 12:04:00 +0000 | [diff] [blame] | 22 | |
Christophe Lyon | a8d87b8 | 2018-04-27 14:41:22 +0100 | [diff] [blame] | 23 | if [ $# -lt 2 ] |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 24 | then |
Laurent Alfonsi | df859d3 | 2022-11-21 14:59:49 +0100 | [diff] [blame] | 25 | echo "Usage: $0 [-pass-thresh pass-ratio-threshold] [-compr compression-scheme] ref_logs new_logs [target ...]" |
Christophe Lyon | a8d87b8 | 2018-04-27 14:41:22 +0100 | [diff] [blame] | 26 | echo " If no target name is provided, detect which targets have been built and compare their results" |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 27 | exit 1 |
| 28 | fi |
| 29 | |
| 30 | ref_logs=$1 |
| 31 | new_logs=$2 |
Christophe Lyon | a8d87b8 | 2018-04-27 14:41:22 +0100 | [diff] [blame] | 32 | shift 2 |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 33 | |
| 34 | tmptargets=/tmp/targets.$$ |
| 35 | trap "rm -f ${tmptargets}" 0 1 2 3 5 9 13 15 |
| 36 | |
| 37 | rm -f ${tmptargets} |
| 38 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 39 | function html_report_print_row |
| 40 | { |
| 41 | local target=${1?} |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 42 | local status=${2?} |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 43 | local message=${3?} |
Christophe Lyon | 803277b | 2017-10-16 21:39:59 +0000 | [diff] [blame] | 44 | local log_url=1-diff-${target}.txt |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 45 | cat <<EOF |
| 46 | <tr> |
| 47 | <td>${target}</td> |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 48 | <td class="$status"><a href="$log_url"><b>${message}</b></a></td> |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 49 | </tr> |
| 50 | EOF |
| 51 | } |
| 52 | |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 53 | # Should be called for all HTML documents (e.g. report, log, ...) |
| 54 | function html_doc_print_header |
| 55 | { |
| 56 | cat <<EOF |
| 57 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
| 58 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 59 | <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> |
| 60 | <head> |
| 61 | <title>Report</title> |
| 62 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> |
| 63 | <link rel="stylesheet" type="text/css" href="report.css" /> |
| 64 | </head> |
| 65 | <body> |
| 66 | EOF |
| 67 | } |
| 68 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 69 | function html_report_print_header |
| 70 | { |
| 71 | cat <<EOF |
| 72 | <h1>Results comparison ${ref_logs} vs ${new_logs}</h1> |
| 73 | <table border="1"> |
| 74 | <tr> |
| 75 | <td><b>Target</b></td> |
| 76 | <td><b>Status</b></td> |
| 77 | </tr> |
| 78 | EOF |
| 79 | } |
| 80 | |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 81 | # Should be called for all HTML documents (e.g. report, log, ...) |
| 82 | function html_doc_print_footer |
| 83 | { |
| 84 | cat <<EOF |
| 85 | </body> |
| 86 | </html> |
| 87 | EOF |
| 88 | } |
| 89 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 90 | function html_report_print_footer |
| 91 | { |
| 92 | cat <<EOF |
| 93 | </table> |
| 94 | EOF |
| 95 | } |
| 96 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 97 | # For the time being, we expect different jobs to store their results |
| 98 | # in similar directories. |
| 99 | |
| 100 | # Build list of all build-targets validated for ${ref_logs} |
| 101 | for dir in `find ${ref_logs}/ -mindepth 1 -maxdepth 1 -type d` |
| 102 | do |
| 103 | basename ${dir} >> ${tmptargets} |
| 104 | done |
| 105 | |
| 106 | # Build list of all build-targets validated for ${new_logs} |
| 107 | for dir in `find ${new_logs}/ -mindepth 1 -maxdepth 1 -type d` |
| 108 | do |
| 109 | basename ${dir} >> ${tmptargets} |
| 110 | done |
| 111 | |
Christophe Lyon | a8d87b8 | 2018-04-27 14:41:22 +0100 | [diff] [blame] | 112 | buildtargets= |
Christophe Lyon | 1bead62 | 2018-05-16 22:51:59 +0000 | [diff] [blame] | 113 | # If the user provided no target name, use what we detected |
| 114 | if [ $# -ne 0 ]; then |
| 115 | # Otherwise, use what the user provided, which may be incomplete |
| 116 | # and not include builder_type for instance |
| 117 | rm -f ${tmptargets} |
| 118 | for mytarget in "$@" |
| 119 | do |
| 120 | for dir in `ls -d ${ref_logs}/*${mytarget} ${new_logs}/*${mytarget}` |
| 121 | do |
| 122 | basename ${dir} >> ${tmptargets} |
| 123 | done |
| 124 | done |
| 125 | fi |
| 126 | if [ -s ${tmptargets} ]; then |
| 127 | buildtargets=`sort -u ${tmptargets}` |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 128 | fi |
| 129 | rm -f ${tmptargets} |
| 130 | |
Christophe Lyon | 803277b | 2017-10-16 21:39:59 +0000 | [diff] [blame] | 131 | HTML_REPORT=${mydir}/0-report.html |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 132 | rm -f ${HTML_REPORT} ${HTML_REPORT}.part |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 133 | |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 134 | html_doc_print_header > ${HTML_REPORT}.part |
| 135 | html_report_print_header >> ${HTML_REPORT}.part |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 136 | |
Christophe Lyon | abeb4f9 | 2016-01-12 14:42:02 +0100 | [diff] [blame] | 137 | # Gather all diffs, to concatenate them to the main report |
| 138 | difflog=${mydir}/alldiffs.txt |
| 139 | rm -f ${difflog} |
| 140 | touch ${difflog} |
| 141 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 142 | for buildtarget in ${buildtargets} |
| 143 | do |
| 144 | ref="${ref_logs}/${buildtarget}" |
| 145 | build="${new_logs}/${buildtarget}" |
| 146 | echo "REF = "${ref} |
| 147 | echo "BUILD = "${build} |
| 148 | failed=false |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 149 | improved=false |
Christophe Lyon | 803277b | 2017-10-16 21:39:59 +0000 | [diff] [blame] | 150 | mylog=${mydir}/1-diff-${buildtarget}.txt |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 151 | target=`echo ${buildtarget} | cut -d. -f2` |
| 152 | printf "\t# ============================================================== #\n" > ${mylog} |
| 153 | printf "\t#\t\t*** ${buildtarget} ***\n" >> ${mylog} |
| 154 | printf "\t# ============================================================== #\n\n" >> ${mylog} |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 155 | |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 156 | class=no-change |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 157 | color=lightgreen |
| 158 | message=PASSED |
Christophe Lyon | e007527 | 2016-02-04 11:09:58 +0100 | [diff] [blame] | 159 | ret=0 |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 160 | |
Christophe Lyon | e007527 | 2016-02-04 11:09:58 +0100 | [diff] [blame] | 161 | if [ -d "${build}" -a -d "${ref}" ] |
| 162 | then |
| 163 | printf "# Running on `hostname` in `pwd`\n" >> ${mylog} |
| 164 | ${mydir}/compare_tests -target ${target} \ |
Christophe Lyon | 20e676d | 2017-06-02 07:21:38 +0000 | [diff] [blame] | 165 | ${pass_thresh:+-pass-thresh ${pass_thresh}} \ |
Laurent Alfonsi | df859d3 | 2022-11-21 14:59:49 +0100 | [diff] [blame] | 166 | ${compr:+-compr ${compr}} \ |
Christophe Lyon | e007527 | 2016-02-04 11:09:58 +0100 | [diff] [blame] | 167 | ${ref} ${build} >> ${mylog} |
| 168 | ret=$? |
| 169 | fi |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 170 | if [ ! -d "${ref}" ]; then |
| 171 | printf "\t# REF RESULTS NOT PRESENT: BUILD FAILED\n" >> ${mylog} |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 172 | ret=5 |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 173 | fi |
| 174 | if [ ! -d "${build}" ]; then |
| 175 | printf "\t# BUILD RESULTS NOT PRESENT: BUILD FAILED\n" >> ${mylog} |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 176 | ret=5 |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 177 | fi |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 178 | case $ret in |
| 179 | 0) # No change |
| 180 | ;; |
| 181 | 1) # Improvement |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 182 | class=improvement |
| 183 | color=green |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 184 | message=BETTER |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 185 | ;; |
| 186 | 2) # Regression |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 187 | class=regression |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 188 | color=red |
| 189 | message=FAILED |
Christophe Lyon | ae7e47a | 2016-01-07 18:29:50 +0100 | [diff] [blame] | 190 | failed=true |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 191 | ;; |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 192 | 3) # No common logs |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 193 | class=no-common-logs |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 194 | color=red |
| 195 | message=NO-COMMON-LOGS |
| 196 | failed=true |
| 197 | ;; |
| 198 | 4) # Extra logs |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 199 | class=extra-logs |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 200 | color=red |
| 201 | message=EXTRA-LOGS |
| 202 | failed=true |
| 203 | ;; |
| 204 | 5) # Build failed |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 205 | class=build-failed |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 206 | color=darkred |
| 207 | message=BUILDFAILED |
Christophe Lyon | ae7e47a | 2016-01-07 18:29:50 +0100 | [diff] [blame] | 208 | failed=true |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 209 | ;; |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 210 | esac |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 211 | |
| 212 | ${failed} && status=1 |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 213 | html_report_print_row "${buildtarget}" "$class" "$message" >> $HTML_REPORT.part |
Christophe Lyon | abeb4f9 | 2016-01-12 14:42:02 +0100 | [diff] [blame] | 214 | |
| 215 | cat ${mylog} >> ${difflog} |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 216 | done |
| 217 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 218 | html_report_print_footer >> ${HTML_REPORT}.part |
Christophe Lyon | abeb4f9 | 2016-01-12 14:42:02 +0100 | [diff] [blame] | 219 | |
| 220 | echo "<pre>" >> ${HTML_REPORT}.part |
| 221 | cat ${difflog} >> ${HTML_REPORT}.part |
| 222 | rm -f ${difflog} |
| 223 | echo "</pre>" >> ${HTML_REPORT}.part |
| 224 | |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 225 | html_doc_print_footer >> ${HTML_REPORT}.part |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 226 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 227 | mv ${HTML_REPORT}.part ${HTML_REPORT} |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 228 | |
| 229 | exit ${status} |