| austin = Variant('austin'), py = '3.9', mode = '-i', mode_meta = 'wall'
|
|
|
| @requires_sudo
|
| @pytest.mark.parametrize(
|
| "mode,mode_meta", [("-i", "wall"), ("-ci", "cpu"), ("-Ci", "wall"), ("-Cci", "cpu")]
|
| )
|
| @allpythons()
|
| @variants
|
| def test_attach_wall_time(austin, py, mode, mode_meta):
|
| with run_python(py, target("sleepy.py"), "2") as p:
|
| sleep(0.5)
|
|
|
| > result = austin(mode, "2ms", "-p", str(p.pid))
|
|
|
| test/functional/test_attach.py:56:
|
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
|
|
| self = Variant('austin'), timeout = 60, convert = True, expect_fail = False
|
| args = ('-i', '2ms', '-p', '2003')
|
|
|
| def __call__(
|
| self,
|
| *args: str,
|
| timeout: int = 60,
|
| convert: bool = True,
|
| expect_fail: Union[bool, int] = False,
|
| ) -> CompletedProcess:
|
| if not self.path.is_file():
|
| if "PYTEST_CURRENT_TEST" in os.environ:
|
| pytest.skip(f"{self} not available")
|
| else:
|
| raise FileNotFoundError(f"Binary {self.path} not found for {self}")
|
|
|
| extra_args = ["-b"] if "-b, --binary" in self.help else []
|
|
|
| try:
|
| result = run(
|
| [str(self.path)] + extra_args + list(args),
|
| capture_output=True,
|
| timeout=timeout,
|
| )
|
| except Exception as exc:
|
| if (pid := getattr(exc, "pid", None)) is not None:
|
| print_logs(collect_logs(self.name, pid))
|
| raise
|
|
|
| if result.returncode in (-11, 139): # SIGSEGV
|
| print(bt(self.path, result.pid))
|
|
|
| # If we are writing to stdout, check if we need to convert the stream
|
| if result.stdout.startswith(b"MOJ"):
|
| if convert:
|
| try:
|
| result.stdout = demojo(result.stdout)
|
| except Exception as e:
|
| dump_mojo(result.stdout)
|
| raise e
|
| else:
|
| result.stdout = result.stdout.decode()
|
| result.stderr = result.stderr.decode()
|
|
|
| logs = collect_logs(self.name, result.pid)
|
| result.logs = logs
|
|
|
| if result.returncode != int(expect_fail):
|
| print_logs(logs)
|
| > raise RuntimeError(
|
| f"Command {self.name} returned {result.returncode} "
|
| f"while expecting {expect_fail}. Output:\n{result.stdout}\n"
|
| f"Error:\n{result.stderr}"
|
| )
|
| E RuntimeError: Command austin returned -11 while expecting False. Output:
|
| E
|
| E Error:
|
| E [1m _ _ [0m
|
| E [1m __ _ _ _ __| |_(_)_ _ [0m
|
| E [1m/ _` | || (_-< _| | ' \ [0m
|
| E [1m\__,_|\_,_/__/\__|_|_||_| [0m [36;1m4.0.0 [0m [gcc 12.4.0]
|
|
|
| test/utils.py:327: RuntimeError
|