diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-11-06 01:01:17 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-02-15 00:31:55 -0500 |
commit | f06a6bcd761f2a643377b17c16776512404ac3b0 (patch) | |
tree | 52e41d047a53ceaa07c3a3c1f58c27c88757d2a2 /src | |
parent | 48ccb60d453b06584e58f6ffca47b2204f9c65db (diff) |
test-journal-importer: add a test case with broken input
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test-journal-importer.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/test/test-journal-importer.c b/src/test/test-journal-importer.c index fea5c1d51c..1f0684863e 100644 --- a/src/test/test-journal-importer.c +++ b/src/test/test-journal-importer.c @@ -44,7 +44,7 @@ static void test_basic_parsing(void) { do r = journal_importer_process_data(&imp); - while (r == 0); + while (r == 0 && !journal_importer_eof(&imp)); assert_se(r == 1); /* We read one entry, so we should get EOF on next read, but not yet */ @@ -64,11 +64,27 @@ static void test_basic_parsing(void) { assert_se(journal_importer_eof(&imp)); } +static void test_bad_input(void) { + _cleanup_(journal_importer_cleanup) JournalImporter imp = {}; + int r; + + imp.fd = open(TEST_DATA_DIR("/journal-data/journal-2.txt"), O_RDONLY|O_CLOEXEC); + assert_se(imp.fd >= 0); + + do + r = journal_importer_process_data(&imp); + while (!journal_importer_eof(&imp)); + assert_se(r == 0); /* If we don't have enough input, 0 is returned */ + + assert_se(journal_importer_eof(&imp)); +} + int main(int argc, char **argv) { log_set_max_level(LOG_DEBUG); log_parse_environment(); test_basic_parsing(); + test_bad_input(); return 0; } |