]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/test-journal-syslog.c
0697c46afba106506bd2b1fc111af4967ee0071e
[thirdparty/systemd.git] / src / journal / test-journal-syslog.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 /***
3 This file is part of systemd.
4
5 Copyright 2011 Lennart Poettering
6 ***/
7
8 #include "alloc-util.h"
9 #include "journald-syslog.h"
10 #include "macro.h"
11 #include "string-util.h"
12
13 static void test_syslog_parse_identifier(const char* str,
14 const char *ident, const char*pid, int ret) {
15 const char *buf = str;
16 _cleanup_free_ char *ident2 = NULL, *pid2 = NULL;
17 int ret2;
18
19 ret2 = syslog_parse_identifier(&buf, &ident2, &pid2);
20
21 assert_se(ret == ret2);
22 assert_se(ident == ident2 || streq_ptr(ident, ident2));
23 assert_se(pid == pid2 || streq_ptr(pid, pid2));
24 }
25
26 int main(void) {
27 test_syslog_parse_identifier("pidu[111]: xxx", "pidu", "111", 11);
28 test_syslog_parse_identifier("pidu: xxx", "pidu", NULL, 6);
29 test_syslog_parse_identifier("pidu xxx", NULL, NULL, 0);
30
31 return 0;
32 }