Mac v2 signing - Bug 1064952 - Update Cpp unit test harness for the new v2 bundle structure on OSX. r=jmaher
authorStephen Pohl <spohl.mozilla.bugs@gmail.com>
Mon, 29 Sep 2014 11:51:39 -0700
changeset 220514 5af85a6db219c32ff98b4178d1c9235d2fe9e151
parent 220513 33000c22f91fa34ff64d58ce8b32684d93fb1024
child 220515 09e4c6245f6d7a3070da126086df01486661919e
push idunknown
push userunknown
push dateunknown
reviewersjmaher
bugs1064952
milestone35.0a1
Mac v2 signing - Bug 1064952 - Update Cpp unit test harness for the new v2 bundle structure on OSX. r=jmaher
startupcache/test/TestStartupCache.cpp
testing/runcppunittests.py
--- a/startupcache/test/TestStartupCache.cpp
+++ b/startupcache/test/TestStartupCache.cpp
@@ -409,16 +409,24 @@ int main(int argc, char** argv)
   
   int rv = 0;
   nsresult scrv;
 
   // Register TestStartupCacheTelemetry
   nsCOMPtr<nsIFile> manifest;
   scrv = NS_GetSpecialDirectory(NS_GRE_DIR,
                                 getter_AddRefs(manifest));
+#ifdef XP_MACOSX
+  if (NS_SUCCEEDED(scrv)) {
+    nsCOMPtr<nsIFile> parent;
+    manifest->GetParent(getter_AddRefs(parent));
+    parent->AppendNative(NS_LITERAL_CSTRING("MacOS"));
+    manifest = parent.forget();
+  }
+#endif
   if (NS_FAILED(scrv)) {
     fail("NS_XPCOM_CURRENT_PROCESS_DIR");
     return 1;
   }
 
   manifest->AppendNative(NS_LITERAL_CSTRING("TestStartupCacheTelemetry.manifest"));
   XRE_AddManifestLocation(NS_COMPONENT_LOCATION, manifest);
 
--- a/testing/runcppunittests.py
+++ b/testing/runcppunittests.py
@@ -92,27 +92,33 @@ class CPPUnitTests(object):
         Create and return a dictionary of all the appropriate env variables and values.
         On a remote system, we overload this to set different values and are missing things like os.environ and PATH.
         """
         if not os.path.isdir(self.xre_path):
             raise Exception("xre_path does not exist: %s", self.xre_path)
         env = dict(os.environ)
         env = self.build_core_environment(env)
         pathvar = ""
+        libpath = self.xre_path
         if mozinfo.os == "linux":
             pathvar = "LD_LIBRARY_PATH"
         elif mozinfo.os == "mac":
+            applibpath = os.path.join(os.path.dirname(libpath), 'MacOS')
+            if os.path.exists(applibpath):
+                # Set the library load path to Contents/MacOS if we're run from
+                # the app bundle.
+                libpath = applibpath
             pathvar = "DYLD_LIBRARY_PATH"
         elif mozinfo.os == "win":
             pathvar = "PATH"
         if pathvar:
             if pathvar in env:
-                env[pathvar] = "%s%s%s" % (self.xre_path, os.pathsep, env[pathvar])
+                env[pathvar] = "%s%s%s" % (libpath, os.pathsep, env[pathvar])
             else:
-                env[pathvar] = self.xre_path
+                env[pathvar] = libpath
 
         # Use llvm-symbolizer for ASan if available/required
         llvmsym = os.path.join(self.xre_path, "llvm-symbolizer")
         if os.path.isfile(llvmsym):
             env["ASAN_SYMBOLIZER_PATH"] = llvmsym
             self.log.info("ASan using symbolizer at %s" % llvmsym)
         else:
             self.log.info("Failed to find ASan symbolizer at %s" % llvmsym)
@@ -204,16 +210,18 @@ def main():
         sys.exit(1)
 
     log = structured.commandline.setup_logging("cppunittests",
                                                options,
                                                {"tbpl": sys.stdout})
 
     progs = extract_unittests_from_args(args, options.manifest_file)
     options.xre_path = os.path.abspath(options.xre_path)
+    if mozinfo.isMac:
+        options.xre_path = os.path.join(os.path.dirname(options.xre_path), 'Resources')
     tester = CPPUnitTests()
 
     try:
         result = tester.run_tests(progs, options.xre_path, options.symbols_path)
     except Exception as e:
         log.error(str(e))
         result = False