test: call sync() before checking the test logs
authorFrantisek Sumsal <frantisek@sumsal.cz>
Mon, 17 Oct 2022 16:11:21 +0000 (18:11 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Mon, 17 Oct 2022 20:24:24 +0000 (20:24 +0000)
commit3113ae1f2b8b55c8386ff056b054a962c88cdb07
treea0d6a8ef1970aa01c772b72cd49ca9a5b1e7b7a7
parent61938b3c8dca8a37c62cf306359ec8dd0f62ea60
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.
test/test-exec-deserialization.py