i = 0;
SD_JOURNAL_FOREACH(j) {
const void *d;
- char *k;
+ char *k, *c;
size_t l;
unsigned u;
}
free(k);
+
+ assert_se(sd_journal_get_cursor(j, &c) >= 0);
+ assert_se(sd_journal_test_cursor(j, c) > 0);
+ free(c);
}
if (skip > 0)
JournalFile *one, *two, *three;
char t[] = "/tmp/journal-stream-XXXXXX";
unsigned i;
- sd_journal *j;
+ _cleanup_journal_close_ sd_journal*j = NULL;
char *z;
+ const void *data;
+ size_t l;
log_set_max_level(LOG_DEBUG);
assert_se(mkdtemp(t));
assert_se(chdir(t) >= 0);
- assert_se(journal_file_open("one.journal", O_RDWR|O_CREAT, 0666, NULL, &one) == 0);
- assert_se(journal_file_open("two.journal", O_RDWR|O_CREAT, 0666, NULL, &two) == 0);
- assert_se(journal_file_open("three.journal", O_RDWR|O_CREAT, 0666, NULL, &three) == 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);
for (i = 0; i < N_ENTRIES; i++) {
char *p, *q;
assert_se(sd_journal_add_match(j, "MAGIC=quux", 0) >= 0);
SD_JOURNAL_FOREACH_BACKWARDS(j) {
- const void *d;
- size_t l;
+ _cleanup_free_ char *c;
- assert_se(sd_journal_get_data(j, "NUMBER", &d, &l) >= 0);
- printf("\t%.*s\n", (int) l, (const char*) d);
+ assert_se(sd_journal_get_data(j, "NUMBER", &data, &l) >= 0);
+ printf("\t%.*s\n", (int) l, (const char*) data);
+
+ assert_se(sd_journal_get_cursor(j, &c) >= 0);
+ assert_se(sd_journal_test_cursor(j, c) > 0);
}
SD_JOURNAL_FOREACH(j) {
- const void *d;
- size_t l;
+ _cleanup_free_ char *c;
- assert_se(sd_journal_get_data(j, "NUMBER", &d, &l) >= 0);
- printf("\t%.*s\n", (int) l, (const char*) d);
+ assert_se(sd_journal_get_data(j, "NUMBER", &data, &l) >= 0);
+ printf("\t%.*s\n", (int) l, (const char*) data);
+
+ assert_se(sd_journal_get_cursor(j, &c) >= 0);
+ assert_se(sd_journal_test_cursor(j, c) > 0);
}
sd_journal_flush_matches(j);
verify_contents(j, 0);
- sd_journal_close(j);
+ assert_se(sd_journal_query_unique(j, "NUMBER") >= 0);
+ SD_JOURNAL_FOREACH_UNIQUE(j, data, l)
+ printf("%.*s\n", (int) l, (const char*) data);
- assert_se(rm_rf(t, false, true, false) >= 0);
+ assert_se(rm_rf_dangerous(t, false, true, false) >= 0);
return 0;
}