From 7fe25c75d493c3869d31795f24a5569e29479b20 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Wed, 13 Nov 2024 10:58:06 -0500 Subject: [PATCH] Tests: Add option to set session shm path MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I0a5b2b32351438d37c47f3e9920e5cebbf1bdf50 Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- tests/utils/lttngtest/lttng.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/utils/lttngtest/lttng.py b/tests/utils/lttngtest/lttng.py index 6bccb9126..b447c22b8 100644 --- a/tests/utils/lttngtest/lttng.py +++ b/tests/utils/lttngtest/lttng.py @@ -708,26 +708,29 @@ class LTTngClient(logger._Logger, lttngctl.Controller): else: return out.decode("utf-8") - def create_session(self, name=None, output=None, live=False): - # type: (Optional[str], Optional[lttngctl.SessionOutputLocation], bool) -> lttngctl.Session + def create_session( + self, name=None, output=None, live=False, snapshot=False, shm_path=None + ): + # type: (Optional[str], Optional[lttngctl.SessionOutputLocation], bool, Optional[pathlib.Path]) -> lttngctl.Session name = name if name else lttngctl.Session._generate_name() + args = ["create", name] if isinstance(output, lttngctl.LocalSessionOutputLocation): - output_option = "--output '{output_path}'".format(output_path=output.path) + args.extend(["--output", str(output.path)]) elif isinstance(output, lttngctl.NetworkSessionOutputLocation): - output_option = "--set-url '{}'".format(output.url) + args.extend(["--set-url", output.url]) elif output is None: - output_option = "--no-output" + args.append("--no-output") else: raise TypeError("LTTngClient only supports local or no output") - self._run_cmd( - "create '{session_name}' {output_option} {live_option}".format( - session_name=name, - output_option=output_option, - live_option="--live" if live else "", - ) - ) + if live: + args.append("--live") + if shm_path is not None: + args.extend(["--shm-path", str(shm_path)]) + if snapshot: + args.append("--snapshot") + self._run_cmd(" ".join([shlex.quote(x) for x in args])) return _Session(self, name, output) def start_session_by_name(self, name): -- 2.39.5