diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2022-01-21 15:19:26 +0000 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2022-10-07 12:16:11 +0200 |
commit | c92f1ebe5d0f6ffb0d3e9730aae662dbbfcea035 (patch) | |
tree | 4973a8a47c63b9b1609ed7fda5324a6168f09a0b /src | |
parent | 61297656c7677a0c8574b95581499b241bfd261f (diff) | |
download | systemd-c92f1ebe5d0f6ffb0d3e9730aae662dbbfcea035.tar.gz |
journal: Run unit tests with and without compact mode enabled
Diffstat (limited to 'src')
-rw-r--r-- | src/journal/test-journal-flush.c | 10 | ||||
-rw-r--r-- | src/journal/test-journal-interleaving.c | 10 | ||||
-rw-r--r-- | src/journal/test-journal-stream.c | 11 | ||||
-rw-r--r-- | src/journal/test-journal-verify.c | 12 | ||||
-rw-r--r-- | src/journal/test-journal.c | 30 |
5 files changed, 65 insertions, 8 deletions
diff --git a/src/journal/test-journal-flush.c b/src/journal/test-journal-flush.c index 06eeb1a578..c734aa02ca 100644 --- a/src/journal/test-journal-flush.c +++ b/src/journal/test-journal-flush.c @@ -13,7 +13,7 @@ #include "path-util.h" #include "string-util.h" -int main(int argc, char *argv[]) { +static void test_journal_flush(int argc, char *argv[]) { _cleanup_(mmap_cache_unrefp) MMapCache *m = NULL; _cleanup_free_ char *fn = NULL; char dn[] = "/var/tmp/test-journal-flush.XXXXXX"; @@ -70,6 +70,14 @@ int main(int argc, char *argv[]) { unlink(fn); assert_se(rmdir(dn) == 0); +} + +int main(int argc, char *argv[]) { + assert_se(setenv("SYSTEMD_JOURNAL_COMPACT", "0", 1) >= 0); + test_journal_flush(argc, argv); + + assert_se(setenv("SYSTEMD_JOURNAL_COMPACT", "1", 1) >= 0); + test_journal_flush(argc, argv); return 0; } diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c index eeb67be019..378bf162ca 100644 --- a/src/journal/test-journal-interleaving.c +++ b/src/journal/test-journal-interleaving.c @@ -210,7 +210,7 @@ TEST(skip) { test_skip_one(setup_interleaved); } -TEST(sequence_numbers) { +static void test_sequence_numbers_one(void) { _cleanup_(mmap_cache_unrefp) MMapCache *m = NULL; char t[] = "/var/tmp/journal-seq-XXXXXX"; ManagedJournalFile *one, *two; @@ -295,6 +295,14 @@ TEST(sequence_numbers) { } } +TEST(sequence_numbers) { + assert_se(setenv("SYSTEMD_JOURNAL_COMPACT", "0", 1) >= 0); + test_sequence_numbers_one(); + + assert_se(setenv("SYSTEMD_JOURNAL_COMPACT", "1", 1) >= 0); + test_sequence_numbers_one(); +} + static int intro(void) { /* managed_journal_file_open requires a valid machine id */ if (access("/etc/machine-id", F_OK) != 0) diff --git a/src/journal/test-journal-stream.c b/src/journal/test-journal-stream.c index f7bbd4bff9..ac5b7f0005 100644 --- a/src/journal/test-journal-stream.c +++ b/src/journal/test-journal-stream.c @@ -184,11 +184,18 @@ int main(int argc, char *argv[]) { test_setup_logging(LOG_DEBUG); - /* Run this test twice. Once with old hashing and once with new hashing */ + /* Run this test multiple times with different configurations of features. */ + + assert_se(setenv("SYSTEMD_JOURNAL_KEYED_HASH", "0", 1) >= 0); + run_test(); + assert_se(setenv("SYSTEMD_JOURNAL_KEYED_HASH", "1", 1) >= 0); run_test(); - assert_se(setenv("SYSTEMD_JOURNAL_KEYED_HASH", "0", 1) >= 0); + assert_se(setenv("SYSTEMD_JOURNAL_COMPACT", "0", 1) >= 0); + run_test(); + + assert_se(setenv("SYSTEMD_JOURNAL_COMPACT", "1", 1) >= 0); run_test(); return 0; diff --git a/src/journal/test-journal-verify.c b/src/journal/test-journal-verify.c index b971c79ea9..e36ea8cae1 100644 --- a/src/journal/test-journal-verify.c +++ b/src/journal/test-journal-verify.c @@ -56,7 +56,7 @@ static int raw_verify(const char *fn, const char *verification_key) { return r; } -int main(int argc, char *argv[]) { +static int run_test(int argc, char *argv[]) { _cleanup_(mmap_cache_unrefp) MMapCache *m = NULL; char t[] = "/var/tmp/journal-XXXXXX"; unsigned n; @@ -141,3 +141,13 @@ int main(int argc, char *argv[]) { return 0; } + +int main(int argc, char *argv[]) { + assert_se(setenv("SYSTEMD_JOURNAL_COMPACT", "0", 1) >= 0); + run_test(argc, argv); + + assert_se(setenv("SYSTEMD_JOURNAL_COMPACT", "1", 1) >= 0); + run_test(argc, argv); + + return 0; +} diff --git a/src/journal/test-journal.c b/src/journal/test-journal.c index 70b216ba67..889673cae7 100644 --- a/src/journal/test-journal.c +++ b/src/journal/test-journal.c @@ -23,7 +23,7 @@ static void mkdtemp_chdir_chattr(char *path) { (void) chattr_path(path, FS_NOCOW_FL, FS_NOCOW_FL, NULL); } -TEST(non_empty) { +static void test_non_empty_one(void) { _cleanup_(mmap_cache_unrefp) MMapCache *m = NULL; dual_timestamp ts; ManagedJournalFile *f; @@ -118,7 +118,15 @@ TEST(non_empty) { puts("------------------------------------------------------------"); } -TEST(empty) { +TEST(non_empty) { + assert_se(setenv("SYSTEMD_JOURNAL_COMPACT", "0", 1) >= 0); + test_non_empty_one(); + + assert_se(setenv("SYSTEMD_JOURNAL_COMPACT", "1", 1) >= 0); + test_non_empty_one(); +} + +static void test_empty_one(void) { _cleanup_(mmap_cache_unrefp) MMapCache *m = NULL; ManagedJournalFile *f1, *f2, *f3, *f4; char t[] = "/var/tmp/journal-XXXXXX"; @@ -158,6 +166,14 @@ TEST(empty) { (void) managed_journal_file_close(f4); } +TEST(empty) { + assert_se(setenv("SYSTEMD_JOURNAL_COMPACT", "0", 1) >= 0); + test_empty_one(); + + assert_se(setenv("SYSTEMD_JOURNAL_COMPACT", "1", 1) >= 0); + test_empty_one(); +} + #if HAVE_COMPRESSION static bool check_compressed(uint64_t compress_threshold, uint64_t data_size) { _cleanup_(mmap_cache_unrefp) MMapCache *m = NULL; @@ -222,7 +238,7 @@ static bool check_compressed(uint64_t compress_threshold, uint64_t data_size) { return is_compressed; } -TEST(min_compress_size) { +static void test_min_compress_size_one(void) { /* Note that XZ will actually fail to compress anything under 80 bytes, so you have to choose the limits * carefully */ @@ -241,6 +257,14 @@ TEST(min_compress_size) { assert_se(check_compressed(256, 256)); assert_se(!check_compressed(256, 255)); } + +TEST(min_compress_size) { + assert_se(setenv("SYSTEMD_JOURNAL_COMPACT", "0", 1) >= 0); + test_min_compress_size_one(); + + assert_se(setenv("SYSTEMD_JOURNAL_COMPACT", "1", 1) >= 0); + test_min_compress_size_one(); +} #endif static int intro(void) { |