mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
test: Don't keep journals for skipped tests
Let's make sure we don't save journals for tests that were skipped.
This commit is contained in:
@@ -144,24 +144,29 @@ def main():
|
||||
]
|
||||
|
||||
result = subprocess.run(cmd)
|
||||
# Return code 123 is the expected success code
|
||||
if result.returncode != 123:
|
||||
if result.returncode != 77 and journal_file:
|
||||
cmd = [
|
||||
'journalctl',
|
||||
'--no-hostname',
|
||||
'-o', 'short-monotonic',
|
||||
'--file', journal_file,
|
||||
'-u', test_unit,
|
||||
'-p', 'info',
|
||||
]
|
||||
print("Test failed, relevant logs can be viewed with: \n\n"
|
||||
f"{shlex.join(str(a) for a in cmd)}\n", file=sys.stderr)
|
||||
exit(result.returncode or 1)
|
||||
|
||||
# Do not keep journal files for tests that don't fail.
|
||||
# Return code 123 is the expected success code
|
||||
if result.returncode in (123, 77):
|
||||
# Do not keep journal files for tests that don't fail.
|
||||
if journal_file:
|
||||
journal_file.unlink(missing_ok=True)
|
||||
|
||||
exit(0 if result.returncode == 123 else 77)
|
||||
|
||||
if journal_file:
|
||||
journal_file.unlink(missing_ok=True)
|
||||
cmd = [
|
||||
'journalctl',
|
||||
'--no-hostname',
|
||||
'-o', 'short-monotonic',
|
||||
'--file', journal_file,
|
||||
'-u', test_unit,
|
||||
'-p', 'info',
|
||||
]
|
||||
print("Test failed, relevant logs can be viewed with: \n\n"
|
||||
f"{shlex.join(str(a) for a in cmd)}\n", file=sys.stderr)
|
||||
|
||||
# 0 also means we failed so translate that to a non-zero exit code to mark the test as failed.
|
||||
exit(result.returncode or 1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user