Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | mydir="`dirname $0`" |
| 4 | status=0 |
| 5 | |
Christophe Lyon | ca9d830 | 2017-05-22 12:04:00 +0000 | [diff] [blame] | 6 | [ x"$1" = x"-pass-thresh" ] && pass_thresh=$2 && shift 2 |
| 7 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 8 | if [ $# != 2 ] |
| 9 | then |
Christophe Lyon | ca9d830 | 2017-05-22 12:04:00 +0000 | [diff] [blame] | 10 | echo "Usage: $0 [-pass-thresh pass-ratio-threshold] ref_logs new_logs" |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 11 | exit 1 |
| 12 | fi |
| 13 | |
| 14 | ref_logs=$1 |
| 15 | new_logs=$2 |
| 16 | |
| 17 | tmptargets=/tmp/targets.$$ |
| 18 | trap "rm -f ${tmptargets}" 0 1 2 3 5 9 13 15 |
| 19 | |
| 20 | rm -f ${tmptargets} |
| 21 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 22 | function html_report_print_row |
| 23 | { |
| 24 | local target=${1?} |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 25 | local status=${2?} |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 26 | local message=${3?} |
Christophe Lyon | 803277b | 2017-10-16 21:39:59 +0000 | [diff] [blame^] | 27 | local log_url=1-diff-${target}.txt |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 28 | cat <<EOF |
| 29 | <tr> |
| 30 | <td>${target}</td> |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 31 | <td class="$status"><a href="$log_url"><b>${message}</b></a></td> |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 32 | </tr> |
| 33 | EOF |
| 34 | } |
| 35 | |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 36 | # Should be called for all HTML documents (e.g. report, log, ...) |
| 37 | function 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> |
| 49 | EOF |
| 50 | } |
| 51 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 52 | function 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> |
| 61 | EOF |
| 62 | } |
| 63 | |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 64 | # Should be called for all HTML documents (e.g. report, log, ...) |
| 65 | function html_doc_print_footer |
| 66 | { |
| 67 | cat <<EOF |
| 68 | </body> |
| 69 | </html> |
| 70 | EOF |
| 71 | } |
| 72 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 73 | function html_report_print_footer |
| 74 | { |
| 75 | cat <<EOF |
| 76 | </table> |
| 77 | EOF |
| 78 | } |
| 79 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 80 | # 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} |
| 84 | for dir in `find ${ref_logs}/ -mindepth 1 -maxdepth 1 -type d` |
| 85 | do |
| 86 | basename ${dir} >> ${tmptargets} |
| 87 | done |
| 88 | |
| 89 | # Build list of all build-targets validated for ${new_logs} |
| 90 | for dir in `find ${new_logs}/ -mindepth 1 -maxdepth 1 -type d` |
| 91 | do |
| 92 | basename ${dir} >> ${tmptargets} |
| 93 | done |
| 94 | |
| 95 | if [ -s ${tmptargets} ]; then |
| 96 | buildtargets=`sort -u ${tmptargets}` |
| 97 | fi |
| 98 | rm -f ${tmptargets} |
| 99 | |
Christophe Lyon | 803277b | 2017-10-16 21:39:59 +0000 | [diff] [blame^] | 100 | HTML_REPORT=${mydir}/0-report.html |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 101 | rm -f ${HTML_REPORT} ${HTML_REPORT}.part |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 102 | |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 103 | html_doc_print_header > ${HTML_REPORT}.part |
| 104 | html_report_print_header >> ${HTML_REPORT}.part |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 105 | |
Christophe Lyon | abeb4f9 | 2016-01-12 14:42:02 +0100 | [diff] [blame] | 106 | # Gather all diffs, to concatenate them to the main report |
| 107 | difflog=${mydir}/alldiffs.txt |
| 108 | rm -f ${difflog} |
| 109 | touch ${difflog} |
| 110 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 111 | for buildtarget in ${buildtargets} |
| 112 | do |
| 113 | ref="${ref_logs}/${buildtarget}" |
| 114 | build="${new_logs}/${buildtarget}" |
| 115 | echo "REF = "${ref} |
| 116 | echo "BUILD = "${build} |
| 117 | failed=false |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 118 | improved=false |
Christophe Lyon | 803277b | 2017-10-16 21:39:59 +0000 | [diff] [blame^] | 119 | mylog=${mydir}/1-diff-${buildtarget}.txt |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 120 | 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 Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 124 | |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 125 | class=no-change |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 126 | color=lightgreen |
| 127 | message=PASSED |
Christophe Lyon | e007527 | 2016-02-04 11:09:58 +0100 | [diff] [blame] | 128 | ret=0 |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 129 | |
Christophe Lyon | e007527 | 2016-02-04 11:09:58 +0100 | [diff] [blame] | 130 | if [ -d "${build}" -a -d "${ref}" ] |
| 131 | then |
| 132 | printf "# Running on `hostname` in `pwd`\n" >> ${mylog} |
| 133 | ${mydir}/compare_tests -target ${target} \ |
Christophe Lyon | 20e676d | 2017-06-02 07:21:38 +0000 | [diff] [blame] | 134 | ${pass_thresh:+-pass-thresh ${pass_thresh}} \ |
Christophe Lyon | e007527 | 2016-02-04 11:09:58 +0100 | [diff] [blame] | 135 | ${ref} ${build} >> ${mylog} |
| 136 | ret=$? |
| 137 | fi |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 138 | if [ ! -d "${ref}" ]; then |
| 139 | printf "\t# REF RESULTS NOT PRESENT: BUILD FAILED\n" >> ${mylog} |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 140 | ret=5 |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 141 | fi |
| 142 | if [ ! -d "${build}" ]; then |
| 143 | printf "\t# BUILD RESULTS NOT PRESENT: BUILD FAILED\n" >> ${mylog} |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 144 | ret=5 |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 145 | fi |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 146 | case $ret in |
| 147 | 0) # No change |
| 148 | ;; |
| 149 | 1) # Improvement |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 150 | class=improvement |
| 151 | color=green |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 152 | message=BETTER |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 153 | ;; |
| 154 | 2) # Regression |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 155 | class=regression |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 156 | color=red |
| 157 | message=FAILED |
Christophe Lyon | ae7e47a | 2016-01-07 18:29:50 +0100 | [diff] [blame] | 158 | failed=true |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 159 | ;; |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 160 | 3) # No common logs |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 161 | class=no-common-logs |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 162 | color=red |
| 163 | message=NO-COMMON-LOGS |
| 164 | failed=true |
| 165 | ;; |
| 166 | 4) # Extra logs |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 167 | class=extra-logs |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 168 | color=red |
| 169 | message=EXTRA-LOGS |
| 170 | failed=true |
| 171 | ;; |
| 172 | 5) # Build failed |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 173 | class=build-failed |
Christophe Lyon | 8fbc2a9 | 2015-12-02 17:46:22 +0100 | [diff] [blame] | 174 | color=darkred |
| 175 | message=BUILDFAILED |
Christophe Lyon | ae7e47a | 2016-01-07 18:29:50 +0100 | [diff] [blame] | 176 | failed=true |
Christophe Lyon | f02cb6b | 2016-01-12 14:32:24 +0100 | [diff] [blame] | 177 | ;; |
Christophe Lyon | a8755e8 | 2015-11-20 00:40:34 +0100 | [diff] [blame] | 178 | esac |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 179 | |
| 180 | ${failed} && status=1 |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 181 | html_report_print_row "${buildtarget}" "$class" "$message" >> $HTML_REPORT.part |
Christophe Lyon | abeb4f9 | 2016-01-12 14:42:02 +0100 | [diff] [blame] | 182 | |
| 183 | cat ${mylog} >> ${difflog} |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 184 | done |
| 185 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 186 | html_report_print_footer >> ${HTML_REPORT}.part |
Christophe Lyon | abeb4f9 | 2016-01-12 14:42:02 +0100 | [diff] [blame] | 187 | |
| 188 | echo "<pre>" >> ${HTML_REPORT}.part |
| 189 | cat ${difflog} >> ${HTML_REPORT}.part |
| 190 | rm -f ${difflog} |
| 191 | echo "</pre>" >> ${HTML_REPORT}.part |
| 192 | |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 193 | html_doc_print_footer >> ${HTML_REPORT}.part |
Christophe Lyon | 473c816 | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 194 | |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 195 | mv ${HTML_REPORT}.part ${HTML_REPORT} |
Christophe Lyon | bff3961 | 2015-11-18 16:29:11 +0100 | [diff] [blame] | 196 | |
| 197 | exit ${status} |