]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/test-journal-syslog.c
0697c46afba106506bd2b1fc111af4967ee0071e
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 This file is part of systemd.
5 Copyright 2011 Lennart Poettering
8 #include "alloc-util.h"
9 #include "journald-syslog.h"
11 #include "string-util.h"
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
;
19 ret2
= syslog_parse_identifier(&buf
, &ident2
, &pid2
);
21 assert_se(ret
== ret2
);
22 assert_se(ident
== ident2
|| streq_ptr(ident
, ident2
));
23 assert_se(pid
== pid2
|| streq_ptr(pid
, pid2
));
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);