Bug 1014653 - Run C++ unit tests on B2G; r=gbrown
authorDan Minor <dminor@mozilla.com>
Tue, 15 Jul 2014 15:53:33 -0400
changeset 216286 692c3ecda74919d8564757ac301bcb2cf2148509
parent 216285 61a09b7b7e9df01cf4c4c2a5265197d630142a97
child 216287 98c0de173604a00a02726a61cf5d6cbe8fc40c24
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown
bugs1014653
milestone33.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 1014653 - Run C++ unit tests on B2G; r=gbrown
testing/b2g_cppunittest_manifest.txt
testing/config/mozharness/b2g_emulator_config.py
testing/remotecppunittests.py
testing/testsuite-targets.mk
new file mode 100644
--- /dev/null
+++ b/testing/b2g_cppunittest_manifest.txt
@@ -0,0 +1,9 @@
+# This is just a list of tests to skip, one test per line
+TestPLDHash                         # Bug 1038197
+TestTXMgr                           # Bug 919595
+TestPlainTextSerializer             # Bug 919599
+TestNativeXMLHttpRequest            # Bug 919642
+mediapipeline_unittest              # Bug 919646
+TestStartupCache                    # Bug 929655
+TestStartupCacheTelemetry.manifest  # Bug 929655
+TestStartupCacheTelemetry.js        # Bug 929655
--- a/testing/config/mozharness/b2g_emulator_config.py
+++ b/testing/config/mozharness/b2g_emulator_config.py
@@ -42,9 +42,19 @@ config = {
     ],
 
     "xpcshell_options": [
         "--adbpath=%(adbpath)s", "--b2gpath=%(b2gpath)s", "--emulator=%(emulator)s",
         "--logdir=%(logcat_dir)s", "--manifest=%(test_manifest)s", "--use-device-libs",
         "--testing-modules-dir=%(modules_dir)s", "--symbols-path=%(symbols_path)s",
         "--busybox=%(busybox)s", "--total-chunks=%(total_chunks)s", "--this-chunk=%(this_chunk)s",
     ],
+
+    "cppunittest_options": [
+        "--dm_trans=adb",
+        "--symbols-path=%(symbols_path)s",
+        "--xre-path=%(xre_path)s",
+        "--addEnv", "LD_LIBRARY_PATH=/vendor/lib:/system/lib:/system/b2g",
+        "--with-b2g-emulator=%(b2gpath)s",
+        "--skip-manifest=b2g_cppunittest_manifest.txt",
+        "."
+    ],
 }
