Tests: lttngctl.py: allow the creation of per-pid buffers
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 15 Jun 2023 16:09:05 +0000 (12:09 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 15 Jun 2023 16:09:05 +0000 (12:09 -0400)
Add BufferSharingPolicy which can be used with the add_channel method of
a Session to create per-pid channels.

This is done to allow tests for the per-pid buffer sharing mode to be
written using the python utils.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ice3b5d3a8db69c95aaa632c45f42069ab2be590c

tests/utils/lttngtest/lttng.py
tests/utils/lttngtest/lttngctl.py

index ea92616c6d0a0d3001be234c374e6d5c740bf3f2..2b9dec5adafaba0772fd371740500db06a3d18ab 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)
index 9b9658ec626086ef280d8acc9ff19c26894f60d0..c2afa885f56f14448ea9c5c30bd0688afcfd9a25 100644 (file)
@@ -89,6 +89,17 @@ class TracingDomain(enum.Enum):
         return "<%s.%s>" % (self.__class__.__name__, self.name)
 
 
+@enum.unique
+class BufferSharingPolicy(enum.Enum):
+    """Buffer sharing policy."""
+
+    PerUID = "Per-UID buffering"
+    PerPID = "Per-PID buffering"
+
+    def __repr__(self):
+        return "<%s.%s>" % (self.__class__.__name__, self.name)
+
+
 class EventRule(abc.ABC):
     """Event rule base class, see LTTNG-EVENT-RULE(7)."""
 
@@ -351,8 +362,13 @@ class Session(abc.ABC):
         pass
 
     @abc.abstractmethod
-    def add_channel(self, domain, channel_name=None):
-        # type: (TracingDomain, Optional[str]) -> Channel
+    def add_channel(
+        self,
+        domain,
+        channel_name=None,
+        buffer_sharing_policy=BufferSharingPolicy.PerUID,
+    ):
+        # type: (TracingDomain, Optional[str], BufferSharingPolicy) -> Channel
         """Add a channel with default attributes to the session."""
         pass
 
This page took 0.027253 seconds and 4 git commands to generate.