def run_android_test(self, **kwargs): """Runs a reftest, in Firefox for Android.""" import runreftest if kwargs["suite"] not in ('reftest', 'crashtest', 'jstestbrowser'): raise Exception('None or unrecognized reftest suite type.') if "ipc" in kwargs.keys(): raise Exception('IPC tests not supported on Android.') default_manifest = { "reftest": (self.topsrcdir, "layout", "reftests", "reftest.list"), "crashtest": (self.topsrcdir, "testing", "crashtest", "crashtests.list"), "jstestbrowser": ("jsreftest", "tests", "jstests.list") } if not kwargs["tests"]: kwargs["tests"] = [ os.path.join(*default_manifest[kwargs["suite"]]) ] kwargs["extraProfileFiles"].append( os.path.join(self.topsrcdir, "mobile", "android", "fonts")) if not kwargs["httpdPath"]: kwargs["httpdPath"] = os.path.join(self.tests_dir, "modules") if not kwargs["symbolsPath"]: kwargs["symbolsPath"] = os.path.join(self.topobjdir, "crashreporter-symbols") if not kwargs["xrePath"]: kwargs["xrePath"] = os.environ.get("MOZ_HOST_BIN") if not kwargs["app"]: kwargs["app"] = self.substs["ANDROID_PACKAGE_NAME"] if not kwargs["utilityPath"]: kwargs["utilityPath"] = kwargs["xrePath"] kwargs["dm_trans"] = "adb" kwargs["ignoreWindowSize"] = True kwargs["printDeviceInfo"] = False from mozrunner.devices.android_device import grant_runtime_permissions grant_runtime_permissions(self, kwargs['app']) # A symlink and some path manipulations are required so that test # manifests can be found both locally and remotely (via a url) # using the same relative path. if kwargs["suite"] == "jstestbrowser": staged_js_dir = os.path.join(self.topobjdir, "dist", "test-stage", "jsreftest") tests = os.path.join(self.reftest_dir, 'jsreftest') if not os.path.isdir(tests): os.symlink(staged_js_dir, tests) kwargs["extraProfileFiles"].append( os.path.join(staged_js_dir, "tests", "user.js")) else: tests = os.path.join(self.reftest_dir, "tests") if not os.path.isdir(tests): os.symlink(self.topsrcdir, tests) for i, path in enumerate(kwargs["tests"]): # Non-absolute paths are relative to the packaged directory, which # has an extra tests/ at the start if os.path.exists(os.path.abspath(path)): path = os.path.relpath(path, os.path.join(self.topsrcdir)) kwargs["tests"][i] = os.path.join('tests', path) # Need to chdir to reftest_dir otherwise imports fail below. os.chdir(self.reftest_dir) # The imp module can spew warnings if the modules below have # already been imported, ignore them. with warnings.catch_warnings(): warnings.simplefilter('ignore') import imp path = os.path.join(self.reftest_dir, 'remotereftest.py') with open(path, 'r') as fh: imp.load_module('reftest', fh, path, ('.py', 'r', imp.PY_SOURCE)) import reftest self.log_manager.enable_unstructured() try: rv = reftest.run(**kwargs) finally: self.log_manager.disable_unstructured() return rv
def run_android_test(self, **kwargs): """Runs a reftest, in Firefox for Android.""" import runreftest if kwargs["suite"] not in ('reftest', 'crashtest', 'jstestbrowser'): raise Exception('None or unrecognized reftest suite type.') if "ipc" in kwargs.keys(): raise Exception('IPC tests not supported on Android.') default_manifest = { "reftest": (self.topsrcdir, "layout", "reftests", "reftest.list"), "crashtest": (self.topsrcdir, "testing", "crashtest", "crashtests.list"), "jstestbrowser": ("jsreftest", "tests", "jstests.list") } if not kwargs["tests"]: kwargs["tests"] = [os.path.join(*default_manifest[kwargs["suite"]])] kwargs["extraProfileFiles"].append( os.path.join(self.topsrcdir, "mobile", "android", "fonts")) if not kwargs["httpdPath"]: kwargs["httpdPath"] = os.path.join(self.tests_dir, "modules") if not kwargs["symbolsPath"]: kwargs["symbolsPath"] = os.path.join(self.topobjdir, "crashreporter-symbols") if not kwargs["xrePath"]: kwargs["xrePath"] = os.environ.get("MOZ_HOST_BIN") if not kwargs["app"]: kwargs["app"] = self.substs["ANDROID_PACKAGE_NAME"] kwargs["dm_trans"] = "adb" kwargs["ignoreWindowSize"] = True kwargs["printDeviceInfo"] = False from mozrunner.devices.android_device import grant_runtime_permissions grant_runtime_permissions(self, kwargs['app']) # A symlink and some path manipulations are required so that test # manifests can be found both locally and remotely (via a url) # using the same relative path. if kwargs["suite"] == "jstestbrowser": staged_js_dir = os.path.join(self.topobjdir, "dist", "test-stage", "jsreftest") tests = os.path.join(self.reftest_dir, 'jsreftest') if not os.path.isdir(tests): os.symlink(staged_js_dir, tests) kwargs["extraProfileFiles"].append(os.path.join(staged_js_dir, "tests", "user.js")) else: tests = os.path.join(self.reftest_dir, "tests") if not os.path.isdir(tests): os.symlink(self.topsrcdir, tests) for i, path in enumerate(kwargs["tests"]): # Non-absolute paths are relative to the packaged directory, which # has an extra tests/ at the start if os.path.exists(os.path.abspath(path)): path = os.path.relpath(path, os.path.join(self.topsrcdir)) kwargs["tests"][i] = os.path.join('tests', path) # Need to chdir to reftest_dir otherwise imports fail below. os.chdir(self.reftest_dir) # The imp module can spew warnings if the modules below have # already been imported, ignore them. with warnings.catch_warnings(): warnings.simplefilter('ignore') import imp path = os.path.join(self.reftest_dir, 'remotereftest.py') with open(path, 'r') as fh: imp.load_module('reftest', fh, path, ('.py', 'r', imp.PY_SOURCE)) import reftest self.log_manager.enable_unstructured() try: rv = reftest.run(**kwargs) finally: self.log_manager.disable_unstructured() return rv