def run_gtest(self, test_dir, shuffle, test_filter, package, adb_path, device_serial, remote_test_root, libxul_path, symbols_path, enable_webrender): """ Launch the test app, run gtest, collect test results and wait for completion. Return False if a crash or other failure is detected, else True. """ update_mozinfo() self.device = mozdevice.ADBDeviceFactory(adb=adb_path, device=device_serial, test_root=remote_test_root, logger_name=LOGGER_NAME, verbose=False, run_as_package=package) root = self.device.test_root self.remote_profile = posixpath.join(root, 'gtest-profile') self.remote_minidumps = posixpath.join(root, 'gtest-minidumps') self.remote_log = posixpath.join(root, 'gtest.log') self.remote_libdir = posixpath.join(root, 'gtest') self.package = package self.cleanup() self.device.mkdir(self.remote_profile) self.device.mkdir(self.remote_minidumps) self.device.mkdir(self.remote_libdir) log.info("Running Android gtest") if not self.device.is_app_installed(self.package): raise Exception("%s is not installed on this device" % self.package) # Push the gtest libxul.so to the device. The harness assumes an architecture- # appropriate library is specified and pushes it to the arch-agnostic remote # directory. # TODO -- consider packaging the gtest libxul.so in an apk self.device.push(libxul_path, self.remote_libdir) # Push support files to device. Avoid sub-directories so that libxul.so # is not included. for f in glob.glob(os.path.join(test_dir, "*")): if not os.path.isdir(f): self.device.push(f, self.remote_profile) if test_filter is not None: test_filter = six.ensure_text(test_filter) env = self.build_environment(shuffle, test_filter, enable_webrender) args = ["-unittest", "--gtest_death_test_style=threadsafe", "-profile %s" % self.remote_profile] if 'geckoview' in self.package: activity = "TestRunnerActivity" self.device.launch_activity(self.package, activity_name=activity, e10s=False, # gtest is non-e10s on desktop moz_env=env, extra_args=args) else: self.device.launch_fennec(self.package, moz_env=env, extra_args=args) waiter = AppWaiter(self.device, self.remote_log) timed_out = waiter.wait(self.package) self.shutdown(use_kill=True if timed_out else False) if self.check_for_crashes(symbols_path): return False return True
def device(self): if not self._device: # We must access the adb_path property to activate the # virtualenv before importing mozdevice in order to # import the mozdevice installed into the virtualenv and # not any system-wide installation of mozdevice. adb = self.adb_path import mozdevice self._device = mozdevice.ADBDeviceFactory( adb=adb, device=self.device_serial) return self._device
def setup_kwargs(self, kwargs): from . import android import mozdevice # We don't support multiple channels for android yet if kwargs["browser_channel"] is None: kwargs["browser_channel"] = "nightly" if kwargs["prefs_root"] is None: prefs_root = self.browser.install_prefs( kwargs["binary"], self.venv.path, channel=kwargs["browser_channel"]) kwargs["prefs_root"] = prefs_root if kwargs["package_name"] is None: kwargs["package_name"] = "org.mozilla.geckoview.test" app = kwargs["package_name"] if kwargs["device_serial"] is None: kwargs["device_serial"] = "emulator-5554" # We're running on an emulator so ensure that's set up if kwargs["device_serial"].startswith("emulator-"): emulator = android.install(logger, reinstall=False, no_prompt=not self.prompt) android.start(logger, emulator=emulator, reinstall=False) install = False if hasattr(self, "_install_browser"): if self.prompt_install("geckoview-test"): install = True apk_path = self.browser.install( self.venv.path, channel=kwargs["browser_channel"]) if "ADB_PATH" not in os.environ: adb_path = os.path.join(android.get_sdk_path(None), "platform-tools", "adb") os.environ["ADB_PATH"] = adb_path adb_path = os.environ["ADB_PATH"] device = mozdevice.ADBDeviceFactory(adb=adb_path, device=kwargs["device_serial"]) if install: device.uninstall_app(app) device.install_app(apk_path) elif not device.is_app_installed(app): raise WptrunError("app %s not installed on device %s" % (app, kwargs["device_serial"]))