How to use the ffpuppet.LaunchError function in ffpuppet

To help you get started, we’ve selected a few ffpuppet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MozillaSecurity / grizzly / grizzly / reduce / test_interesting.py View on Github external
"target should be launched more than once on error"

    class MyTarget(FakeTarget):

        def launch(self, *args, **kwds):
            FakeTarget.launch(self, *args, **kwds)
            raise ffpuppet.LaunchError()

    obj = Interesting([], MyTarget(), 30, False, False, 0, 1, 1, 0, 0, 0, FakeReduceStatus())
    create_target_binary(obj.target, tmp_path)
    prefix = tmp_path / "lithium"
    prefix.mkdir()
    (tmp_path / "test.html").touch()
    obj.reduce_file = str(tmp_path / "test.html")
    obj.init(None)
    with pytest.raises(ffpuppet.LaunchError):
        obj.interesting(None, str(prefix))
    assert obj.server is not None
    assert obj.target._calls["launch"] > 1
    obj.cleanup(None)
    assert obj.target._calls["cleanup"] == 0
github MozillaSecurity / grizzly / grizzly / reduce / test_interesting.py View on Github external
def launch(self, *args, **kwds):
            FakeTarget.launch(self, *args, **kwds)
            raise ffpuppet.LaunchError()
github MozillaSecurity / grizzly / grizzly / reduce / interesting.py View on Github external
self.server.set_redirect("/first_test", str(self.landing_page), required=True)

        if self.no_harness:
            self.server.timeout = self.iter_timeout
        else:
            # wait a few extra seconds to avoid races between the harness & sapphire timing out
            self.server.timeout = self.iter_timeout + 10

        # (re)launch Target
        if self.target.closed:
            # Try to launch the browser at most, 4 times
            for retries in reversed(range(4)):
                try:
                    self.target.launch(self.location, env_mod=self.env_mod)
                    break
                except ffpuppet.LaunchError as exc:
                    if retries:
                        LOG.warning(str(exc))
                        time.sleep(15)
                    else:
                        raise
            self.target.step()

        try:
            idle_timeout_event = threading.Event()
            iteration_done_event = threading.Event()
            if self.idle_poll:
                monitor_launched = threading.Event()
                poll = threading.Thread(target=self.monitor_process,
                                        args=(iteration_done_event, idle_timeout_event, monitor_launched))
                poll.start()
                assert monitor_launched.wait(30), "Failed to launch monitoring thread"
github MozillaSecurity / grizzly / grizzly / target / adb_target.py View on Github external
env_mod = dict(env_mod or [])
        # This may be used to disabled network connections during testing, e.g.
        env_mod["MOZ_IN_AUTOMATION"] = "1"
        # prevent crash reporter from touching the dmp files
        env_mod["MOZ_CRASHREPORTER"] = "1"
        env_mod["MOZ_CRASHREPORTER_NO_REPORT"] = "1"
        env_mod["MOZ_CRASHREPORTER_SHUTDOWN"] = "1"
        # do not allow network connections to non local endpoints
        env_mod["MOZ_DISABLE_NONLOCAL_CONNECTIONS"] = "1"
        try:
            self._proc.launch(
                env_mod=env_mod,
                launch_timeout=self.launch_timeout,
                prefs_js=self.prefs,
                url=location)
        except LaunchError:
            self._proc.close()
            raise
github MozillaSecurity / grizzly / grizzly / target / puppet_target.py View on Github external
self.rl_countdown = self.rl_reset
        env_mod = dict(env_mod or [])
        # do not allow network connections to non local endpoints
        env_mod["MOZ_DISABLE_NONLOCAL_CONNECTIONS"] = "1"
        env_mod["MOZ_CRASHREPORTER_SHUTDOWN"] = "1"
        try:
            self._puppet.launch(
                self.binary,
                launch_timeout=self.launch_timeout,
                location=location,
                log_limit=self.log_limit,
                memory_limit=self.memory_limit,
                prefs_js=self.prefs,
                extension=self.extension,
                env_mod=env_mod)
        except LaunchError as exc:
            log.error("FFPuppet Error: %s", str(exc))
            self.close()
            if isinstance(exc, BrowserTimeoutError):
                raise TargetLaunchTimeout(str(exc))
            raise TargetLaunchError(str(exc))
github MozillaSecurity / grizzly / grizzly / reduce / reduce.py View on Github external
return Session.EXIT_SUCCESS

        LOG.warning("Reduction failed: %s", FuzzManagerReporter.quality_name(job.result_code))
        return Session.EXIT_ERROR

    except NoTestcaseError:
        with ReducerStats() as stats:
            stats.error += 1
        # TODO: test should be marked as Q7
        return Session.EXIT_ERROR

    except KeyboardInterrupt:
        job_cancelled = True
        return Session.EXIT_ABORT

    except ffpuppet.LaunchError as exc:
        LOG.error("Error launching target: %s", exc)
        with ReducerStats() as stats:
            stats.error += 1
        return Session.EXIT_LAUNCH_FAILURE

    finally:
        LOG.warning("Shutting down...")
        if job is not None and not job_cancelled:
            job_cancelled = job.result_code in {FuzzManagerReporter.QUAL_REDUCER_BROKE,
                                                FuzzManagerReporter.QUAL_REDUCER_ERROR}
        if job is not None:
            job.close(keep_temp=job_cancelled)
        # job handles calling cleanup if it was created
        if job is None and target is not None:
            target.cleanup()
        # call cleanup if we are unlikely to be using status again