]> git.lttng.org Git - lttng-tools.git/commitdiff
Tests: Check python version before using signal.strsignal
authorKienan Stewart <kstewart@efficios.com>
Thu, 7 Nov 2024 13:38:13 +0000 (08:38 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 18 Dec 2024 15:53:39 +0000 (15:53 +0000)
Observed issue
==============

When running CI tests against sles12sp5 (with python 3.4) the clean-up
of a stalled test produced the following output:

```
Traceback (most recent call last):
  File "./tools/live/test_early_inactive_app.py", line 111, in <module>
    log=tap.diagnostic, with_relayd=True, with_sessiond=True
  File "/usr/lib64/python3.4/contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "/home/jenkins/workspace/dev_review_lttng-tools_master_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/platform/sles12sp5-amd64/src/lttng-tools/tests/utils/lttngtest/environment.py", line 1192, in test_environment
    with_sessiond, log, with_relayd, extra_env_vars, skip_temporary_lttng_home
  File "/home/jenkins/workspace/dev_review_lttng-tools_master_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/platform/sles12sp5-amd64/src/lttng-tools/tests/utils/lttngtest/environment.py", line 677, in __init__
    self._launch_lttng_relayd() if with_relayd else None
  File "/home/jenkins/workspace/dev_review_lttng-tools_master_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/platform/sles12sp5-amd64/src/lttng-tools/tests/utils/lttngtest/environment.py", line 933, in _launch_lttng_relayd
    time.sleep(0.1)
  File "/home/jenkins/workspace/dev_review_lttng-tools_master_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/platform/sles12sp5-amd64/src/lttng-tools/tests/utils/lttngtest/environment.py", line 1044, in _handle_termination_signal
    signal_name=signal.strsignal(signal_number)
AttributeError: 'module' object has no attribute 'strsignal'
```

Cause
=====

`signal.strsignal` is introduced in Python 3.8[1].

Solution
========

Check the system version and fall back to using `str(signal_number)`
which will give the numeric signal (e.g. signal.SIGKILL -> 9).

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

None.

References
==========
[1]: https://docs.python.org/3/library/signal.html#signal.strsignal

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

index 1cc87a1fe4fdfa0be522f20f0578ebb740f83dfb..6e2d2e9abd3e6e7d9b4c64162db6776da1d18805 100644 (file)
@@ -995,11 +995,15 @@ class _Environment(logger._Logger):
 
     def _handle_termination_signal(self, signal_number, frame):
         # type: (int, Optional[FrameType]) -> None
-        self._log(
-            "Killed by {signal_name} signal, cleaning-up".format(
-                signal_name=signal.strsignal(signal_number)
+        if sys.version_info[0] == 3 and sys.version_info[1] >= 8:
+            # signal.strsignal is introduced in python 3.8
+            self._log(
+                "Killed by {signal_name} signal, cleaning-up".format(
+                    signal_name=signal.strsignal(signal_number)
+                )
             )
-        )
+        else:
+            self._log("Killed by signal {}, cleaning-up".format(str(signal_number)))
         self._cleanup()
 
     def launch_live_viewer(self, session, hostname=None):
This page took 0.029542 seconds and 4 git commands to generate.