diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-04-04 10:04:26 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-04-04 12:18:13 +0200 |
commit | 949082ac214409365c01781fbf18ba08593918ff (patch) | |
tree | 14dbae36cfd7ce8c7f281496aab0bad97bbf9d68 | |
parent | 6e79d2b5a414f49c05392cf5f52072c5f081442e (diff) | |
download | systemd-949082ac214409365c01781fbf18ba08593918ff.tar.gz |
test-journal: move tests to /var/tmp/ and set FS_NOCOW_FLv242-rc3
The journal files might not be tiny hence let's write them to /var/tmp/
instead of /tmp. Also, let's turn on NOCOW on the files, as these tests
might apparently be slow on btrfs.
Fixes: #12210
-rw-r--r-- | src/journal/test-journal-flush.c | 3 | ||||
-rw-r--r-- | src/journal/test-journal-init.c | 4 | ||||
-rw-r--r-- | src/journal/test-journal-interleaving.c | 20 | ||||
-rw-r--r-- | src/journal/test-journal-stream.c | 4 | ||||
-rw-r--r-- | src/journal/test-journal-verify.c | 4 | ||||
-rw-r--r-- | src/journal/test-journal.c | 25 |
6 files changed, 42 insertions, 18 deletions
diff --git a/src/journal/test-journal-flush.c b/src/journal/test-journal-flush.c index 566674d6b0..de9d23a003 100644 --- a/src/journal/test-journal-flush.c +++ b/src/journal/test-journal-flush.c @@ -6,6 +6,7 @@ #include "sd-journal.h" #include "alloc-util.h" +#include "chattr-util.h" #include "journal-file.h" #include "journal-internal.h" #include "macro.h" @@ -20,6 +21,8 @@ int main(int argc, char *argv[]) { int r; assert_se(mkdtemp(dn)); + (void) chattr_path(dn, FS_NOCOW_FL, FS_NOCOW_FL, NULL); + fn = strappend(dn, "/test.journal"); r = journal_file_open(-1, fn, O_CREAT|O_RDWR, 0644, false, 0, false, NULL, NULL, NULL, NULL, &new_journal); diff --git a/src/journal/test-journal-init.c b/src/journal/test-journal-init.c index 860baca383..d10e61080d 100644 --- a/src/journal/test-journal-init.c +++ b/src/journal/test-journal-init.c @@ -2,6 +2,7 @@ #include "sd-journal.h" +#include "chattr-util.h" #include "log.h" #include "parse-util.h" #include "rm-rf.h" @@ -11,7 +12,7 @@ int main(int argc, char *argv[]) { sd_journal *j; int r, i, I = 100; - char t[] = "/tmp/journal-stream-XXXXXX"; + char t[] = "/var/tmp/journal-stream-XXXXXX"; test_setup_logging(LOG_DEBUG); @@ -24,6 +25,7 @@ int main(int argc, char *argv[]) { log_info("Running %d loops", I); assert_se(mkdtemp(t)); + (void) chattr_path(t, FS_NOCOW_FL, FS_NOCOW_FL, NULL); for (i = 0; i < I; i++) { r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY); diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c index cf0561df61..449ac8ea1f 100644 --- a/src/journal/test-journal-interleaving.c +++ b/src/journal/test-journal-interleaving.c @@ -6,6 +6,7 @@ #include "sd-journal.h" #include "alloc-util.h" +#include "chattr-util.h" #include "io-util.h" #include "journal-file.h" #include "journal-vacuum.h" @@ -130,13 +131,21 @@ static void setup_interleaved(void) { test_close(two); } +static void mkdtemp_chdir_chattr(char *path) { + assert_se(mkdtemp(path)); + assert_se(chdir(path) >= 0); + + /* Speed up things a bit on btrfs, ensuring that CoW is turned off for all files created in our + * directory during the test run */ + (void) chattr_path(path, FS_NOCOW_FL, FS_NOCOW_FL, NULL); +} + static void test_skip(void (*setup)(void)) { - char t[] = "/tmp/journal-skip-XXXXXX"; + char t[] = "/var/tmp/journal-skip-XXXXXX"; sd_journal *j; int r; - assert_se(mkdtemp(t)); - assert_se(chdir(t) >= 0); + mkdtemp_chdir_chattr(t); setup(); @@ -189,13 +198,12 @@ static void test_skip(void (*setup)(void)) { static void test_sequence_numbers(void) { - char t[] = "/tmp/journal-seq-XXXXXX"; + char t[] = "/var/tmp/journal-seq-XXXXXX"; JournalFile *one, *two; uint64_t seqnum = 0; sd_id128_t seqnum_id; - assert_se(mkdtemp(t)); - assert_se(chdir(t) >= 0); + mkdtemp_chdir_chattr(t); assert_se(journal_file_open(-1, "one.journal", O_RDWR|O_CREAT, 0644, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &one) == 0); diff --git a/src/journal/test-journal-stream.c b/src/journal/test-journal-stream.c index 226c30f80a..6d97bc5ce8 100644 --- a/src/journal/test-journal-stream.c +++ b/src/journal/test-journal-stream.c @@ -6,6 +6,7 @@ #include "sd-journal.h" #include "alloc-util.h" +#include "chattr-util.h" #include "journal-file.h" #include "journal-internal.h" #include "log.h" @@ -59,7 +60,7 @@ static void verify_contents(sd_journal *j, unsigned skip) { int main(int argc, char *argv[]) { JournalFile *one, *two, *three; - char t[] = "/tmp/journal-stream-XXXXXX"; + char t[] = "/var/tmp/journal-stream-XXXXXX"; unsigned i; _cleanup_(sd_journal_closep) sd_journal *j = NULL; char *z; @@ -75,6 +76,7 @@ int main(int argc, char *argv[]) { assert_se(mkdtemp(t)); assert_se(chdir(t) >= 0); + (void) chattr_path(t, FS_NOCOW_FL, FS_NOCOW_FL, NULL); assert_se(journal_file_open(-1, "one.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &one) == 0); assert_se(journal_file_open(-1, "two.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &two) == 0); diff --git a/src/journal/test-journal-verify.c b/src/journal/test-journal-verify.c index c4fa41e076..2893a7c00f 100644 --- a/src/journal/test-journal-verify.c +++ b/src/journal/test-journal-verify.c @@ -4,6 +4,7 @@ #include <stdio.h> #include <unistd.h> +#include "chattr-util.h" #include "fd-util.h" #include "io-util.h" #include "journal-file.h" @@ -51,7 +52,7 @@ static int raw_verify(const char *fn, const char *verification_key) { } int main(int argc, char *argv[]) { - char t[] = "/tmp/journal-XXXXXX"; + char t[] = "/var/tmp/journal-XXXXXX"; unsigned n; JournalFile *f; const char *verification_key = argv[1]; @@ -70,6 +71,7 @@ int main(int argc, char *argv[]) { assert_se(mkdtemp(t)); assert_se(chdir(t) >= 0); + (void) chattr_path(t, FS_NOCOW_FL, FS_NOCOW_FL, NULL); log_info("Generating..."); diff --git a/src/journal/test-journal.c b/src/journal/test-journal.c index 0795e0da0a..7f56668af9 100644 --- a/src/journal/test-journal.c +++ b/src/journal/test-journal.c @@ -3,6 +3,7 @@ #include <fcntl.h> #include <unistd.h> +#include "chattr-util.h" #include "io-util.h" #include "journal-authenticate.h" #include "journal-file.h" @@ -13,6 +14,15 @@ static bool arg_keep = false; +static void mkdtemp_chdir_chattr(char *path) { + assert_se(mkdtemp(path)); + assert_se(chdir(path) >= 0); + + /* Speed up things a bit on btrfs, ensuring that CoW is turned off for all files created in our + * directory during the test run */ + (void) chattr_path(path, FS_NOCOW_FL, FS_NOCOW_FL, NULL); +} + static void test_non_empty(void) { dual_timestamp ts; JournalFile *f; @@ -21,12 +31,11 @@ static void test_non_empty(void) { Object *o; uint64_t p; sd_id128_t fake_boot_id; - char t[] = "/tmp/journal-XXXXXX"; + char t[] = "/var/tmp/journal-XXXXXX"; test_setup_logging(LOG_DEBUG); - assert_se(mkdtemp(t)); - assert_se(chdir(t) >= 0); + mkdtemp_chdir_chattr(t); assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, true, NULL, NULL, NULL, NULL, &f) == 0); @@ -109,12 +118,11 @@ static void test_non_empty(void) { static void test_empty(void) { JournalFile *f1, *f2, *f3, *f4; - char t[] = "/tmp/journal-XXXXXX"; + char t[] = "/var/tmp/journal-XXXXXX"; test_setup_logging(LOG_DEBUG); - assert_se(mkdtemp(t)); - assert_se(chdir(t) >= 0); + mkdtemp_chdir_chattr(t); assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, false, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &f1) == 0); @@ -156,7 +164,7 @@ static bool check_compressed(uint64_t compress_threshold, uint64_t data_size) { struct iovec iovec; Object *o; uint64_t p; - char t[] = "/tmp/journal-XXXXXX"; + char t[] = "/var/tmp/journal-XXXXXX"; char data[2048] = {0}; bool is_compressed; int r; @@ -165,8 +173,7 @@ static bool check_compressed(uint64_t compress_threshold, uint64_t data_size) { test_setup_logging(LOG_DEBUG); - assert_se(mkdtemp(t)); - assert_se(chdir(t) >= 0); + mkdtemp_chdir_chattr(t); assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, compress_threshold, true, NULL, NULL, NULL, NULL, &f) == 0); |