Bug 1171299 - Support mozinfo.json in cppunit tests; r=dminor
authorGeoff Brown <gbrown@mozilla.com>
Thu, 04 Jun 2015 10:51:14 -0600
changeset 247165 42d42889d05866ad51511a0f0113bdd5687089fc
parent 247164 93de3a806f3442ebd6c57bab80715ad15b1e9692
child 247166 0f2a2beb0a654d46c74b1c4815c3b8b2453bb9cb
push id28855
push userkwierso@gmail.com
push dateFri, 05 Jun 2015 01:19:30 +0000
treeherdermozilla-central@227d356ac030 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdminor
bugs1171299
milestone41.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 1171299 - Support mozinfo.json in cppunit tests; r=dminor
testing/remotecppunittests.py
testing/runcppunittests.py
testing/testsuite-targets.mk
--- a/testing/remotecppunittests.py
+++ b/testing/remotecppunittests.py
@@ -6,16 +6,17 @@
 
 import os, sys
 import subprocess
 import tempfile
 from zipfile import ZipFile
 import runcppunittests as cppunittests
 import mozcrash
 import mozfile
+import mozinfo
 import StringIO
 import posixpath
 from mozdevice import devicemanager, devicemanagerADB, devicemanagerSUT
 from mozlog import structured
 
 try:
     from mozbuild.base import MozbuildObject
     build_obj = MozbuildObject.from_environment()
@@ -249,21 +250,18 @@ def main():
             sys.exit(1)
 
     log = structured.commandline.setup_logging("remotecppunittests",
                                                options,
                                                {"tbpl": sys.stdout})
 
 
     options.xre_path = os.path.abspath(options.xre_path)
-    if options.with_b2g_emulator:
-        environ = {'os': 'b2g'}
-    else:
-        environ = {'os': 'android'}
-    progs = cppunittests.extract_unittests_from_args(args, environ)
+    cppunittests.update_mozinfo()
+    progs = cppunittests.extract_unittests_from_args(args, mozinfo.info)
     tester = RemoteCPPUnitTests(dm, options, progs)
     try:
         result = tester.run_tests(progs, options.xre_path, options.symbols_path)
     except Exception, e:
         log.error(str(e))
         result = False
     if options.with_b2g_emulator:
         runner.cleanup()
--- a/testing/runcppunittests.py
+++ b/testing/runcppunittests.py
@@ -11,16 +11,18 @@ import manifestparser
 import mozprocess
 import mozinfo
 import mozcrash
 import mozfile
 from contextlib import contextmanager
 from mozlog import structured
 from subprocess import PIPE
 
+SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
+
 class CPPUnitTests(object):
     # Time (seconds) to wait for test process to complete
     TEST_PROC_TIMEOUT = 900
     # Time (seconds) in which process will be killed if it produces no output.
     TEST_PROC_NO_OUTPUT_TIMEOUT = 300
 
     def run_one_test(self, prog, env, symbols_path=None, interactive=False):
         """
@@ -195,31 +197,43 @@ def extract_unittests_from_args(args, en
     else:
         tests.extend([test['path'] for test in mp.active_tests(exists=False, disabled=False, **environ)])
 
     # skip non-existing tests
     tests = [test for test in tests if os.path.isfile(test)]
 
     return tests
 
+def update_mozinfo():
+    """walk up directories to find mozinfo.json update the info"""
+    path = SCRIPT_DIR
+    dirs = set()
+    while path != os.path.expanduser('~'):
+        if path in dirs:
+            break
+        dirs.add(path)
+        path = os.path.split(path)[0]
+    mozinfo.find_and_update_from_json(*dirs)
+
 def main():
     parser = CPPUnittestOptions()
     structured.commandline.add_logging_group(parser)
     options, args = parser.parse_args()
     if not args:
         print >>sys.stderr, """Usage: %s <test binary> [<test binary>...]""" % sys.argv[0]
         sys.exit(1)
     if not options.xre_path:
         print >>sys.stderr, """Error: --xre-path is required"""
         sys.exit(1)
 
     log = structured.commandline.setup_logging("cppunittests",
                                                options,
                                                {"tbpl": sys.stdout})
 
+    update_mozinfo()
     progs = extract_unittests_from_args(args, mozinfo.info)
     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)
--- a/testing/testsuite-targets.mk
+++ b/testing/testsuite-targets.mk
@@ -515,16 +515,17 @@ stage-cppunittests: make-stage-dir
 ifdef STRIP_CPP_TESTS
 	$(foreach bin,$(CPP_UNIT_TEST_BINS),$(OBJCOPY) $(or $(STRIP_FLAGS),--strip-unneeded) $(bin) $(bin:$(DIST)/%=$(PKG_STAGE)/%);)
 else
 	cp -RL $(DIST)/cppunittests $(PKG_STAGE)
 endif
 	cp $(topsrcdir)/testing/runcppunittests.py $(PKG_STAGE)/cppunittests
 	cp $(topsrcdir)/testing/remotecppunittests.py $(PKG_STAGE)/cppunittests
 	cp $(topsrcdir)/testing/cppunittest.ini $(PKG_STAGE)/cppunittests
+	cp $(DEPTH)/mozinfo.json $(PKG_STAGE)/cppunittests
 ifeq ($(MOZ_DISABLE_STARTUPCACHE),)
 	cp $(topsrcdir)/startupcache/test/TestStartupCacheTelemetry.js $(PKG_STAGE)/cppunittests
 	cp $(topsrcdir)/startupcache/test/TestStartupCacheTelemetry.manifest $(PKG_STAGE)/cppunittests
 endif
 ifdef STRIP_CPP_TESTS
 	$(OBJCOPY) $(or $(STRIP_FLAGS),--strip-unneeded) $(DIST)/bin/jsapi-tests$(BIN_SUFFIX) $(PKG_STAGE)/cppunittests/jsapi-tests$(BIN_SUFFIX)
 else
 	cp -RL $(DIST)/bin/jsapi-tests$(BIN_SUFFIX) $(PKG_STAGE)/cppunittests