From: Daan De Meyer Date: Tue, 7 May 2024 09:50:11 +0000 (+0200) Subject: test: Don't keep journals for skipped tests X-Git-Tag: v256-rc2~81^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca2e19f2b73d8a489b31106c5d211bdfebf68672;p=thirdparty%2Fsystemd.git test: Don't keep journals for skipped tests Let's make sure we don't save journals for tests that were skipped. --- diff --git a/test/integration-test-wrapper.py b/test/integration-test-wrapper.py index 575403344e4..25b903c4e6a 100755 --- a/test/integration-test-wrapper.py +++ b/test/integration-test-wrapper.py @@ -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) + 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) - # Do not keep journal files for tests that don't fail. 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__':