From b2cb358ae1c391191fa43a44977229eecb538af5 Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 1 Jul 2024 22:24:02 -0400 Subject: [PATCH 1/2] Return error code 3 for callback errors Signed-off-by: mulhern --- scripts/monitor_dbus_signals.py | 9 +++++---- testlib/infra.py | 8 ++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/monitor_dbus_signals.py b/scripts/monitor_dbus_signals.py index c2d3a75..7810cc6 100755 --- a/scripts/monitor_dbus_signals.py +++ b/scripts/monitor_dbus_signals.py @@ -685,10 +685,6 @@ def _check(): if _PROPERTIES is None: return [] - assert isinstance(_CALLBACK_ERRORS, list) - if _CALLBACK_ERRORS: - return _CALLBACK_ERRORS - if _MO is None: return [] @@ -730,6 +726,11 @@ def _check(): return diffs + assert isinstance(_CALLBACK_ERRORS, list) + if _CALLBACK_ERRORS: + print(os.linesep.join(_CALLBACK_ERRORS)) + sys.exit(3) + result = _check() assert isinstance(result, list) diff --git a/testlib/infra.py b/testlib/infra.py index 139e304..27aac90 100644 --- a/testlib/infra.py +++ b/testlib/infra.py @@ -464,6 +464,14 @@ def run_check(self, stop_time): time.sleep(sleep_time(stop_time, 16)) self.trace.send_signal(signal.SIGINT) (stdoutdata, stderrdata) = self.trace.communicate() + + if self.trace.returncode == 3: + raise RuntimeError( + "Failure while processing D-Bus signals: " + f'stderr: {stderrdata.decode("utf-8")}, ' + f'stdout: {stdoutdata.decode("utf-8")}' + ) + msg = stdoutdata.decode("utf-8") self.assertEqual( self.trace.returncode, From 38197f53fa3ebec03a1d02aa6f37a84485f658a5 Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 1 Jul 2024 22:52:07 -0400 Subject: [PATCH 2/2] Handle exceptions that occur while doing comparison Signed-off-by: mulhern --- scripts/monitor_dbus_signals.py | 6 +++++- testlib/infra.py | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/monitor_dbus_signals.py b/scripts/monitor_dbus_signals.py index 7810cc6..289fad8 100755 --- a/scripts/monitor_dbus_signals.py +++ b/scripts/monitor_dbus_signals.py @@ -731,7 +731,11 @@ def _check(): print(os.linesep.join(_CALLBACK_ERRORS)) sys.exit(3) - result = _check() + try: + result = _check() + except Exception as exco: # pylint: disable=broad-except + print(f"{exco}") + sys.exit(4) assert isinstance(result, list) if not result: diff --git a/testlib/infra.py b/testlib/infra.py index 27aac90..812653e 100644 --- a/testlib/infra.py +++ b/testlib/infra.py @@ -472,6 +472,13 @@ def run_check(self, stop_time): f'stdout: {stdoutdata.decode("utf-8")}' ) + if self.trace.returncode == 4: + raise RuntimeError( + "Failure while comparing D-Bus states: " + f'stderr: {stderrdata.decode("utf-8")}, ' + f'stdout: {stdoutdata.decode("utf-8")}' + ) + msg = stdoutdata.decode("utf-8") self.assertEqual( self.trace.returncode,