--- a/testing/remotecppunittests.py
+++ b/testing/remotecppunittests.py
@@ -70,29 +70,30 @@ class RemoteCPPUnitTests(cppunittests.CP
                         remote_file = posixpath.join(self.remote_bin_dir, os.path.basename(info.filename))
                         apk_contents.extract(info, tmpdir)
                         file = os.path.join(tmpdir, info.filename)
                         if szip:
                             out = subprocess.check_output([szip, '-d', file], stderr=subprocess.STDOUT)
                         self.device.pushFile(os.path.join(tmpdir, info.filename), remote_file)
             return
 
-        for file in os.listdir(self.options.local_lib):
-            if file.endswith(".so"):
-                print >> sys.stderr, "Pushing %s.." % file
-                remote_file = posixpath.join(self.remote_bin_dir, file)
-                self.device.pushFile(os.path.join(self.options.local_lib, file), remote_file)
-        # Additional libraries may be found in a sub-directory such as "lib/armeabi-v7a"
-        local_arm_lib = os.path.join(self.options.local_lib, "lib")
-        if os.path.isdir(local_arm_lib):
-            for root, dirs, files in os.walk(local_arm_lib):
-                for file in files:
-                    if (file.endswith(".so")):
-                        remote_file = posixpath.join(self.remote_bin_dir, file)
-                        self.device.pushFile(os.path.join(root, file), remote_file)
+        elif self.options.local_lib:
+            for file in os.listdir(self.options.local_lib):
+                if file.endswith(".so"):
+                    print >> sys.stderr, "Pushing %s.." % file
+                    remote_file = posixpath.join(self.remote_bin_dir, file)
+                    self.device.pushFile(os.path.join(self.options.local_lib, file), remote_file)
+            # Additional libraries may be found in a sub-directory such as "lib/armeabi-v7a"
+            local_arm_lib = os.path.join(self.options.local_lib, "lib")
+            if os.path.isdir(local_arm_lib):
+                for root, dirs, files in os.walk(local_arm_lib):
+                    for file in files:
+                        if (file.endswith(".so")):
+                            remote_file = posixpath.join(self.remote_bin_dir, file)
+                            self.device.pushFile(os.path.join(root, file), remote_file)
 
     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()
@@ -182,16 +183,19 @@ class RemoteCPPUnittestOptions(cppunitte
         self.add_option("--localBinDir", action="store",
                         type = "string", dest = "local_bin",
                         help = "local path to bin directory")
         defaults["local_bin"] = build_obj.bindir if build_obj is not None else None
 
         self.add_option("--remoteTestRoot", action = "store",
                     type = "string", dest = "remote_test_root",
                     help = "remote directory to use as test root (eg. /data/local/tests)")
+        self.add_option("--with-b2g-emulator", action = "store",
+                    type = "string", dest = "with_b2g_emulator",
+                    help = "Start B2G Emulator (specify path to b2g home)")
         # /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
@@ -199,42 +203,58 @@ class RemoteCPPUnittestOptions(cppunitte
         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)
-    if options.local_lib is None and options.local_apk is None:
-        print >>sys.stderr, """Error: --localLib or --apk is required"""
-        sys.exit(1)
     if options.local_lib is not None and not os.path.isdir(options.local_lib):
         print >>sys.stderr, """Error: --localLib directory %s not found""" % options.local_lib
         sys.exit(1)
     if options.local_apk is not None and not os.path.isfile(options.local_apk):
         print >>sys.stderr, """Error: --apk file %s not found""" % options.local_apk
         sys.exit(1)
     if not options.xre_path:
         print >>sys.stderr, """Error: --xre-path is required"""
         sys.exit(1)
+    if options.with_b2g_emulator:
+        from mozrunner import B2GEmulatorRunner
+        runner = B2GEmulatorRunner(b2g_home=options.with_b2g_emulator)
+        runner.start()
     if options.dm_trans == "adb":
-        if options.device_ip:
-            dm = devicemanagerADB.DeviceManagerADB(options.device_ip, options.device_port, packageName=None, deviceRoot=options.remote_test_root)
+        if options.with_b2g_emulator:
+            # because we just started the emulator, we need more than the
+            # default number of retries here.
+            retryLimit = 50
         else:
-            dm = devicemanagerADB.DeviceManagerADB(packageName=None, deviceRoot=options.remote_test_root)
+            retryLimit = 5
+        try:
+            if options.device_ip:
+                dm = devicemanagerADB.DeviceManagerADB(options.device_ip, options.device_port, packageName=None, deviceRoot=options.remote_test_root, retryLimit=retryLimit)
+            else:
+                dm = devicemanagerADB.DeviceManagerADB(packageName=None, deviceRoot=options.remote_test_root, retryLimit=retryLimit)
+        except:
+            if options.with_b2g_emulator:
+                runner.cleanup()
+                runner.wait()
+            raise
     else:
         dm = devicemanagerSUT.DeviceManagerSUT(options.device_ip, options.device_port, deviceRoot=options.remote_test_root)
         if not options.device_ip:
             print "Error: you must provide a device IP to connect to via the --deviceIP option"
             sys.exit(1)
     options.xre_path = os.path.abspath(options.xre_path)
     progs = cppunittests.extract_unittests_from_args(args, options.manifest_file)
     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()
+        runner.wait()
     sys.exit(0 if result else 1)
 
 if __name__ == '__main__':
     main()
--- a/testing/testsuite-targets.mk
+++ b/testing/testsuite-targets.mk
@@ -499,16 +499,19 @@ ifdef STRIP_CPP_TESTS
 else
 	cp -RL $(DIST)/cppunittests $(PKG_STAGE)
 endif
 	$(NSINSTALL) $(topsrcdir)/testing/runcppunittests.py $(PKG_STAGE)/cppunittests
 	$(NSINSTALL) $(topsrcdir)/testing/remotecppunittests.py $(PKG_STAGE)/cppunittests
 ifeq ($(MOZ_WIDGET_TOOLKIT),android)
 	$(NSINSTALL) $(topsrcdir)/testing/android_cppunittest_manifest.txt $(PKG_STAGE)/cppunittests
 endif
+ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
+	$(NSINSTALL) $(topsrcdir)/testing/b2g_cppunittest_manifest.txt $(PKG_STAGE)/cppunittests
+endif
 ifeq ($(MOZ_DISABLE_STARTUPCACHE),)
 	$(NSINSTALL) $(topsrcdir)/startupcache/test/TestStartupCacheTelemetry.js $(PKG_STAGE)/cppunittests
 	$(NSINSTALL) $(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