Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinguish among different errors more carefully in D-Bus monitoring #271

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions scripts/monitor_dbus_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 []

Expand Down Expand Up @@ -730,7 +726,16 @@ def _check():

return diffs

result = _check()
assert isinstance(_CALLBACK_ERRORS, list)
if _CALLBACK_ERRORS:
print(os.linesep.join(_CALLBACK_ERRORS))
sys.exit(3)

try:
result = _check()
except Exception as exco: # pylint: disable=broad-except
print(f"{exco}")
sys.exit(4)

assert isinstance(result, list)
if not result:
Expand Down
15 changes: 15 additions & 0 deletions testlib/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,21 @@ 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")}'
)

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,
Expand Down