Fix: Tests: Use wait_before_exit_file_path in WaitTraceTestApplication
authorKienan Stewart <kstewart@efficios.com>
Fri, 29 Mar 2024 20:58:20 +0000 (16:58 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 30 Aug 2024 21:06:52 +0000 (17:06 -0400)
The `_WaitTraceTestApplication`'s `__init__` method proposed the
`wait_before_exit` and `wait_before_exit_file_path` parameters; however,
the parameters weren't then passed onwards to the trace test
application's invocation.

Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Change-Id: I9055aa206a8fd943012bacfa49d6ff152f2dfbde
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/utils/lttngtest/environment.py

index 6cb2ebaf019a2b051b4cae17cdcf72d9fa5d76dc..ea958cc2f1c3ce656114a312887dedb6ca1c704f 100644 (file)
@@ -249,11 +249,12 @@ class _WaitTraceTestApplication:
                 tempfile.mktemp(
                     prefix="app_",
                     suffix="_exit",
-                    dir=self._compat_pathlike(environment.lttng_home_location),
+                    dir=dir,
                 )
             )
-
+        self._wait_before_exit_file_path = wait_before_exit_file_path
         self._has_returned = False
+        self._tracing_started = False
 
         test_app_env = os.environ.copy()
         test_app_env["LTTNG_HOME"] = str(environment.lttng_home_location)
@@ -279,6 +280,10 @@ class _WaitTraceTestApplication:
         test_app_args.extend(
             ["--sync-before-exit-touch", str(self._app_tracing_done_file_path)]
         )
+        if wait_before_exit:
+            test_app_args.extend(
+                ["--sync-before-exit", str(self._wait_before_exit_file_path)]
+            )
         if wait_time_between_events_us != 0:
             test_app_args.extend(["--wait", str(wait_time_between_events_us)])
 
@@ -380,6 +385,9 @@ class _WaitTraceTestApplication:
 
             time.sleep(0.001)
 
+    def touch_exit_file(self):
+        open(self._compat_pathlike(self._wait_before_exit_file_path), mode="x")
+
     def trace(self):
         # type: () -> None
         if self._process.poll() is not None:
@@ -390,10 +398,15 @@ class _WaitTraceTestApplication:
                 )
             )
         open(self._compat_pathlike(self._app_start_tracing_file_path), mode="x")
+        self._environment._log("[{}] Tracing started".format(self.vpid))
+        self._tracing_started = True
 
     def wait_for_tracing_done(self):
         # type: () -> None
+        if not self._tracing_started:
+            raise RuntimeError("Tracing hasn't been started")
         self._wait_for_file_to_be_created(self._app_tracing_done_file_path)
+        self._environment._log("[{}] Tracing done".format(self.vpid))
 
     def wait_for_exit(self):
         # type: () -> None
@@ -504,12 +517,8 @@ class WaitTraceTestApplicationGroup:
         for app in self._apps:
             app.wait_for_tracing_done()
 
-        open(
-            _WaitTraceTestApplication._compat_pathlike(
-                self._wait_before_exit_file_path
-            ),
-            mode="x",
-        )
+        self._apps[0].touch_exit_file()
+
         # Performed in two passes to allow tests to stress the unregistration of many applications.
         # Waiting for each app to exit turn-by-turn would defeat the purpose here.
         if wait_for_apps:
This page took 0.025819 seconds and 4 git commands to generate.