]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/test-journal-init.c
resolve: support port specifier in DNS= setting
[thirdparty/systemd.git] / src / journal / test-journal-init.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #include "sd-journal.h"
4
5 #include "chattr-util.h"
6 #include "log.h"
7 #include "parse-util.h"
8 #include "rm-rf.h"
9 #include "tests.h"
10 #include "util.h"
11
12 int main(int argc, char *argv[]) {
13 sd_journal *j;
14 int r, i, I = 100;
15 char t[] = "/var/tmp/journal-stream-XXXXXX";
16
17 test_setup_logging(LOG_DEBUG);
18
19 if (argc >= 2) {
20 r = safe_atoi(argv[1], &I);
21 if (r < 0)
22 log_info("Could not parse loop count argument. Using default.");
23 }
24
25 log_info("Running %d loops", I);
26
27 assert_se(mkdtemp(t));
28 (void) chattr_path(t, FS_NOCOW_FL, FS_NOCOW_FL, NULL);
29
30 for (i = 0; i < I; i++) {
31 r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY);
32 assert_se(r == 0);
33
34 sd_journal_close(j);
35
36 r = sd_journal_open_directory(&j, t, 0);
37 assert_se(r == 0);
38
39 sd_journal_close(j);
40
41 j = NULL;
42 r = sd_journal_open_directory(&j, t, SD_JOURNAL_LOCAL_ONLY);
43 assert_se(r == -EINVAL);
44 assert_se(j == NULL);
45 }
46
47 assert_se(rm_rf(t, REMOVE_ROOT|REMOVE_PHYSICAL) >= 0);
48
49 return 0;
50 }