From bb83950948b1bbe53f30ec5e1af098ba90cdbf9b Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Sat, 29 Jun 2019 09:49:23 +0000 Subject: [PATCH] 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 --HG-- extra : moz-landing-system : lando --- testing/mach_commands.py | 3 +++ testing/remotecppunittests.py | 7 ++++--- testing/runcppunittests.py | 23 +++++++++++++++++------ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/testing/mach_commands.py b/testing/mach_commands.py index b9c0aa01fae4..fb2f9fbaaa96 100644 --- a/testing/mach_commands.py +++ b/testing/mach_commands.py @@ -374,6 +374,9 @@ class Test(MachCommandBase): 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 ' diff --git a/testing/remotecppunittests.py b/testing/remotecppunittests.py index 4833cb78ae0b..9ce859c89d75 100644 --- a/testing/remotecppunittests.py +++ b/testing/remotecppunittests.py @@ -97,8 +97,8 @@ class RemoteCPPUnitTests(cppunittests.CPPUnitTests): 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 @@ -230,7 +230,8 @@ def run_test_harness(options, 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 diff --git a/testing/runcppunittests.py b/testing/runcppunittests.py index 1aa4799b4aae..4982d1d6c20c 100755 --- a/testing/runcppunittests.py +++ b/testing/runcppunittests.py @@ -90,7 +90,7 @@ class CPPUnitTests(object): 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. """ @@ -100,9 +100,16 @@ class CPPUnitTests(object): 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 @@ -111,7 +118,7 @@ class CPPUnitTests(object): 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": @@ -150,7 +157,7 @@ class CPPUnitTests(object): 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. @@ -171,7 +178,7 @@ class CPPUnitTests(object): 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: @@ -212,6 +219,10 @@ class CPPUnittestOptions(OptionParser): 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): @@ -276,7 +287,7 @@ def run_test_harness(options, args): 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