Bug 992983 - Run gtests from mozharness' desktop_unittest.py r=jlund
☠☠ backed out by 08335bf9d492 ☠ ☠
authorChris Manchester <cmanchester@mozilla.com>
Sat, 18 Jul 2015 22:05:06 -0700
changeset 294058 53e7018a7b15ae3c352151d374037640be7b481c
parent 294057 314e201aa2d7d6464f72fa7b676fe51d36cfd896
child 294059 873acda091b75ba8aee7f374cd8e6c8627d64494
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlund
bugs992983
milestone43.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 992983 - Run gtests from mozharness' desktop_unittest.py r=jlund
testing/mozharness/configs/unittests/linux_unittest.py
testing/mozharness/configs/unittests/mac_unittest.py
testing/mozharness/configs/unittests/win_unittest.py
testing/mozharness/mozharness/mozilla/testing/errors.py
testing/mozharness/scripts/desktop_unittest.py
--- a/testing/mozharness/configs/unittests/linux_unittest.py
+++ b/testing/mozharness/configs/unittests/linux_unittest.py
@@ -35,27 +35,29 @@ config = {
     "xpcshell_name": XPCSHELL_NAME,
     "exe_suffix": EXE_SUFFIX,
     "run_file_names": {
         "mochitest": "runtests.py",
         "webapprt": "runtests.py",
         "reftest": "runreftest.py",
         "xpcshell": "runxpcshelltests.py",
         "cppunittest": "runcppunittests.py",
+        "gtest": "rungtests.py",
         "jittest": "jit_test.py",
         "mozbase": "test.py",
         "mozmill": "runtestlist.py",
     },
     "minimum_tests_zip_dirs": ["bin/*", "certs/*", "modules/*", "mozbase/*", "config/*"],
     "specific_tests_zip_dirs": {
         "mochitest": ["mochitest/*"],
         "webapprt": ["mochitest/*"],
         "reftest": ["reftest/*", "jsreftest/*"],
         "xpcshell": ["xpcshell/*"],
         "cppunittest": ["cppunittest/*"],
+        "gtest": ["gtest/*"],
         "jittest": ["jit-test/*"],
         "mozbase": ["mozbase/*"],
         "mozmill": ["mozmill/*"],
     },
     "suite_definitions": {
         "cppunittest": {
             "options": [
                 "--symbols-path=%(symbols_path)s",
@@ -158,17 +160,26 @@ config = {
                 "--symbols-path=%(symbols_path)s",
                 "--test-plugin-path=%(test_plugin_path)s",
                 "--log-raw=%(raw_log_file)s",
                 "--log-errorsummary=%(error_summary_file)s",
                 "--utility-path=tests/bin",
             ],
             "run_filename": "runxpcshelltests.py",
             "testsdir": "xpcshell"
-        }
+        },
+        "gtest": {
+            "options": [
+                "--xre-path=%(abs_res_dir)s",
+                "--cwd=%(gtest_dir)s",
+                "--symbols-path=%(symbols_path)s",
+                "%(binary_path)s",
+            ],
+            "run_filename": "rungtests.py",
+        },
     },
     # local mochi suites
     "all_mochitest_suites": {
         "plain": [],
         "plain-chunked": ["--chunk-by-dir=4"],
         "mochitest-push": ["--subsuite=push"],
         "chrome": ["--chrome"],
         "browser-chrome": ["--browser-chrome"],
@@ -213,16 +224,19 @@ config = {
                      "%(abs_app_dir)s/" + XPCSHELL_NAME],
         "xpcshell-addons": ["--manifest=tests/xpcshell/tests/all-test-dirs.list",
                             "--tag=addons",
                             "%(abs_app_dir)s/" + XPCSHELL_NAME]
     },
     "all_cppunittest_suites": {
         "cppunittest": ['tests/cppunittest']
     },
+    "all_gtest_suites": {
+        "gtest": []
+    },
     "all_jittest_suites": {
         "jittest": [],
         "jittest1": ["--total-chunks=2", "--this-chunk=1"],
         "jittest2": ["--total-chunks=2", "--this-chunk=2"],
         "jittest-chunked": [],
     },
     "all_mozbase_suites": {
         "mozbase": []
--- a/testing/mozharness/configs/unittests/mac_unittest.py
+++ b/testing/mozharness/configs/unittests/mac_unittest.py
@@ -24,27 +24,29 @@ config = {
     "xpcshell_name": XPCSHELL_NAME,
     "exe_suffix": EXE_SUFFIX,
     "run_file_names": {
         "mochitest": "runtests.py",
         "webapprt": "runtests.py",
         "reftest": "runreftest.py",
         "xpcshell": "runxpcshelltests.py",
         "cppunittest": "runcppunittests.py",
+        "gtest": "rungtests.py",
         "jittest": "jit_test.py",
         "mozbase": "test.py",
         "mozmill": "runtestlist.py",
     },
     "minimum_tests_zip_dirs": ["bin/*", "certs/*", "modules/*", "mozbase/*", "config/*"],
     "specific_tests_zip_dirs": {
         "mochitest": ["mochitest/*"],
         "webapprt": ["mochitest/*"],
         "reftest": ["reftest/*", "jsreftest/*"],
         "xpcshell": ["xpcshell/*"],
         "cppunittest": ["cppunittest/*"],
+        "gtest": ["gtest/*"],
         "jittest": ["jit-test/*"],
         "mozbase": ["mozbase/*"],
         "mozmill": ["mozmill/*"],
     },
     "suite_definitions": {
         "cppunittest": {
             "options": [
                 "--symbols-path=%(symbols_path)s",
@@ -125,17 +127,26 @@ config = {
                 "--symbols-path=%(symbols_path)s",
                 "--test-plugin-path=%(test_plugin_path)s",
                 "--log-raw=%(raw_log_file)s",
                 "--log-errorsummary=%(error_summary_file)s",
                 "--utility-path=tests/bin",
             ],
             "run_filename": "runxpcshelltests.py",
             "testsdir": "xpcshell"
-        }
+        },
+        "gtest": {
+            "options": [
+                "--xre-path=%(abs_res_dir)s",
+                "--cwd=%(gtest_dir)s",
+                "--symbols-path=%(symbols_path)s",
+                "%(binary_path)s",
+            ],
+            "run_filename": "rungtests.py",
+        },
     },
     # local mochi suites
     "all_mochitest_suites": {
         "plain": [],
         "plain-chunked": ["--chunk-by-dir=4"],
         "mochitest-push": ["--subsuite=push"],
         "chrome": ["--chrome"],
         "browser-chrome": ["--browser-chrome"],
@@ -172,16 +183,19 @@ config = {
                      "%(abs_app_dir)s/" + XPCSHELL_NAME],
         "xpcshell-addons": ["--manifest=tests/xpcshell/tests/all-test-dirs.list",
                             "--tag=addons",
                             "%(abs_app_dir)s/" + XPCSHELL_NAME]
     },
     "all_cppunittest_suites": {
         "cppunittest": ['tests/cppunittest']
     },
+    "all_gtest_suites": {
+        "gtest": []
+    },
     "all_jittest_suites": {
         "jittest": []
     },
     "all_mozbase_suites": {
         "mozbase": []
     },
     "run_cmd_checks_enabled": True,
     "preflight_run_cmd_suites": [
--- a/testing/mozharness/configs/unittests/win_unittest.py
+++ b/testing/mozharness/configs/unittests/win_unittest.py
@@ -33,27 +33,29 @@ config = {
     "pip_index": False,
     "exe_suffix": EXE_SUFFIX,
     "run_file_names": {
         "mochitest": "runtests.py",
         "webapprt": "runtests.py",
         "reftest": "runreftest.py",
         "xpcshell": "runxpcshelltests.py",
         "cppunittest": "runcppunittests.py",
+        "gtest": "rungtests.py",
         "jittest": "jit_test.py",
         "mozbase": "test.py",
         "mozmill": "runtestlist.py",
     },
     "minimum_tests_zip_dirs": ["bin/*", "certs/*", "modules/*", "mozbase/*", "config/*"],
     "specific_tests_zip_dirs": {
         "mochitest": ["mochitest/*"],
         "webapprt": ["mochitest/*"],
         "reftest": ["reftest/*", "jsreftest/*"],
         "xpcshell": ["xpcshell/*"],
         "cppunittest": ["cppunittest/*"],
+        "gtest": ["gtest/*"],
         "jittest": ["jit-test/*"],
         "mozbase": ["mozbase/*"],
         "mozmill": ["mozmill/*"],
     },
     "suite_definitions": {
         "cppunittest": {
             "options": [
                 "--symbols-path=%(symbols_path)s",
@@ -133,17 +135,26 @@ config = {
                 "--symbols-path=%(symbols_path)s",
                 "--test-plugin-path=%(test_plugin_path)s",
                 "--log-raw=%(raw_log_file)s",
                 "--log-errorsummary=%(error_summary_file)s",
                 "--utility-path=tests/bin",
             ],
             "run_filename": "runxpcshelltests.py",
             "testsdir": "xpcshell"
-        }
+        },
+        "gtest": {
+            "options": [
+                "--xre-path=%(abs_res_dir)s",
+                "--cwd=%(gtest_dir)s",
+                "--symbols-path=%(symbols_path)s",
+                "%(binary_path)s",
+            ],
+            "run_filename": "rungtests.py",
+        },
     },
     # local mochi suites
     "all_mochitest_suites":
     {
         "plain": [],
         "plain-chunked": ["--chunk-by-dir=4"],
         "mochitest-push": ["--subsuite=push"],
         "chrome": ["--chrome"],
@@ -186,16 +197,19 @@ config = {
                      "%(abs_app_dir)s/" + XPCSHELL_NAME],
         "xpcshell-addons": ["--manifest=tests/xpcshell/tests/all-test-dirs.list",
                             "--tag=addons",
                             "%(abs_app_dir)s/" + XPCSHELL_NAME]
     },
     "all_cppunittest_suites": {
         "cppunittest": ['tests/cppunittest']
     },
+    "all_gtest_suites": {
+        "gtest": []
+    },
     "all_jittest_suites": {
         "jittest": []
     },
     "all_mozbase_suites": {
         "mozbase": []
     },
     "run_cmd_checks_enabled": True,
     "preflight_run_cmd_suites": [
--- a/testing/mozharness/mozharness/mozilla/testing/errors.py
+++ b/testing/mozharness/mozharness/mozilla/testing/errors.py
@@ -55,16 +55,22 @@ TinderBoxPrintRe = {
     "robocop_summary": _mochitest_summary,
     "instrumentation_summary": _mochitest_summary,
     "cppunittest_summary": {
         'regex': re.compile(r'''cppunittests INFO \| (Passed|Failed): (\d+)'''),
         'pass_group': "Passed",
         'fail_group': "Failed",
         'known_fail_group': None,
     },
+    "gtest_summary": {
+        'regex': re.compile(r'''(Passed|Failed): (\d+)'''),
+        'pass_group': "Passed",
+        'fail_group': "Failed",
+        'known_fail_group': None,
+    },
     "jittest_summary": {
         'regex': re.compile(r'''(Passed|Failed): (\d+)'''),
         'pass_group': "Passed",
         'fail_group': "Failed",
         'known_fail_group': None,
     },
     "mozbase_summary": {
         'regex': re.compile(r'''(OK)|(FAILED) \(errors=(\d+)'''),
--- a/testing/mozharness/scripts/desktop_unittest.py
+++ b/testing/mozharness/scripts/desktop_unittest.py
@@ -26,19 +26,18 @@ from mozharness.base.script import PreSc
 from mozharness.base.vcs.vcsbase import MercurialScript
 from mozharness.mozilla.blob_upload import BlobUploadMixin, blobupload_config_options
 from mozharness.mozilla.mozbase import MozbaseMixin
 from mozharness.mozilla.testing.codecoverage import (
     CodeCoverageMixin,
     code_coverage_config_options
 )
 from mozharness.mozilla.testing.testbase import TestingMixin, testing_config_options
-from mozharness.mozilla.buildbot import TBPL_WARNING
 
-SUITE_CATEGORIES = ['cppunittest', 'jittest', 'mochitest', 'reftest', 'xpcshell', 'mozbase', 'mozmill', 'webapprt']
+SUITE_CATEGORIES = ['gtest', 'cppunittest', 'jittest', 'mochitest', 'reftest', 'xpcshell', 'mozbase', 'mozmill', 'webapprt']
 
 
 # DesktopUnittest {{{1
 class DesktopUnittest(TestingMixin, MercurialScript, BlobUploadMixin, MozbaseMixin, CodeCoverageMixin):
     config_options = [
         [['--mochitest-suite', ], {
             "action": "extend",
             "dest": "specified_mochitest_suites",
@@ -74,16 +73,24 @@ class DesktopUnittest(TestingMixin, Merc
         [['--cppunittest-suite', ], {
             "action": "extend",
             "dest": "specified_cppunittest_suites",
             "type": "string",
             "help": "Specify which cpp unittest suite to run. "
                     "Suites are defined in the config file\n."
                     "Examples: 'cppunittest'"}
          ],
+        [['--gtest-suite', ], {
+            "action": "extend",
+            "dest": "specified_gtest_suites",
+            "type": "string",
+            "help": "Specify which gtest suite to run. "
+                    "Suites are defined in the config file\n."
+                    "Examples: 'gtest'"}
+         ],
         [['--jittest-suite', ], {
             "action": "extend",
             "dest": "specified_jittest_suites",
             "type": "string",
             "help": "Specify which jit-test suite to run. "
                     "Suites are defined in the config file\n."
                     "Examples: 'jittest'"}
          ],
@@ -202,16 +209,17 @@ class DesktopUnittest(TestingMixin, Merc
                                                         'plugins')
         dirs['abs_test_bin_components_dir'] = os.path.join(dirs['abs_test_bin_dir'],
                                                            'components')
         dirs['abs_mochitest_dir'] = os.path.join(dirs['abs_test_install_dir'], "mochitest")
         dirs['abs_webapprt_dir'] = os.path.join(dirs['abs_test_install_dir'], "mochitest")
         dirs['abs_reftest_dir'] = os.path.join(dirs['abs_test_install_dir'], "reftest")
         dirs['abs_xpcshell_dir'] = os.path.join(dirs['abs_test_install_dir'], "xpcshell")
         dirs['abs_cppunittest_dir'] = os.path.join(dirs['abs_test_install_dir'], "cppunittest")
+        dirs['abs_gtest_dir'] = os.path.join(dirs['abs_test_install_dir'], "gtest")
         dirs['abs_blob_upload_dir'] = os.path.join(abs_dirs['abs_work_dir'], 'blobber_upload_dir')
         dirs['abs_jittest_dir'] = os.path.join(dirs['abs_test_install_dir'], "jit-test", "jit-test")
         dirs['abs_mozbase_dir'] = os.path.join(dirs['abs_test_install_dir'], "mozbase")
         dirs['abs_mozmill_dir'] = os.path.join(dirs['abs_test_install_dir'], "mozmill")
 
         if os.path.isabs(c['virtualenv_path']):
             dirs['abs_virtualenv_dir'] = c['virtualenv_path']
         else:
@@ -334,17 +342,20 @@ class DesktopUnittest(TestingMixin, Merc
                                               '%s_errorsummary.log' % suite)
             str_format_values = {
                 'binary_path': self.binary_path,
                 'symbols_path': self._query_symbols_url(),
                 'abs_app_dir': abs_app_dir,
                 'abs_res_dir': abs_res_dir,
                 'raw_log_file': raw_log_file,
                 'error_summary_file': error_summary_file,
+                'gtest_dir': os.path.join(dirs['abs_test_install_dir'],
+                                          'gtest'),
             }
+
             # TestingMixin._download_and_extract_symbols() will set
             # self.symbols_path when downloading/extracting.
             if self.symbols_path:
                 str_format_values['symbols_path'] = self.symbols_path
 
             if suite_category == 'webapprt':
                 str_format_values['app_path'] = self.get_webapprt_path(abs_res_dir, dirs['abs_mochitest_dir'])
 
@@ -463,16 +474,18 @@ class DesktopUnittest(TestingMixin, Merc
     def run_tests(self):
         self._run_category_suites('mochitest')
         self._run_category_suites('reftest')
         self._run_category_suites('webapprt')
         self._run_category_suites('xpcshell',
                                   preflight_run_method=self.preflight_xpcshell)
         self._run_category_suites('cppunittest',
                                   preflight_run_method=self.preflight_cppunittest)
+        self._run_category_suites('gtest',
+                                  preflight_run_method=self.preflight_gtest)
         self._run_category_suites('jittest')
         self._run_category_suites('mozbase')
         self._run_category_suites('mozmill',
                                   preflight_run_method=self.preflight_mozmill)
 
     def preflight_xpcshell(self, suites):
         c = self.config
         dirs = self.query_abs_dirs()
@@ -510,16 +523,31 @@ class DesktopUnittest(TestingMixin, Merc
         abs_cppunittest_dir = dirs['abs_cppunittest_dir']
 
         # move manifest and js fils to resources dir, where tests expect them
         files = glob.glob(os.path.join(abs_cppunittest_dir, '*.js'))
         files.extend(glob.glob(os.path.join(abs_cppunittest_dir, '*.manifest')))
         for f in files:
             self.move(f, abs_res_dir)
 
+    def preflight_gtest(self, suites):
+        abs_res_dir = self.query_abs_res_dir()
+        abs_app_dir = self.query_abs_app_dir()
+        dirs = self.query_abs_dirs()
+        abs_gtest_dir = dirs['abs_gtest_dir']
+        dirs['abs_test_bin_dir'] = os.path.join(dirs['abs_test_install_dir'], 'bin')
+
+        files = glob.glob(os.path.join(dirs['abs_test_bin_plugins_dir'], 'gmp-*'))
+        files.append(os.path.join(abs_gtest_dir, 'dependentlibs.list.gtest'))
+        for f in files:
+            self.move(f, abs_res_dir)
+
+        self.copytree(os.path.join(abs_gtest_dir, 'gtest_bin'),
+                      os.path.join(abs_app_dir))
+
     def preflight_mozmill(self, suites):
         c = self.config
         dirs = self.query_abs_dirs()
         abs_app_dir = self.query_abs_app_dir()
         abs_app_plugins_dir = os.path.join(abs_app_dir, 'plugins')
         abs_app_extensions_dir = os.path.join(abs_app_dir, 'extensions')
         if suites:  # there are mozmill suites to run
             self.mkdir_p(abs_app_plugins_dir)
@@ -601,17 +629,17 @@ class DesktopUnittest(TestingMixin, Merc
                 # be. We do this by:
                 # 1) checking to see if our mozharness script ran into any
                 #    errors itself with 'num_errors' <- OutputParser
                 # 2) if num_errors is 0 then we look in the subclassed 'parser'
                 #    findings for harness/suite errors <- DesktopUnittestOutputParser
                 # 3) checking to see if the return code is in success_codes
 
                 success_codes = None
-                if self._is_windows():
+                if self._is_windows() and suite_category != 'gtest':
                     # bug 1120644
                     success_codes = [0, 1]
 
                 tbpl_status, log_level = parser.evaluate_parser(return_code,
                                                                 success_codes=success_codes)
                 parser.append_tinderboxprint_line(suite_name)
 
                 self.buildbot_status(tbpl_status, level=log_level)