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