tests: Ensure `_process` is set in _TraceTestApplications
authorKienan Stewart <kstewart@efficios.com>
Fri, 9 Feb 2024 14:16:26 +0000 (09:16 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 7 Mar 2024 17:13:53 +0000 (12:13 -0500)
commitcebde614e5805e89341ba75d276b4d3e2da7225f
tree395c76d5b9c97ad84d1f1784c2ef1535e3410aa2
parentd46c935357f0c559289245b9e2b25c8cfaf9d831
tests: Ensure `_process` is set in _TraceTestApplications

Observed issue
==============

An exception is thrown when deleting a _TraceTestApplication object that
has thrown an exception during it's `__init__` method. Eg.

```
Exception ignored in: <function _TraceTestApplication.__del__ at 0x7fcbc9a21620>
Traceback (most recent call last):
  File "/home/kstewart/src/efficios/lttng/master/src/lttng-tools/tests/utils/lttngtest/environment.py", line 348, in __del__
    self._process.kill()
    ^^^^^^^^^^^^^
AttributeError: '_TraceTestApplication' object has no attribute '_process'
```

Similarly, this can happen to _WaitTraceTestApplication objects.

Cause
=====

The object's `_process` attribute is set during `__init__`; however,
if an exception is thrown during `subprocess.Popen` a value is never
assigned to the attribute.

Solution
========

A default value for the `_process` attribute is set and checked as
part of the condition when executing the `__del__` method.

Known drawbacks
===============

None.

Change-Id: I2220ae764be49fafb3b977a5e723931421485d63
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/utils/lttngtest/environment.py
This page took 0.024738 seconds and 4 git commands to generate.