]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-journal: move tests to /var/tmp/ and set FS_NOCOW_FL v242-rc3
authorLennart Poettering <lennart@poettering.net>
Thu, 4 Apr 2019 08:04:26 +0000 (10:04 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 4 Apr 2019 10:18:13 +0000 (12:18 +0200)
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
src/journal/test-journal-flush.c
src/journal/test-journal-init.c
src/journal/test-journal-interleaving.c
src/journal/test-journal-stream.c
src/journal/test-journal-verify.c
src/journal/test-journal.c

index 566674d6b0698670195ed0c2bf2c87e4904250c1..de9d23a003cb359d2308636809cce4b8e45d9276 100644 (file)
@@ -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);
index 860baca38388e0b0e50cda82b3e2b63d62331dcd..d10e61080d23051b1a7c8409ab089bfb513d234a 100644 (file)
@@ -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);
index cf0561df619f55420460fc44ec1e52469b16eac2..449ac8ea1fa6fe612f1667f63e9996df65386baf 100644 (file)
@@ -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);
index 226c30f80a3914677918e9e71589da1f794bce6a..6d97bc5ce8aa6f656c434efdc903d8a4f7bf14ff 100644 (file)
@@ -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);
index c4fa41e07682360fc877b7c4fcaa03c712639dcd..2893a7c00fe9c63c8b66b79fcaceff3cb87bcd0d 100644 (file)
@@ -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...");
 
index 0795e0da0a82503b19f7f81eb3dc500c59c54c0d..7f56668af9541a5badf8bc937efaaf14631e9480 100644 (file)
@@ -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"
 
 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);