Bug 1483478 - Store memory dump artifacts in awsy-lite; r=glandium
authorGeoff Brown <gbrown@mozilla.com>
Mon, 26 Nov 2018 17:59:05 -0700
changeset 507285 510f4bccd603a6a64b514e174c5d9e52d7afd185
parent 507284 4b797608c0576725cc6f5c46f2255a268a05f3e0
child 507398 e321cef882b8caf0063cf9d17eec89a8b3170606
child 507400 456275c5ddac8e6c7cd9a71a4f10ed56c0f1bfc3
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1483478
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1483478 - Store memory dump artifacts in awsy-lite; r=glandium
mobile/android/tests/browser/chrome/test_awsy_lite.html
testing/mochitest/runtestsremote.py
--- a/mobile/android/tests/browser/chrome/test_awsy_lite.html
+++ b/mobile/android/tests/browser/chrome/test_awsy_lite.html
@@ -38,16 +38,31 @@
   SimpleTest.waitForExplicitFinish();
   SimpleTest.requestLongerTimeout(3); // several long waits and GCs make for a long-running test
   SimpleTest.requestCompleteLog(); // so that "PERFHERDER_DATA" can be scraped from the log
 
   function checkpoint(aName) {
     var mrm = Cc["@mozilla.org/memory-reporter-manager;1"].getService(Ci.nsIMemoryReporterManager);
     gResults.push( { name: aName, resident: mrm.resident } );
     info(`${aName} | Resident Memory: ${mrm.resident}`);
+    var env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
+    var upload = env.get("MOZ_UPLOAD_DIR");
+    if (upload) {
+        var path = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
+        path.initWithPath(upload);
+        if (!path.exists()) {
+            path.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
+        }
+        var fileName = aName.replace(/ /g, "_").replace(/\W/g, "") + ".json.gz";
+        path.appendRelativePath(fileName);
+        var dumper = Cc["@mozilla.org/memory-info-dumper;1"].getService(Ci.nsIMemoryInfoDumper);
+        dumper.dumpMemoryReportsToNamedFile(path.path, function() {
+            info("finished dump to " + path.path);
+        }, null, /* anonymize = */ false);
+    }
   }
 
   var browserListener = {
     onOpenWindow: function(aXulWin) {
         var win = aXulWin.docShell.domWindow;
         win.addEventListener("UIReady", function(aEvent) {
             attachTo(win);
         }, {once: true});
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -313,16 +313,21 @@ class MochiRemote(MochitestDesktop):
             del browserEnv["XPCOM_MEM_BLOAT_LOG"]
         # override mozLogs to avoid processing in MochitestDesktop base class
         self.mozLogs = None
         browserEnv["MOZ_LOG_FILE"] = os.path.join(
             self.remoteMozLog,
             self.mozLogName)
         if options.dmd:
             browserEnv['DMD'] = '1'
+        # Contents of remoteMozLog will be pulled from device and copied to the
+        # host MOZ_UPLOAD_DIR, to be made available as test artifacts. Make
+        # MOZ_UPLOAD_DIR available to the browser environment so that tests
+        # can use it as though they were running on the host.
+        browserEnv["MOZ_UPLOAD_DIR"] = self.remoteMozLog
         return browserEnv
 
     def runApp(self, *args, **kwargs):
         """front-end automation.py's `runApp` functionality until FennecRunner is written"""
 
         # automation.py/remoteautomation `runApp` takes the profile path,
         # whereas runtest.py's `runApp` takes a mozprofile object.
         if 'profileDir' not in kwargs and 'profile' in kwargs: