~ubuntu-branches/ubuntu/trusty/systemd/trusty

« back to all changes in this revision

Viewing changes to src/journal/test-journal-match.c

Tags: upstream-202
ImportĀ upstreamĀ versionĀ 202

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "log.h"
29
29
 
30
30
int main(int argc, char *argv[]) {
31
 
        sd_journal *j;
32
 
        char *t;
 
31
        _cleanup_journal_close_ sd_journal*j;
 
32
        _cleanup_free_ char *t;
33
33
 
34
34
        log_set_max_level(LOG_DEBUG);
35
35
 
54
54
        assert_se(sd_journal_add_match(j, "ONE=two", 0) >= 0);
55
55
        assert_se(sd_journal_add_match(j, "TWO=two", 0) >= 0);
56
56
 
 
57
        assert_se(sd_journal_add_conjunction(j) >= 0);
 
58
 
 
59
        assert_se(sd_journal_add_match(j, "L4_1=yes", 0) >= 0);
 
60
        assert_se(sd_journal_add_match(j, "L4_1=ok", 0) >= 0);
 
61
        assert_se(sd_journal_add_match(j, "L4_2=yes", 0) >= 0);
 
62
        assert_se(sd_journal_add_match(j, "L4_2=ok", 0) >= 0);
 
63
 
 
64
        assert_se(sd_journal_add_disjunction(j) >= 0);
 
65
 
 
66
        assert_se(sd_journal_add_match(j, "L3=yes", 0) >= 0);
 
67
        assert_se(sd_journal_add_match(j, "L3=ok", 0) >= 0);
 
68
 
57
69
        assert_se(t = journal_make_match_string(j));
58
70
 
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
71
        printf("resulting match expression is: %s\n", t);
62
 
        free(t);
63
72
 
64
 
        sd_journal_close(j);
 
73
        assert_se(streq(t, "(((L3=ok OR L3=yes) OR ((L4_2=ok OR L4_2=yes) AND (L4_1=ok OR L4_1=yes))) AND ((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))))"));
65
74
 
66
75
        return 0;
67
76
}