From: Frantisek Sumsal Date: Mon, 17 Oct 2022 16:11:21 +0000 (+0200) Subject: test: call sync() before checking the test logs X-Git-Tag: v252-rc2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3113ae1f2b8b55c8386ff056b054a962c88cdb07;p=thirdparty%2Fsystemd.git test: call sync() before checking the test logs Otherwise we might hit a race where we read the test log just before it's fully written to the disk: ``` ====================================================================== FAIL: test_interleaved (__main__.ExecutionResumeTest.test_interleaved) ---------------------------------------------------------------------- Traceback (most recent call last): File "/root/systemd/test/test-exec-deserialization.py", line 170, in test_interleaved self.check_output(expected_output) File "/root/systemd/test/test-exec-deserialization.py", line 111, in check_output self.assertEqual(output, expected_output) AssertionError: 'foo\n' != 'foo\nbar\n' foo + bar ``` With some debug: ``` test_interleaved (__main__.ExecutionResumeTest.test_interleaved) ... Assertion failed; file contents just after the assertion: b'foo\n' File contents 5 seconds later: b'foo\nbar\n' FAIL ``` Seen quite often in CentOS CI on the fast baremetal machines. --- diff --git a/test/test-exec-deserialization.py b/test/test-exec-deserialization.py index 8ad343f73df..a5afaf547ca 100755 --- a/test/test-exec-deserialization.py +++ b/test/test-exec-deserialization.py @@ -104,6 +104,8 @@ class ExecutionResumeTest(unittest.TestCase): if subprocess.call(['systemctl', '-q', 'is-active', self.unit]) == 0: continue + os.sync() + try: with open(self.output_file, 'r', encoding='utf-8') as log: output = log.read()