Bug 821033 - Define TMPDIR and HOME environment variables for unit tests. r=dmose
authorGeoff Brown <gbrown@mozilla.com>
Thu, 03 Jan 2013 13:01:57 -0700
changeset 123058 79e3ae50976460a55e57bd6ba56bef594bc0dc24
parent 123057 d834b07541e05cc33e80943d6fdb3747f76e98e6
child 123059 348e89acb5f3dc8bc5d4cb71d7ab2c903ea3b331
push id3129
push userakeybl@mozilla.com
push dateMon, 07 Jan 2013 22:54:45 +0000
treeherdermozilla-aurora@090bc89ff6b4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmose
bugs821033
milestone20.0a1
Bug 821033 - Define TMPDIR and HOME environment variables for unit tests. r=dmose
testing/remotecppunittests.py
--- a/testing/remotecppunittests.py
+++ b/testing/remotecppunittests.py
@@ -16,29 +16,32 @@ log = mozlog.getLogger('remotecppunittes
 class RemoteCPPUnitTests(cppunittests.CPPUnitTests):
     def __init__(self, devmgr, options, progs):
         cppunittests.CPPUnitTests.__init__(self)
         self.options = options
         self.device = devmgr
         self.remote_test_root = self.device.getDeviceRoot() + "/cppunittests"
         self.remote_bin_dir = posixpath.join(self.remote_test_root, "b")
         self.remote_tmp_dir = posixpath.join(self.remote_test_root, "tmp")
-        self.remote_profile_dir = posixpath.join(self.remote_test_root, "p")
+        self.remote_home_dir = posixpath.join(self.remote_test_root, "h")
         if options.setup:
             self.setup_bin(progs)
 
     def setup_bin(self, progs):
         if not self.device.dirExists(self.remote_test_root):
             self.device.mkDir(self.remote_test_root)
         if self.device.dirExists(self.remote_tmp_dir):
             self.device.removeDir(self.remote_tmp_dir)
         self.device.mkDir(self.remote_tmp_dir)
         if self.device.dirExists(self.remote_bin_dir):
             self.device.removeDir(self.remote_bin_dir)
         self.device.mkDir(self.remote_bin_dir)
+        if self.device.dirExists(self.remote_home_dir):
+            self.device.removeDir(self.remote_home_dir)
+        self.device.mkDir(self.remote_home_dir)
         self.push_libs()
         self.push_progs(progs)
         self.device.chmodDir(self.remote_bin_dir)
 
     def push_libs(self):
         for file in os.listdir(self.options.local_lib):
             if file.endswith(".so"):
                 print >> sys.stderr, "Pushing %s.." % file
@@ -56,16 +59,18 @@ class RemoteCPPUnitTests(cppunittests.CP
     def push_progs(self, progs):
         for local_file in progs:
             remote_file = posixpath.join(self.remote_bin_dir, os.path.basename(local_file))
             self.device.pushFile(local_file, remote_file)
 
     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
         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.
@@ -74,21 +79,21 @@ class RemoteCPPUnitTests(cppunittests.CP
                         symbol files for producing stack traces on crash.
 
         Return True if the program exits with a zero status, False otherwise.
         """
         basename = os.path.basename(prog)
         remote_bin = posixpath.join(self.remote_bin_dir, basename)
         log.info("Running test %s", basename)
         buf = StringIO.StringIO()
-        returncode = self.device.shell([remote_bin], buf, env=env, cwd=self.remote_tmp_dir,
+        returncode = self.device.shell([remote_bin], buf, env=env, cwd=self.remote_home_dir,
                                        timeout=cppunittests.CPPUnitTests.TEST_PROC_TIMEOUT)
         print >> sys.stdout, buf.getvalue()
         with cppunittests.TemporaryDirectory() as tempdir:
-            self.device.getDirectory(self.remote_tmp_dir, tempdir)
+            self.device.getDirectory(self.remote_home_dir, tempdir)
             if mozcrash.check_for_crashes(tempdir, symbols_path,
                                           test_name=basename):
                 log.testFail("%s | test crashed", basename)
                 return False
         result = returncode == 0
         if not result:
             log.testFail("%s | test failed with return code %s",
                          basename, returncode)