Add a timeout to the graphics sanity test. (bug 1195623, r=mchang)

This commit is contained in:
David Anderson 2015-09-03 20:58:48 -07:00
parent f662bda0f4
commit 50ca54ceaf

View File

@ -20,13 +20,14 @@ const DEVICE_PREF="sanity-test.device-id";
const VERSION_PREF="sanity-test.version";
const DISABLE_VIDEO_PREF="media.hardware-video-decoding.failed";
const RUNNING_PREF="sanity-test.running";
const OS_SNAPSHOT_TIMEOUT_SEC=3;
const TIMEOUT_SEC=6;
// GRAPHICS_SANITY_TEST histogram enumeration values
const TEST_PASSED=0;
const TEST_FAILED_RENDER=1;
const TEST_FAILED_VIDEO=2;
const TEST_CRASHED=3;
const TEST_TIMEOUT=4;
// GRAPHICS_SANITY_TEST_REASON enumeration values.
const REASON_FIRST_RUN=0;
@ -64,11 +65,6 @@ function reportResult(val) {
Services.prefs.savePrefFile(null);
}
function reportSnapshotResult(val) {
let histogram = Services.telemetry.getHistogramById("GRAPHICS_SANITY_TEST_OS_SNAPSHOT");
histogram.add(val);
}
function reportTestReason(val) {
let histogram = Services.telemetry.getHistogramById("GRAPHICS_SANITY_TEST_REASON");
histogram.add(val);
@ -84,6 +80,12 @@ function annotateCrashReport(value) {
}
}
function setTimeout(aMs, aCallback) {
var timer = Cc['@mozilla.org/timer;1'].
createInstance(Ci.nsITimer);
timer.initWithCallback(aCallback, aMs, Ci.nsITimer.TYPE_ONE_SHOT);
}
function takeWindowSnapshot(win, ctx) {
// TODO: drawWindow reads back from the gpu's backbuffer, which won't catch issues with presenting
// the front buffer via the window manager. Ideally we'd use an OS level API for reading back
@ -157,6 +159,12 @@ let listener = {
this.win.onload = this.onWindowLoaded.bind(this);
this.utils = this.win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
setTimeout(TIMEOUT_SEC * 1000, () => {
if (this.win) {
reportResult(TEST_TIMEOUT);
this.endTest();
}
});
},
runSanityTest: function() {