test-journal-flush: do not croak on corrupted input files

We would fail if the input file was corrupted:
build/test-journal-flush ./system@0005b7dac334f805-0021aca076ae5c5e.journal\~
journal_file_copy_entry failed: Bad message
Assertion 'r >= 0' failed at src/libsystemd/sd-journal/test-journal-flush.c:55, function main(). Aborting.
[1]    619472 IOT instruction (core dumped)  build/test-journal-flush ./system@0005b7dac334f805-0021aca076ae5c5e.journal\~

Let's skip some "reasonable" errors.

Fixes #17963.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-11-26 09:46:02 +01:00
parent 0fa167cd58
commit b4046d5557

View File

@ -51,8 +51,11 @@ int main(int argc, char *argv[]) {
r = journal_file_copy_entry(f, new_journal, o, f->current_offset);
if (r < 0)
log_error_errno(r, "journal_file_copy_entry failed: %m");
assert_se(r >= 0);
log_warning_errno(r, "journal_file_copy_entry failed: %m");
assert_se(r >= 0 ||
IN_SET(r, -EBADMSG, /* corrupted file */
-EPROTONOSUPPORT, /* unsupported compression */
-EIO)); /* file rotated */
if (++n >= 10000)
break;