]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
3b6c7e78 ZJS |
2 | /*** |
3 | This file is part of systemd. | |
4 | ||
5 | Copyright 2013 Zbigniew Jędrzejewski-Szmek | |
6 | ||
7 | systemd is free software; you can redistribute it and/or modify it | |
8 | under the terms of the GNU Lesser General Public License as published by | |
9 | the Free Software Foundation; either version 2.1 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | systemd is distributed in the hope that it will be useful, but | |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | Lesser General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU Lesser General Public License | |
18 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
19 | ***/ | |
20 | ||
3ffd4af2 | 21 | #include "sd-journal.h" |
3b6c7e78 ZJS |
22 | |
23 | #include "log.h" | |
6bedfcbb | 24 | #include "parse-util.h" |
c6878637 | 25 | #include "rm-rf.h" |
3ffd4af2 | 26 | #include "util.h" |
3b6c7e78 ZJS |
27 | |
28 | int main(int argc, char *argv[]) { | |
29 | sd_journal *j; | |
30 | int r, i, I = 100; | |
31 | char t[] = "/tmp/journal-stream-XXXXXX"; | |
32 | ||
33 | log_set_max_level(LOG_DEBUG); | |
34 | ||
cbb452e7 TA |
35 | if (argc >= 2) { |
36 | r = safe_atoi(argv[1], &I); | |
37 | if (r < 0) | |
38 | log_info("Could not parse loop count argument. Using default."); | |
39 | } | |
40 | ||
3b6c7e78 ZJS |
41 | log_info("Running %d loops", I); |
42 | ||
43 | assert_se(mkdtemp(t)); | |
44 | ||
45 | for (i = 0; i < I; i++) { | |
46 | r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY); | |
47 | assert_se(r == 0); | |
48 | ||
49 | sd_journal_close(j); | |
50 | ||
51 | r = sd_journal_open_directory(&j, t, 0); | |
52 | assert_se(r == 0); | |
53 | ||
54 | sd_journal_close(j); | |
55 | ||
56 | j = NULL; | |
57 | r = sd_journal_open_directory(&j, t, SD_JOURNAL_LOCAL_ONLY); | |
58 | assert_se(r == -EINVAL); | |
59 | assert_se(j == NULL); | |
60 | } | |
61 | ||
c6878637 | 62 | assert_se(rm_rf(t, REMOVE_ROOT|REMOVE_PHYSICAL) >= 0); |
3b6c7e78 ZJS |
63 | |
64 | return 0; | |
65 | } |