Bug 799107 - minidumps not being generated from robocop test crashes (breakpad environment variables not being set properly). r=kats
☠☠ backed out by 1d60a0de1ec1 ☠ ☠
authorJoel Maher <jmaher@mozilla.com>
Mon, 15 Oct 2012 11:13:44 -0400
changeset 110422 e814e12508af61b1470d9f6f751b35fc27303283
parent 110421 45863b00372bb8735c614ab5031f9795c19b4959
child 110423 7703f0ec6770271ae06a9bd2034f898439da4168
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewerskats
bugs799107
milestone19.0a1
Bug 799107 - minidumps not being generated from robocop test crashes (breakpad environment variables not being set properly). r=kats
build/mobile/robocop/FennecNativeDriver.java.in
mobile/android/base/tests/BaseTest.java.in
testing/mochitest/runtestsremote.py
--- a/build/mobile/robocop/FennecNativeDriver.java.in
+++ b/build/mobile/robocop/FennecNativeDriver.java.in
@@ -388,17 +388,17 @@ public class FennecNativeDriver implemen
      *  Takes a string of "key=value" pairs split by \n and creates a hash table.
      */
     public static HashMap convertTextToTable(String data)
     {
         HashMap retVal = new HashMap();
 
         String[] lines = data.split("\n");
         for (int i = 0; i < lines.length; i++) {
-            String[] parts = lines[i].split("=");
+            String[] parts = lines[i].split("=", 2);
             retVal.put(parts[0].trim(), parts[1].trim());
         }
         return retVal;
     }
 
     public static void logAllStackTraces(LogLevel level) {
         StringBuffer sb = new StringBuffer();
         sb.append("Dumping ALL the threads!\n");
--- a/mobile/android/base/tests/BaseTest.java.in
+++ b/mobile/android/base/tests/BaseTest.java.in
@@ -61,16 +61,24 @@ abstract class BaseTest extends Activity
         String configFile = FennecNativeDriver.getFile(rootPath + "/robotium.config");
         HashMap config = FennecNativeDriver.convertTextToTable(configFile);
 
         // Create the intent to be used with all the important arguments.
         Intent i = new Intent(Intent.ACTION_MAIN);
         mProfile = (String)config.get("profile");
         i.putExtra("args", "-no-remote -profile " + mProfile);
 
+        String envString = (String)config.get("envvars");
+        if (envString != "") {
+            String[] envStrings = envString.split(",");
+            for (int iter = 0; iter < envStrings.length; iter++) {
+                i.putExtra("env" + iter, envStrings[iter]);
+            }
+        }
+
         // Start the activity
         setActivityIntent(i);
         mActivity = getActivity();
 
         mLogFile = (String)config.get("logfile");
         mBaseUrl = ((String)config.get("host")).replaceAll("(/$)", "");
         mRawBaseUrl = ((String)config.get("rawhost")).replaceAll("(/$)", "");
 
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -381,16 +381,51 @@ class MochiRemote(Mochitest):
         # TODO: Consider not printing to stdout because we might be duplicating output
         print '\n'.join(logFile)
         with open(self.localLog, 'w') as localLog:
             localLog.write('\n'.join(logFile))
 
         if failed > 0:
             return 1
         return 0
+
+    def buildRobotiumConfig(self, options, browserEnv):
+        deviceRoot = self._dm.getDeviceRoot()
+        fHandle = tempfile.NamedTemporaryFile(suffix='.config',
+                                              prefix='robotium-',
+                                              dir=os.getcwd(),
+                                              delete=False)
+        fHandle.write("profile=%s\n" % (self.remoteProfile))
+        fHandle.write("logfile=%s\n" % (options.remoteLogFile))
+        fHandle.write("host=http://mochi.test:8888/tests\n")
+        fHandle.write("rawhost=http://%s:%s/tests\n" % (options.remoteWebServer, options.httpPort))
+
+        if browserEnv:
+            envstr = ""
+            delim = ""
+            for key, value in browserEnv.items():
+                try:
+                    value.index(',')
+                    print "Found: Error an ',' in our value, unable to process value."
+                except ValueError, e:
+                    envstr += "%s%s=%s" % (delim, key, value)
+                    delim = ","
+
+            fHandle.write("envvars=%s\n" % envstr)
+        fHandle.close()
+
+        self._dm.removeFile(os.path.join(deviceRoot, "robotium.config"))
+        self._dm.pushFile(fHandle.name, os.path.join(deviceRoot, "robotium.config"))
+        os.unlink(fHandle.name)
+
+    def buildBrowserEnv(self, options):
+        browserEnv = Mochitest.buildBrowserEnv(self, options)
+        self.buildRobotiumConfig(options, browserEnv)
+        return browserEnv
+
         
 def main():
     scriptdir = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
     auto = RemoteAutomation(None, "fennec")
     parser = RemoteOptions(auto, scriptdir)
     options, args = parser.parse_args()
     if (options.dm_trans == "adb"):
         if (options.deviceIP):
@@ -429,31 +464,18 @@ def main():
         dm.killProcess(procName)
     
     if options.robocop != "":
         mp = manifestparser.TestManifest(strict=False)
         # TODO: pull this in dynamically
         mp.read(options.robocop)
         robocop_tests = mp.active_tests(exists=False)
 
-        fHandle = tempfile.NamedTemporaryFile(suffix='.config',
-                                              prefix='robotium-',
-                                              dir=os.getcwd(),
-                                              delete=False)
-        fHandle.write("profile=%s\n" % (mochitest.remoteProfile))
-        fHandle.write("logfile=%s\n" % (options.remoteLogFile))
-        fHandle.write("host=http://mochi.test:8888/tests\n")
-        fHandle.write("rawhost=http://%s:%s/tests\n" % (options.remoteWebServer, options.httpPort))
-        fHandle.close()
-        deviceRoot = dm.getDeviceRoot()
-      
+        deviceRoot = dm.getDeviceRoot()      
         dm.removeFile(os.path.join(deviceRoot, "fennec_ids.txt"))
-        dm.removeFile(os.path.join(deviceRoot, "robotium.config"))
-        dm.pushFile(fHandle.name, os.path.join(deviceRoot, "robotium.config"))
-        os.unlink(fHandle.name)
         fennec_ids = os.path.abspath("fennec_ids.txt")
         if not os.path.exists(fennec_ids) and options.robocopIds:
             fennec_ids = options.robocopIds
         dm.pushFile(fennec_ids, os.path.join(deviceRoot, "fennec_ids.txt"))
         options.extraPrefs.append('robocop.logfile="%s/robocop.log"' % deviceRoot)
         options.extraPrefs.append('browser.search.suggest.enabled=true')
         options.extraPrefs.append('browser.search.suggest.prompted=true')