]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
3b6c7e78 | 2 | |
3ffd4af2 | 3 | #include "sd-journal.h" |
3b6c7e78 | 4 | |
949082ac | 5 | #include "chattr-util.h" |
3b6c7e78 | 6 | #include "log.h" |
6bedfcbb | 7 | #include "parse-util.h" |
c6878637 | 8 | #include "rm-rf.h" |
6d7c4033 | 9 | #include "tests.h" |
3ffd4af2 | 10 | #include "util.h" |
3b6c7e78 ZJS |
11 | |
12 | int main(int argc, char *argv[]) { | |
13 | sd_journal *j; | |
14 | int r, i, I = 100; | |
949082ac | 15 | char t[] = "/var/tmp/journal-stream-XXXXXX"; |
3b6c7e78 | 16 | |
6d7c4033 | 17 | test_setup_logging(LOG_DEBUG); |
3b6c7e78 | 18 | |
cbb452e7 TA |
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 | ||
3b6c7e78 ZJS |
25 | log_info("Running %d loops", I); |
26 | ||
27 | assert_se(mkdtemp(t)); | |
949082ac | 28 | (void) chattr_path(t, FS_NOCOW_FL, FS_NOCOW_FL, NULL); |
3b6c7e78 ZJS |
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 | ||
c6878637 | 47 | assert_se(rm_rf(t, REMOVE_ROOT|REMOVE_PHYSICAL) >= 0); |
3b6c7e78 ZJS |
48 | |
49 | return 0; | |
50 | } |