]> git.proxmox.com Git - systemd.git/blame - src/journal/test-journal-init.c
Imported Upstream version 220
[systemd.git] / src / journal / test-journal-init.c
CommitLineData
14228c0d
MB
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3/***
4 This file is part of systemd.
5
6 Copyright 2013 Zbigniew Jędrzejewski-Szmek
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20***/
21
5eef597e 22#include "systemd/sd-journal.h"
14228c0d
MB
23
24#include "log.h"
25#include "util.h"
e3bff60a 26#include "rm-rf.h"
14228c0d
MB
27
28int 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
5eef597e
MP
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
14228c0d
MB
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
e3bff60a 62 assert_se(rm_rf(t, REMOVE_ROOT|REMOVE_PHYSICAL) >= 0);
14228c0d
MB
63
64 return 0;
65}