test-journal-syslog.c revision a187bfd98ae7b651f7c464450895ead6bdf1ddd6
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering/***
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering This file is part of systemd.
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering Copyright 2011 Lennart Poettering
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering systemd is free software; you can redistribute it and/or modify it
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering under the terms of the GNU Lesser General Public License as published by
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering the Free Software Foundation; either version 2.1 of the License, or
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering (at your option) any later version.
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering systemd is distributed in the hope that it will be useful, but
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering Lesser General Public License for more details.
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering You should have received a copy of the GNU Lesser General Public License
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering***/
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering#include "journald-syslog.h"
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering#include "macro.h"
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering
aaf7eb81be912e7bed939f31e3bc4c631b2552b3Lennart Poetteringstatic void test_syslog_parse_identifier(const char* str,
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering const char *ident, const char*pid, int ret) {
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering const char *buf = str;
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering char _cleanup_free_ *ident2 = NULL, *pid2 = NULL;
aaf7eb81be912e7bed939f31e3bc4c631b2552b3Lennart Poettering int ret2;
6482f6269c87d2249e52e889a63adbdd50f2d691Ronny Chevalier
0b452006de98294d1690f045f6ea2f7f6630ec3bRonny Chevalier ret2 = syslog_parse_identifier(&buf, &ident2, &pid2);
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering
aaf7eb81be912e7bed939f31e3bc4c631b2552b3Lennart Poettering assert(ret == ret2);
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering assert(ident==ident2 || streq(ident, ident2));
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering assert(pid==pid2 || streq(pid, pid2));
31885cd5e38ec9807a6a7ab32660cf8c2fcf48f7Zbigniew Jędrzejewski-Szmek}
b68fa010f72599e6da5822feda5ae3a47a4e63d8Simon Peeters
b68fa010f72599e6da5822feda5ae3a47a4e63d8Simon Peetersint main(void) {
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering test_syslog_parse_identifier("pidu[111]: xxx", "pidu", "111", 11);
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering test_syslog_parse_identifier("pidu: xxx", "pidu", NULL, 6);
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering test_syslog_parse_identifier("pidu xxx", NULL, NULL, 0);
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering return 0;
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering}
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering