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 /src/journal/test-journal.c | |
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
Diffstat (limited to 'src/journal/test-journal.c')
-rw-r--r-- | src/journal/test-journal.c | 25 |
1 files changed, 16 insertions, 9 deletions
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); |