From b8b97725ef5ef76605d045f2a7cca354a7fc9ca0 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 15 Sep 2023 21:44:44 -0400 Subject: [PATCH] tests: fix all basic type check issues of lttng_live_server.py Do the necessary changes such that this comment passes cleanly: $ PYTHONPATH=/home/smarchi/src/babeltrace/tests/utils/python pyright tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py Pyright pointed out that field _trace_session_state didn't exist, in: @property def trace_session_state(self): return self._trace_session_state The actual field name is _ts_state. However, it shows that this property is never used, so remove it. Change-Id: I115fe473310ecdb1e2fd2e5d369aae33afe963f1 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/10893 Tested-by: jenkins Reviewed-by: Philippe Proulx --- .../src.ctf.lttng-live/lttng_live_server.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py b/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py index 102f7ee8..96879294 100644 --- a/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py +++ b/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py @@ -761,6 +761,11 @@ class _LttngDataStream: self._path = path filename = os.path.basename(path) match = re.match(r"(.*)_\d+", filename) + if not match: + raise RuntimeError( + "Unexpected data stream file name pattern: {}".format(filename) + ) + self._channel_name = match.group(1) trace_dir = os.path.dirname(path) index_path = os.path.join(trace_dir, "index", filename + ".idx") @@ -854,6 +859,12 @@ def _parse_metadata_sections_config(config_sections): line = config_section.get("line") ts = config_section.get("timestamp") + if type(line) is not int: + raise RuntimeError("`line` is not an integer") + + if type(ts) is not int: + raise RuntimeError("`timestamp` is not an integer") + # Sections' timestamps and lines must both be increasing. assert ts > last_timestamp last_timestamp = ts @@ -1076,10 +1087,6 @@ class _LttngLiveViewerSessionMetadataStreamState: ) ) - @property - def trace_session_state(self): - return self._trace_session_state - @property def info(self): return self._info @@ -1435,6 +1442,7 @@ class _LttngLiveViewerSession: metadata_stream_state.is_sent = True status = _LttngLiveViewerGetMetadataStreamDataContentReply.Status.OK metadata_section = metadata_stream_state.cur_section + assert metadata_section is not None # If we are sending an empty section, ready the next one right away. if len(metadata_section.data) == 0: -- 2.34.1