]>
Commit | Line | Data |
---|---|---|
cbdca852 LP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2012 Lennart Poettering | |
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 | ||
22 | #include <stdio.h> | |
23 | ||
24 | #include <systemd/sd-journal.h> | |
25 | ||
26 | #include "journal-internal.h" | |
27 | #include "util.h" | |
28 | #include "log.h" | |
29 | ||
30 | int main(int argc, char *argv[]) { | |
763c7aa2 ZJS |
31 | sd_journal _cleanup_journal_close_ *j; |
32 | char _cleanup_free_ *t; | |
cbdca852 LP |
33 | |
34 | log_set_max_level(LOG_DEBUG); | |
35 | ||
36 | assert_se(sd_journal_open(&j, 0) >= 0); | |
37 | ||
38 | assert_se(sd_journal_add_match(j, "foobar", 0) < 0); | |
39 | assert_se(sd_journal_add_match(j, "foobar=waldo", 0) < 0); | |
40 | assert_se(sd_journal_add_match(j, "", 0) < 0); | |
41 | assert_se(sd_journal_add_match(j, "=", 0) < 0); | |
42 | assert_se(sd_journal_add_match(j, "=xxxxx", 0) < 0); | |
43 | assert_se(sd_journal_add_match(j, "HALLO=WALDO", 0) >= 0); | |
44 | assert_se(sd_journal_add_match(j, "QUUX=mmmm", 0) >= 0); | |
45 | assert_se(sd_journal_add_match(j, "QUUX=xxxxx", 0) >= 0); | |
46 | assert_se(sd_journal_add_match(j, "HALLO=", 0) >= 0); | |
47 | assert_se(sd_journal_add_match(j, "QUUX=xxxxx", 0) >= 0); | |
48 | assert_se(sd_journal_add_match(j, "QUUX=yyyyy", 0) >= 0); | |
49 | assert_se(sd_journal_add_match(j, "PIFF=paff", 0) >= 0); | |
50 | ||
51 | assert_se(sd_journal_add_disjunction(j) >= 0); | |
52 | ||
53 | assert_se(sd_journal_add_match(j, "ONE=one", 0) >= 0); | |
54 | assert_se(sd_journal_add_match(j, "ONE=two", 0) >= 0); | |
55 | assert_se(sd_journal_add_match(j, "TWO=two", 0) >= 0); | |
56 | ||
57 | assert_se(t = journal_make_match_string(j)); | |
58 | ||
59 | assert_se(streq(t, "((TWO=two AND (ONE=two OR ONE=one)) OR (PIFF=paff AND (QUUX=yyyyy OR QUUX=xxxxx OR QUUX=mmmm) AND (HALLO= OR HALLO=WALDO)))")); | |
60 | ||
61 | printf("resulting match expression is: %s\n", t); | |
cbdca852 LP |
62 | |
63 | return 0; | |
64 | } |