Tests fix: lttngtest: quote session output path
[lttng-tools.git] / tests / utils / lttngtest / lttng.py
index ea92616c6d0a0d3001be234c374e6d5c740bf3f2..9dd21fb033fc7566411c2d369a1e1d1083ace26c 100644 (file)
@@ -250,15 +250,23 @@ class _Session(lttngctl.Session):
         # type: () -> str
         return self._name
 
-    def add_channel(self, domain, channel_name=None):
-        # type: (lttngctl.TracingDomain, Optional[str]) -> lttngctl.Channel
+    def add_channel(
+        self,
+        domain,
+        channel_name=None,
+        buffer_sharing_policy=lttngctl.BufferSharingPolicy.PerUID,
+    ):
+        # type: (lttngctl.TracingDomain, Optional[str], lttngctl.BufferSharingPolicy) -> lttngctl.Channel
         channel_name = lttngctl.Channel._generate_name()
         domain_option_name = _get_domain_option_name(domain)
         self._client._run_cmd(
-            "enable-channel --session '{session_name}' --{domain_name} '{channel_name}'".format(
+            "enable-channel --session '{session_name}' --{domain_name} '{channel_name}' {buffer_sharing_policy}".format(
                 session_name=self.name,
                 domain_name=domain_option_name,
                 channel_name=channel_name,
+                buffer_sharing_policy="--buffers-uid"
+                if buffer_sharing_policy == lttngctl.BufferSharingPolicy.PerUID
+                else "--buffers-pid",
             )
         )
         return _Channel(self._client, channel_name, domain, self)
@@ -284,6 +292,10 @@ class _Session(lttngctl.Session):
         # type: () -> None
         self._client._run_cmd("destroy '{session_name}'".format(session_name=self.name))
 
+    def rotate(self, wait=True):
+        # type: (bool) -> None
+        self._client.rotate_session_by_name(self.name, wait)
+
     @property
     def is_active(self):
         # type: () -> bool
@@ -423,7 +435,7 @@ class LTTngClient(logger._Logger, lttngctl.Controller):
         name = name if name else lttngctl.Session._generate_name()
 
         if isinstance(output, lttngctl.LocalSessionOutputLocation):
-            output_option = "--output {output_path}".format(output_path=output.path)
+            output_option = "--output '{output_path}'".format(output_path=output.path)
         elif output is None:
             output_option = "--no-output"
         else:
@@ -472,6 +484,29 @@ class LTTngClient(logger._Logger, lttngctl.Controller):
         # type: () -> None
         self._run_cmd("destroy --all")
 
+    def rotate_session_by_name(self, name, wait=True):
+        self._run_cmd(
+            "rotate '{session_name}' {wait_option}".format(
+                session_name=name, wait_option="-n" if wait is False else ""
+            )
+        )
+
+    def schedule_size_based_rotation(self, name, size_bytes):
+        # type (str, int) -> None
+        self._run_cmd(
+            "enable-rotation --session '{session_name}' --size {size}".format(
+                session_name=name, size=size_bytes
+            )
+        )
+
+    def schedule_time_based_rotation(self, name, period_seconds):
+        # type (str, int) -> None
+        self._run_cmd(
+            "enable-rotation --session '{session_name}' --timer {period_seconds}s".format(
+                session_name=name, period_seconds=period_seconds
+            )
+        )
+
     @staticmethod
     def _mi_find_in_element(element, sub_element_name):
         # type: (xml.etree.ElementTree.Element, str) -> xml.etree.ElementTree.Element
This page took 0.024959 seconds and 4 git commands to generate.