Bug 821425 - Flexible env variable support for remote cpp unit tests; r=jmaher
authorGeoff Brown <gbrown@mozilla.com>
Thu, 03 Jan 2013 13:02:04 -0700
changeset 123061 05cfc19ac6e1e99d9f193ba7ed515440448e33e3
parent 123060 386333461d424e5f1e5db7ee619f6c6143a5d1ef
child 123062 354fcf80053a9bae14beb548656ea7ef20ea8cc3
push idunknown
push userunknown
push dateunknown
reviewersjmaher
bugs821425
milestone20.0a1
Bug 821425 - Flexible env variable support for remote cpp unit tests; r=jmaher
testing/remotecppunittests.py
--- a/testing/remotecppunittests.py
+++ b/testing/remotecppunittests.py
@@ -63,16 +63,26 @@ class RemoteCPPUnitTests(cppunittests.CP
 
     def build_environment(self):
         env = self.build_core_environment()
         env['LD_LIBRARY_PATH'] = self.remote_bin_dir
         env["TMPDIR"]=self.remote_tmp_dir
         env["HOME"]=self.remote_home_dir
         env["MOZILLA_FIVE_HOME"] = self.remote_home_dir
         env["MOZ_XRE_DIR"] = self.remote_bin_dir
+        if self.options.add_env:
+            for envdef in self.options.add_env:
+                envdef_parts = envdef.split("=", 1)
+                if len(envdef_parts) == 2:
+                    env[envdef_parts[0]] = envdef_parts[1]
+                elif len(envdef_parts) == 1:
+                    env[envdef_parts[0]] = ""
+                else:
+                    print >> sys.stderr, "warning: invalid --addEnv option skipped: "+envdef
+
         return env
 
     def run_one_test(self, prog, env, symbols_path=None):
         """
         Run a single C++ unit test program remotely.
 
         Arguments:
         * prog: The path to the test program to run.
@@ -133,16 +143,21 @@ class RemoteCPPUnittestOptions(cppunitte
 
         self.add_option("--remoteTestRoot", action = "store",
                     type = "string", dest = "remote_test_root",
                     help = "remote directory to use as test root (eg. /data/local/tests)")
         # /data/local/tests is used because it is usually not possible to set +x permissions
         # on binaries on /mnt/sdcard
         defaults["remote_test_root"] = "/data/local/tests"
 
+        self.add_option("--addEnv", action = "append",
+                    type = "string", dest = "add_env",
+                    help = "additional remote environment variable definitions (eg. --addEnv \"somevar=something\")")
+        defaults["add_env"] = None
+
         self.set_defaults(**defaults)
 
 def main():
     parser = RemoteCPPUnittestOptions()
     options, args = parser.parse_args()
     if not args:
         print >>sys.stderr, """Usage: %s <test binary> [<test binary>...]""" % sys.argv[0]
         sys.exit(1)