Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_ffpuppet_19(tmp_path):
"""test launching with Valgrind"""
if platform.system() != "Linux":
with pytest.raises(EnvironmentError, match="Valgrind is only supported on Linux"):
FFPuppet(use_valgrind=True)
return
vmv = FFPuppet.VALGRIND_MIN_VERSION
try:
FFPuppet.VALGRIND_MIN_VERSION = 9999999999.99
with pytest.raises(EnvironmentError, match=r"Valgrind >= \d+\.\d+ is required"):
FFPuppet(use_valgrind=True)
FFPuppet.VALGRIND_MIN_VERSION = 0
with FFPuppet(use_valgrind=True) as ffp:
bin_path = str(check_output(["which", "echo"]).strip().decode("ascii"))
# launch will fail b/c 'echo' will exit right away but that's fine
with pytest.raises(LaunchError, match="Failure waiting for browser connection"):
ffp.launch(bin_path)
ffp.close()
ffp.save_logs(str(tmp_path / "logs"))
log_data = (tmp_path / "logs" / "log_stderr.txt").read_bytes()
# verify Valgrind ran and executed the script
assert b"valgrind -q" in log_data
assert b"[ffpuppet] Reason code: EXITED" in log_data
finally:
FFPuppet.VALGRIND_MIN_VERSION = vmv
with pytest.raises(EnvironmentError, match=r"Valgrind >= \d+\.\d+ is required"):
FFPuppet(use_valgrind=True)
FFPuppet.VALGRIND_MIN_VERSION = 0
with FFPuppet(use_valgrind=True) as ffp:
bin_path = str(check_output(["which", "echo"]).strip().decode("ascii"))
# launch will fail b/c 'echo' will exit right away but that's fine
with pytest.raises(LaunchError, match="Failure waiting for browser connection"):
ffp.launch(bin_path)
ffp.close()
ffp.save_logs(str(tmp_path / "logs"))
log_data = (tmp_path / "logs" / "log_stderr.txt").read_bytes()
# verify Valgrind ran and executed the script
assert b"valgrind -q" in log_data
assert b"[ffpuppet] Reason code: EXITED" in log_data
finally:
FFPuppet.VALGRIND_MIN_VERSION = vmv
def test_ffpuppet_19(tmp_path):
"""test launching with Valgrind"""
if platform.system() != "Linux":
with pytest.raises(EnvironmentError, match="Valgrind is only supported on Linux"):
FFPuppet(use_valgrind=True)
return
vmv = FFPuppet.VALGRIND_MIN_VERSION
try:
FFPuppet.VALGRIND_MIN_VERSION = 9999999999.99
with pytest.raises(EnvironmentError, match=r"Valgrind >= \d+\.\d+ is required"):
FFPuppet(use_valgrind=True)
FFPuppet.VALGRIND_MIN_VERSION = 0
with FFPuppet(use_valgrind=True) as ffp:
bin_path = str(check_output(["which", "echo"]).strip().decode("ascii"))
# launch will fail b/c 'echo' will exit right away but that's fine
with pytest.raises(LaunchError, match="Failure waiting for browser connection"):
ffp.launch(bin_path)
ffp.close()
ffp.save_logs(str(tmp_path / "logs"))
log_data = (tmp_path / "logs" / "log_stderr.txt").read_bytes()
# verify Valgrind ran and executed the script
assert b"valgrind -q" in log_data
assert b"[ffpuppet] Reason code: EXITED" in log_data
def test_ffpuppet_19(tmp_path):
"""test launching with Valgrind"""
if platform.system() != "Linux":
with pytest.raises(EnvironmentError, match="Valgrind is only supported on Linux"):
FFPuppet(use_valgrind=True)
return
vmv = FFPuppet.VALGRIND_MIN_VERSION
try:
FFPuppet.VALGRIND_MIN_VERSION = 9999999999.99
with pytest.raises(EnvironmentError, match=r"Valgrind >= \d+\.\d+ is required"):
FFPuppet(use_valgrind=True)
FFPuppet.VALGRIND_MIN_VERSION = 0
with FFPuppet(use_valgrind=True) as ffp:
bin_path = str(check_output(["which", "echo"]).strip().decode("ascii"))
# launch will fail b/c 'echo' will exit right away but that's fine
with pytest.raises(LaunchError, match="Failure waiting for browser connection"):
ffp.launch(bin_path)
ffp.close()
ffp.save_logs(str(tmp_path / "logs"))
log_data = (tmp_path / "logs" / "log_stderr.txt").read_bytes()
# verify Valgrind ran and executed the script
assert b"valgrind -q" in log_data
assert b"[ffpuppet] Reason code: EXITED" in log_data
finally:
FFPuppet.VALGRIND_MIN_VERSION = vmv
self._xvfb = None
self.profile = None # path to profile
self.reason = self.RC_CLOSED # why the target process was terminated
plat = platform.system().lower()
if use_valgrind:
assert not (use_gdb or use_rr), "only a single debugger can be enabled"
if not plat.startswith("linux"):
raise EnvironmentError("Valgrind is only supported on Linux")
try:
match = re.match(
b"valgrind-(?P\\d+\\.\\d+)",
subprocess.check_output(["valgrind", "--version"]))
except OSError:
raise EnvironmentError("Please install Valgrind")
if not match or float(match.group("ver")) < FFPuppet.VALGRIND_MIN_VERSION:
raise EnvironmentError("Valgrind >= %0.2f is required" % FFPuppet.VALGRIND_MIN_VERSION)
if use_gdb:
assert not (use_rr or use_valgrind), "only a single debugger can be enabled"
if not plat.startswith("linux"):
raise EnvironmentError("GDB is only supported on Linux")
try:
subprocess.check_output(["gdb", "--version"])
except OSError:
raise EnvironmentError("Please install GDB")
if use_rr:
assert not (use_gdb or use_valgrind), "only a single debugger can be enabled"
if not plat.startswith("linux"):
raise EnvironmentError("rr is only supported on Linux")
try: