[systemd-devel] [PATCH 3/4] Update the tests

Goffredo Baroncelli kreijack at libero.it
Thu Mar 5 12:39:13 PST 2015


From: Goffredo Baroncelli <kreijack at inwind.it>

Update the tests due to the new interface journal_file_open() and
journal_file_open_reliably().

Signed-off-by: Goffredo Baroncelli <kreijack at inwind.it>
---
 src/journal/test-journal-flush.c        |  2 +-
 src/journal/test-journal-interleaving.c | 11 +++++++----
 src/journal/test-journal-stream.c       |  6 +++---
 src/journal/test-journal-verify.c       |  6 +++---
 src/journal/test-journal.c              | 17 +++++++++++------
 5 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/src/journal/test-journal-flush.c b/src/journal/test-journal-flush.c
index 914ca0b..6d5d4d1 100644
--- a/src/journal/test-journal-flush.c
+++ b/src/journal/test-journal-flush.c
@@ -37,7 +37,7 @@ int main(int argc, char *argv[]) {
         assert_se(mkdtemp(dn));
         fn = strappend(dn, "/test.journal");
 
-        r = journal_file_open(fn, O_CREAT|O_RDWR, 0644, false, false, NULL, NULL, NULL, &new_journal);
+        r = journal_file_open(fn, O_CREAT|O_RDWR, 0644, false, false, false, NULL, NULL, NULL, &new_journal);
         assert_se(r >= 0);
 
         r = sd_journal_open(&j, 0);
diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c
index 3c70601..e58d2b7 100644
--- a/src/journal/test-journal-interleaving.c
+++ b/src/journal/test-journal-interleaving.c
@@ -52,7 +52,7 @@ noreturn static void log_assert_errno(const char *text, int eno, const char *fil
 
 static JournalFile *test_open(const char *name) {
         JournalFile *f;
-        assert_ret(journal_file_open(name, O_RDWR|O_CREAT, 0644, true, false, NULL, NULL, NULL, &f));
+        assert_ret(journal_file_open(name, O_RDWR|O_CREAT, 0644, true, false, false, NULL, NULL, NULL, &f));
         return f;
 }
 
@@ -208,7 +208,8 @@ static void test_sequence_numbers(void) {
         assert_se(chdir(t) >= 0);
 
         assert_se(journal_file_open("one.journal", O_RDWR|O_CREAT, 0644,
-                                    true, false, NULL, NULL, NULL, &one) == 0);
+                                    true, false, false, NULL, NULL,
+                                    NULL, &one) == 0);
 
         append_number(one, 1, &seqnum);
         printf("seqnum=%"PRIu64"\n", seqnum);
@@ -225,7 +226,8 @@ static void test_sequence_numbers(void) {
         memcpy(&seqnum_id, &one->header->seqnum_id, sizeof(sd_id128_t));
 
         assert_se(journal_file_open("two.journal", O_RDWR|O_CREAT, 0644,
-                                    true, false, NULL, NULL, one, &two) == 0);
+                                    true, false, false, NULL, NULL,
+                                    one, &two) == 0);
 
         assert_se(two->header->state == STATE_ONLINE);
         assert_se(!sd_id128_equal(two->header->file_id, one->header->file_id));
@@ -256,7 +258,8 @@ static void test_sequence_numbers(void) {
         seqnum = 0;
 
         assert_se(journal_file_open("two.journal", O_RDWR, 0,
-                                    true, false, NULL, NULL, NULL, &two) == 0);
+                                    true, false, false, NULL, NULL,
+                                    NULL, &two) == 0);
 
         assert_se(sd_id128_equal(two->header->seqnum_id, seqnum_id));
 
