diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2017-03-31 17:07:30 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-04-01 23:28:20 +0100 |
commit | 034702f52070c495415db83e18e77fbe6632e54e (patch) | |
tree | c1e242182134e0cb5ce37b6b51696c694d8682cd /scripts/lib/build_perf | |
parent | 9f299876f716f253b0a3d70eb4473a023c593fc5 (diff) | |
download | poky-034702f52070c495415db83e18e77fbe6632e54e.tar.gz |
scripts/contrib: add oe-build-perf-report-email
Script for sending build perf test reports as an email. Mangles an html
report, generated by oe-build-perf-report, into a format suitable for
html emails. Supports multipart emails where a plaintext alternative can
be included in the same email.
Dependencies required to be installed on the host:
- phantomjs
- optipng
[YOCTO #10931]
(From OE-Core rev: 9e97ff174458f7245fc27a4c407f21a9d2e317ab)
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/build_perf')
-rw-r--r-- | scripts/lib/build_perf/scrape-html-report.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/lib/build_perf/scrape-html-report.js b/scripts/lib/build_perf/scrape-html-report.js new file mode 100644 index 0000000000..05a1f57001 --- /dev/null +++ b/scripts/lib/build_perf/scrape-html-report.js | |||
@@ -0,0 +1,56 @@ | |||
1 | var fs = require('fs'); | ||
2 | var system = require('system'); | ||
3 | var page = require('webpage').create(); | ||
4 | |||
5 | // Examine console log for message from chart drawing | ||
6 | page.onConsoleMessage = function(msg) { | ||
7 | console.log(msg); | ||
8 | if (msg === "ALL CHARTS READY") { | ||
9 | window.charts_ready = true; | ||
10 | } | ||
11 | else if (msg.slice(0, 11) === "CHART READY") { | ||
12 | var chart_id = msg.split(" ")[2]; | ||
13 | console.log('grabbing ' + chart_id); | ||
14 | var png_data = page.evaluate(function (chart_id) { | ||
15 | var chart_div = document.getElementById(chart_id + '_png'); | ||
16 | return chart_div.outerHTML; | ||
17 | }, chart_id); | ||
18 | fs.write(args[2] + '/' + chart_id + '.png', png_data, 'w'); | ||
19 | } | ||
20 | }; | ||
21 | |||
22 | // Check command line arguments | ||
23 | var args = system.args; | ||
24 | if (args.length != 3) { | ||
25 | console.log("USAGE: " + args[0] + " REPORT_HTML OUT_DIR\n"); | ||
26 | phantom.exit(1); | ||
27 | } | ||
28 | |||
29 | // Open the web page | ||
30 | page.open(args[1], function(status) { | ||
31 | if (status == 'fail') { | ||
32 | console.log("Failed to open file '" + args[1] + "'"); | ||
33 | phantom.exit(1); | ||
34 | } | ||
35 | }); | ||
36 | |||
37 | // Check status every 100 ms | ||
38 | interval = window.setInterval(function () { | ||
39 | //console.log('waiting'); | ||
40 | if (window.charts_ready) { | ||
41 | clearTimeout(timer); | ||
42 | clearInterval(interval); | ||
43 | |||
44 | var fname = args[1].replace(/\/+$/, "").split("/").pop() | ||
45 | console.log("saving " + fname); | ||
46 | fs.write(args[2] + '/' + fname, page.content, 'w'); | ||
47 | phantom.exit(0); | ||
48 | } | ||
49 | }, 100); | ||
50 | |||
51 | // Time-out after 10 seconds | ||
52 | timer = window.setTimeout(function () { | ||
53 | clearInterval(interval); | ||
54 | console.log("ERROR: timeout"); | ||
55 | phantom.exit(1); | ||
56 | }, 10000); | ||