diff --git a/build/automation.py.in b/build/automation.py.in index cc95f7b18ce9..26d7a518e650 100644 --- a/build/automation.py.in +++ b/build/automation.py.in @@ -159,6 +159,7 @@ class Automation(object): def __init__(self): self.log = _log self.lastTestSeen = "automation.py" + self.haveDumpedScreen = False def setServerInfo(self, webServer = _DEFAULT_WEB_SERVER, @@ -655,8 +656,34 @@ user_pref("camino.use_system_proxy_settings", false); // Camino-only, harmless t def killPid(self, pid): os.kill(pid, signal.SIGKILL) + if UNIXISH: + def dumpScreen(self, utilityPath): + self.haveDumpedScreen = True; + + screentopng = os.path.join(utilityPath, "screentopng") + try: + dumper = self.Process([screentopng], bufsize=-1, + stdout=subprocess.PIPE, close_fds=True) + except OSError, err: + self.log.info("Failed to start %s for screenshot: %s", + screentopng, err.strerror) + return + + image = dumper.stdout.read() + status = dumper.wait() + if status != 0: + self.log.info("screentopng exited with code %d", status) + return + + import base64 + encoded = base64.b64encode(image) + self.log.info("SCREENSHOT: data:image/png;base64,%s", encoded) + def killAndGetStack(self, proc, utilityPath, debuggerInfo): """Kill the process, preferrably in a way that gets us a stack trace.""" + if self.UNIXISH and not debuggerInfo and not self.haveDumpedScreen: + self.dumpScreen(utilityPath) + if self.CRASHREPORTER and not debuggerInfo: if self.UNIXISH: # ABRT will get picked up by Breakpad's signal handler @@ -710,6 +737,9 @@ user_pref("camino.use_system_proxy_settings", false); // Camino-only, harmless t if stackFixerFunction: line = stackFixerFunction(line) self.log.info(line.rstrip()) + if self.UNIXISH and not debuggerInfo and not self.haveDumpedScreen and "TEST-UNEXPECTED-FAIL" in line and "Test timed out." in line: + self.dumpScreen(utilityPath) + (line, didTimeout) = self.readWithTimeout(logsource, timeout) if not hitMaxTime and maxTime and datetime.now() - startTime > timedelta(seconds = maxTime): # Kill the application, but continue reading from stack fixer so as not to deadlock on stackFixerProcess.wait(). diff --git a/testing/mochitest/Makefile.in b/testing/mochitest/Makefile.in index 7cf20d7b8674..0a20c80c7d99 100644 --- a/testing/mochitest/Makefile.in +++ b/testing/mochitest/Makefile.in @@ -145,6 +145,10 @@ ifeq ($(OS_ARCH),Linux) TEST_HARNESS_BINS += fix-linux-stack.pl endif +ifeq (gtk2_1,$(MOZ_WIDGET_TOOLKIT)_$(MOZ_X11)) +TEST_HARNESS_BINS += screentopng +endif + # Components / typelibs that don't get packaged with # the build, but that we need for the test harness. TEST_HARNESS_COMPONENTS := \