mach_test_package_commands.py (3764B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 import os 6 import sys 7 from argparse import Namespace 8 from functools import partial 9 10 from mach.decorators import Command 11 12 here = os.path.abspath(os.path.dirname(__file__)) 13 logger = None 14 15 16 def run_reftest(context, **kwargs): 17 import mozinfo 18 from mozlog.commandline import setup_logging 19 20 if not kwargs.get("log"): 21 kwargs["log"] = setup_logging("reftest", kwargs, {"mach": sys.stdout}) 22 global logger 23 logger = kwargs["log"] 24 25 args = Namespace(**kwargs) 26 args.e10s = context.mozharness_config.get("e10s", args.e10s) 27 28 if not args.tests: 29 args.tests = [os.path.join("layout", "reftests", "reftest.list")] 30 31 test_root = os.path.join(context.package_root, "reftest", "tests") 32 normalize = partial(context.normalize_test_path, test_root) 33 args.tests = map(normalize, args.tests) 34 35 if kwargs.get("allow_software_gl_layers"): 36 os.environ["MOZ_LAYERS_ALLOW_SOFTWARE_GL"] = "1" 37 38 if mozinfo.info.get("buildapp") == "mobile/android": 39 return run_reftest_android(context, args) 40 return run_reftest_desktop(context, args) 41 42 43 def run_reftest_desktop(context, args): 44 from runreftest import run_test_harness 45 46 args.app = args.app or context.firefox_bin 47 args.extraProfileFiles.append(os.path.join(context.bin_dir, "plugins")) 48 args.utilityPath = context.bin_dir 49 args.sandboxReadWhitelist.append(context.mozharness_workdir) 50 args.extraPrefs.append("layers.acceleration.force-enabled=true") 51 52 logger.info("mach calling runreftest with args: " + str(args)) 53 54 return run_test_harness(parser, args) 55 56 57 def run_reftest_android(context, args): 58 from remotereftest import run_test_harness 59 60 args.app = args.app or "org.mozilla.geckoview.test_runner" 61 args.utilityPath = context.hostutils 62 args.xrePath = context.hostutils 63 args.httpdPath = context.module_dir 64 args.ignoreWindowSize = True 65 66 config = context.mozharness_config 67 if config: 68 host = os.environ.get("HOST_IP", "10.0.2.2") 69 args.remoteWebServer = config.get("remote_webserver", host) 70 args.httpPort = config.get("http_port", 8854) 71 args.sslPort = config.get("ssl_port", 4454) 72 args.adb_path = config["exes"]["adb"] % { 73 "abs_work_dir": context.mozharness_workdir 74 } 75 args.deviceSerial = ( 76 os.environ.get("ANDROID_SERIAL") 77 or os.environ.get("DEVICE_SERIAL") 78 or "emulator-5554" 79 ) 80 81 logger.info("mach calling remotereftest with args: " + str(args)) 82 83 return run_test_harness(parser, args) 84 85 86 def add_global_arguments(parser): 87 parser.add_argument("--test-suite") 88 parser.add_argument("--reftest-suite") 89 parser.add_argument("--download-symbols") 90 parser.add_argument("--allow-software-gl-layers", action="store_true") 91 parser.add_argument("--no-run-tests", action="store_true") 92 93 94 def setup_argument_parser(): 95 import mozinfo 96 import reftestcommandline 97 98 global parser 99 mozinfo.find_and_update_from_json(here) 100 if mozinfo.info.get("buildapp") == "mobile/android": 101 parser = reftestcommandline.RemoteArgumentsParser() 102 else: 103 parser = reftestcommandline.DesktopArgumentsParser() 104 add_global_arguments(parser) 105 return parser 106 107 108 @Command( 109 "reftest", 110 category="testing", 111 description="Run the reftest harness.", 112 parser=setup_argument_parser, 113 ) 114 def reftest(command_context, **kwargs): 115 command_context._mach_context.activate_mozharness_venv() 116 kwargs["suite"] = "reftest" 117 return run_reftest(command_context._mach_context, **kwargs)