Bug 1558598 - Force WebRender on or off in the cppunit harness. r=ahal
authorKartikaya Gupta <kgupta@mozilla.com>
Sat, 29 Jun 2019 09:49:23 +0000
changeset 543516 db9b8bf09e16cf4c09a01b7cfa3ebf43b38b2e33
parent 543515 99707ff8f401216829d12e6fc70ac6abc9856404
child 543517 4c861c8ffb4255eadc27e522cf8a5d94c87ca277
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1558598
milestone69.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 1558598 - Force WebRender on or off in the cppunit harness. r=ahal Also adds it to the mach command, which is a little weird, because the mach command doesn't expose the option but does parse it via the cpp unit argument parser. So I just exposed it on the mach command and after that it Just Works for mach. Differential Revision: https://phabricator.services.mozilla.com/D35859
testing/mach_commands.py
testing/remotecppunittests.py
testing/runcppunittests.py
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -369,16 +369,19 @@ class Test(MachCommandBase):
         log.shutdown()
         return status
 
 
 @CommandProvider
 class MachCommands(MachCommandBase):
     @Command('cppunittest', category='testing',
              description='Run cpp unit tests (C++ tests).')
+    @CommandArgument('--enable-webrender', action='store_true', default=False,
+                     dest='enable_webrender',
+                     help='Enable the WebRender compositor in Gecko.')
     @CommandArgument('test_files', nargs='*', metavar='N',
                      help='Test to run. Can be specified as one or more files or '
                      'directories, or omitted. If omitted, the entire test suite is '
                      'executed.')
     def run_cppunit_test(self, **params):
         from mozlog import commandline
 
         log = params.get('log')
--- a/testing/remotecppunittests.py
+++ b/testing/remotecppunittests.py
@@ -92,18 +92,18 @@ class RemoteCPPUnitTests(cppunittests.CP
                                 self.device.push(local_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.push(local_file, remote_file)
 
-    def build_environment(self):
-        env = self.build_core_environment()
+    def build_environment(self, enable_webrender=False):
+        env = self.build_core_environment({}, enable_webrender)
         env['LD_LIBRARY_PATH'] = self.remote_bin_dir
         env["TMPDIR"] = self.remote_tmp_dir
         env["HOME"] = self.remote_home_dir
         env["MOZ_XRE_DIR"] = self.remote_bin_dir
         if self.options.add_env:
             for envdef in self.options.add_env:
                 envdef_parts = envdef.split("=", 1)
                 if len(envdef_parts) == 2:
@@ -225,17 +225,18 @@ class RemoteCPPUnittestOptions(cppunitte
 
 def run_test_harness(options, args):
     options.xre_path = os.path.abspath(options.xre_path)
     cppunittests.update_mozinfo()
     progs = cppunittests.extract_unittests_from_args(args,
                                                      mozinfo.info,
                                                      options.manifest_path)
     tester = RemoteCPPUnitTests(options, [item[0] for item in progs])
-    result = tester.run_tests(progs, options.xre_path, options.symbols_path)
+    result = tester.run_tests(progs, options.xre_path, options.symbols_path,
+                              enable_webrender=options.enable_webrender)
     return result
 
 
 def main():
     parser = RemoteCPPUnittestOptions()
     mozlog.commandline.add_logging_group(parser)
     options, args = parser.parse_args()
     if not args:
--- a/testing/runcppunittests.py
+++ b/testing/runcppunittests.py
@@ -85,38 +85,45 @@ class CPPUnitTests(object):
             if not result:
                 self.log.test_end(basename, status='FAIL', expected='PASS',
                                   message=("test failed with return code %d" %
                                            proc.proc.returncode))
             else:
                 self.log.test_end(basename, status='PASS', expected='PASS')
             return result
 
-    def build_core_environment(self, env={}):
+    def build_core_environment(self, env, enable_webrender):
         """
         Add environment variables likely to be used across all platforms, including remote systems.
         """
         env["MOZ_XRE_DIR"] = self.xre_path
         # TODO: switch this to just abort once all C++ unit tests have
         # been fixed to enable crash reporting
         env["XPCOM_DEBUG_BREAK"] = "stack-and-abort"
         env["MOZ_CRASHREPORTER_NO_REPORT"] = "1"
         env["MOZ_CRASHREPORTER"] = "1"
+
+        if enable_webrender:
+            env['MOZ_WEBRENDER'] = '1'
+            env['MOZ_ACCELERATED'] = '1'
+        else:
+            env['MOZ_WEBRENDER'] = '0'
+
         return env
 
-    def build_environment(self):
+    def build_environment(self, enable_webrender=False):
         """
         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)
+        env = self.build_core_environment(env, enable_webrender)
         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
@@ -145,17 +152,17 @@ class CPPUnitTests(object):
             # media/mtransport tests statically link in NSS, which
             # causes ODR violations. See bug 1215679.
             assert 'ASAN_OPTIONS' not in env
             env['ASAN_OPTIONS'] = 'detect_leaks=0:detect_odr_violation=0'
 
         return env
 
     def run_tests(self, programs, xre_path, symbols_path=None,
-                  utility_path=None, interactive=False):
+                  utility_path=None, enable_webrender=False, interactive=False):
         """
         Run a set of C++ unit test programs.
 
         Arguments:
         * programs: An iterable containing (test path, test timeout factor) tuples
         * xre_path: A path to a directory containing a XUL Runtime Environment.
         * symbols_path: A path to a directory containing Breakpad-formatted
                         symbol files for producing stack traces on crash.
@@ -166,17 +173,17 @@ class CPPUnitTests(object):
         otherwise.
         """
         self.xre_path = xre_path
         self.log = mozlog.get_default_logger()
         if utility_path:
             self.fix_stack = mozrunner.utils.get_stack_fixer_function(
                 utility_path, symbols_path)
         self.log.suite_start(programs, name='cppunittest')
-        env = self.build_environment()
+        env = self.build_environment(enable_webrender)
         pass_count = 0
         fail_count = 0
         for prog in programs:
             test_path = prog[0]
             timeout_factor = prog[1]
             single_result = self.run_one_test(test_path, env, symbols_path,
                                               interactive, timeout_factor)
             if single_result:
@@ -207,16 +214,20 @@ class CPPUnittestOptions(OptionParser):
         self.add_option("--manifest-path",
                         action="store", type="string", dest="manifest_path",
                         default=None,
                         help="path to test manifest, if different from the path to test binaries")
         self.add_option("--utility-path",
                         action="store", type="string", dest="utility_path",
                         default=None,
                         help="path to directory containing utility programs")
+        self.add_option("--enable-webrender",
+                        action="store_true", dest="enable_webrender",
+                        default=False,
+                        help="Enable the WebRender compositor in Gecko")
 
 
 def extract_unittests_from_args(args, environ, manifest_path):
     """Extract unittests from args, expanding directories as needed"""
     mp = manifestparser.TestManifest(strict=True)
     tests = []
     binary_path = None
 
@@ -271,17 +282,17 @@ def update_mozinfo():
 
 def run_test_harness(options, args):
     update_mozinfo()
     progs = extract_unittests_from_args(args, mozinfo.info, options.manifest_path)
     options.xre_path = os.path.abspath(options.xre_path)
     options.utility_path = os.path.abspath(options.utility_path)
     tester = CPPUnitTests()
     result = tester.run_tests(progs, options.xre_path, options.symbols_path,
-                              options.utility_path)
+                              options.utility_path, options.enable_webrender)
 
     return result
 
 
 def main():
     parser = CPPUnittestOptions()
     mozlog.commandline.add_logging_group(parser)
     options, args = parser.parse_args()