summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-06-05 19:17:56 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-06-10 10:10:07 -0400
commit6eb7a9a0010d035e5bdbbf70227088ce02b2120e (patch)
tree559213d434e111774ef96de080acb4ff87f746f1
parented375bebf46c1251f4baa170b39ee93761dbdb19 (diff)
tests: add test for empty journal files
The headers are currently not printed properly: some "(null)"s appear.
-rw-r--r--TODO2
-rw-r--r--src/journal/test-journal.c60
2 files changed, 58 insertions, 4 deletions
diff --git a/TODO b/TODO
index fc8044b434..0dd19a05c2 100644
--- a/TODO
+++ b/TODO
@@ -11,6 +11,8 @@ Bugfixes:
* properly handle .mount unit state tracking when two mount points are stacked one on top of another on the exact same mount point.
+* fix --header to files without entries (see test-journal output).
+
Fedora 19:
* external: maybe it is time to patch procps so that "ps" links to
diff --git a/src/journal/test-journal.c b/src/journal/test-journal.c
index f4dc52cd81..534fd28fa6 100644
--- a/src/journal/test-journal.c
+++ b/src/journal/test-journal.c
@@ -29,7 +29,9 @@
#include "journal-authenticate.h"
#include "journal-vacuum.h"
-int main(int argc, char *argv[]) {
+static bool arg_keep = false;
+
+static void test_non_empty(void) {
dual_timestamp ts;
JournalFile *f;
struct iovec iovec;
@@ -119,11 +121,61 @@ int main(int argc, char *argv[]) {
journal_file_close(f);
- journal_directory_vacuum(".", 3000000, 0, 0, NULL);
+ log_info("Done...");
+
+ if (arg_keep)
+ log_info("Not removing %s", t);
+ else {
+ journal_directory_vacuum(".", 3000000, 0, 0, NULL);
+
+ assert_se(rm_rf_dangerous(t, false, true, false) >= 0);
+ }
+
+ puts("------------------------------------------------------------");
+}
+
+static void test_empty(void) {
+ JournalFile *f1, *f2, *f3, *f4;
+ char t[] = "/tmp/journal-XXXXXX";
+
+ log_set_max_level(LOG_DEBUG);
- log_error("Exiting...");
+ 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-compress.journal", O_RDWR|O_CREAT, 0666, true, 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-compress.journal", O_RDWR|O_CREAT, 0666, true, true, NULL, NULL, NULL, &f4) == 0);
+
+ journal_file_print_header(f1);
+ puts("");
+ journal_file_print_header(f2);
+ puts("");
+ journal_file_print_header(f3);
+ puts("");
+ journal_file_print_header(f4);
+ puts("");
+
+ log_info("Done...");
+
+ if (arg_keep)
+ log_info("Not removing %s", t);
+ else {
+ journal_directory_vacuum(".", 3000000, 0, 0, NULL);
+
+ assert_se(rm_rf_dangerous(t, false, true, false) >= 0);
+ }
+}
+
+int main(int argc, char *argv[]) {
+ arg_keep = argc > 1;
- assert_se(rm_rf_dangerous(t, false, true, false) >= 0);
+ test_non_empty();
+ test_empty();
return 0;
}