diff --git a/src/journal/test-journal-stream.c b/src/journal/test-journal-stream.c
index 3996e77..3377480 100644
--- a/src/journal/test-journal-stream.c
+++ b/src/journal/test-journal-stream.c
@@ -90,9 +90,9 @@ int main(int argc, char *argv[]) {
         assert_se(mkdtemp(t));
         assert_se(chdir(t) >= 0);
 
-        assert_se(journal_file_open("one.journal", O_RDWR|O_CREAT, 0666, true, false, NULL, NULL, NULL, &one) == 0);
-        assert_se(journal_file_open("two.journal", O_RDWR|O_CREAT, 0666, true, false, NULL, NULL, NULL, &two) == 0);
-        assert_se(journal_file_open("three.journal", O_RDWR|O_CREAT, 0666, true, false, NULL, NULL, NULL, &three) == 0);
+        assert_se(journal_file_open("one.journal", O_RDWR|O_CREAT, 0666, true, false, false, NULL, NULL, NULL, &one) == 0);
+        assert_se(journal_file_open("two.journal", O_RDWR|O_CREAT, 0666, true, false, false, NULL, NULL, NULL, &two) == 0);
+        assert_se(journal_file_open("three.journal", O_RDWR|O_CREAT, 0666, true, false, false, NULL, NULL, NULL, &three) == 0);
 
         for (i = 0; i < N_ENTRIES; i++) {
                 char *p, *q;
diff --git a/src/journal/test-journal-verify.c b/src/journal/test-journal-verify.c
index 9da120c..71155e4 100644
--- a/src/journal/test-journal-verify.c
+++ b/src/journal/test-journal-verify.c
@@ -55,7 +55,7 @@ static int raw_verify(const char *fn, const char *verification_key) {
         JournalFile *f;
         int r;
 
-        r = journal_file_open(fn, O_RDONLY, 0666, true, !!verification_key, NULL, NULL, NULL, &f);
+        r = journal_file_open(fn, O_RDONLY, 0666, true, !!verification_key, false, NULL, NULL, NULL, &f);
         if (r < 0)
                 return r;
 
@@ -88,7 +88,7 @@ int main(int argc, char *argv[]) {
 
         log_info("Generating...");
 
-        assert_se(journal_file_open("test.journal", O_RDWR|O_CREAT, 0666, true, !!verification_key, NULL, NULL, NULL, &f) == 0);
+        assert_se(journal_file_open("test.journal", O_RDWR|O_CREAT, 0666, true, !!verification_key, false, NULL, NULL, NULL, &f) == 0);
 
         for (n = 0; n < N_ENTRIES; n++) {
                 struct iovec iovec;
@@ -111,7 +111,7 @@ int main(int argc, char *argv[]) {
 
         log_info("Verifying...");
 
-        assert_se(journal_file_open("test.journal", O_RDONLY, 0666, true, !!verification_key, NULL, NULL, NULL, &f) == 0);
+        assert_se(journal_file_open("test.journal", O_RDONLY, 0666, true, !!verification_key, false, NULL, NULL, NULL, &f) == 0);
         /* journal_file_print_header(f); */
         journal_file_dump(f);
 
diff --git a/src/journal/test-journal.c b/src/journal/test-journal.c
index 230d265..69098ce 100644
--- a/src/journal/test-journal.c
+++ b/src/journal/test-journal.c
@@ -45,7 +45,7 @@ static void test_non_empty(void) {
         assert_se(mkdtemp(t));
         assert_se(chdir(t) >= 0);
 
-        assert_se(journal_file_open("test.journal", O_RDWR|O_CREAT, 0666, true, true, NULL, NULL, NULL, &f) == 0);
+        assert_se(journal_file_open("test.journal", O_RDWR|O_CREAT, 0666, true, true, false, NULL, NULL, NULL, &f) == 0);
 
         dual_timestamp_get(&ts);
 
@@ -126,7 +126,7 @@ static void test_non_empty(void) {
 }
 
 static void test_empty(void) {
-        JournalFile *f1, *f2, *f3, *f4;
+        JournalFile *f1, *f2, *f3, *f4, *f5;
         char t[] = "/tmp/journal-XXXXXX";
 
         log_set_max_level(LOG_DEBUG);
@@ -134,13 +134,15 @@ static void test_empty(void) {
         assert_se(mkdtemp(t));
         assert_se(chdir(t) >= 0);
 
-        assert_se(journal_file_open("test.journal", O_RDWR|O_CREAT, 0666, false, false, NULL, NULL, NULL, &f1) == 0);
+        assert_se(journal_file_open("test.journal", O_RDWR|O_CREAT, 0666, false, false, false, NULL, NULL, NULL, &f1) == 0);
 
-        assert_se(journal_file_open("test-compress.journal", O_RDWR|O_CREAT, 0666, true, false, NULL, NULL, NULL, &f2) == 0);
+        assert_se(journal_file_open("test-compress.journal", O_RDWR|O_CREAT, 0666, true, false, false, NULL, NULL, NULL, &f2) == 0);
 
-        assert_se(journal_file_open("test-seal.journal", O_RDWR|O_CREAT, 0666, false, true, NULL, NULL, NULL, &f3) == 0);
+        assert_se(journal_file_open("test-seal.journal", O_RDWR|O_CREAT, 0666, false, true, false, NULL, NULL, NULL, &f3) == 0);
 
-        assert_se(journal_file_open("test-seal-compress.journal", O_RDWR|O_CREAT, 0666, true, true, NULL, NULL, NULL, &f4) == 0);
+        assert_se(journal_file_open("test-seal-compress.journal", O_RDWR|O_CREAT, 0666, true, true, false, NULL, NULL, NULL, &f4) == 0);
+
+        assert_se(journal_file_open("test-allow-cow-journal.journal", O_RDWR|O_CREAT, 0666, false, false, true, NULL, NULL, NULL, &f5) == 0);
 
         journal_file_print_header(f1);
         puts("");
@@ -150,6 +152,8 @@ static void test_empty(void) {
         puts("");
         journal_file_print_header(f4);
         puts("");
+        journal_file_print_header(f5);
+        puts("");
 
         log_info("Done...");
 
@@ -165,6 +169,7 @@ static void test_empty(void) {
         journal_file_close(f2);
         journal_file_close(f3);
         journal_file_close(f4);
+        journal_file_close(f5);
 }
 
 int main(int argc, char *argv[]) {
-- 
2.1.0



More information about the systemd-devel mailing list