2 * Copyright (c) 2017-2020, Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <queued_entry.h>
26 dlogutil_entry_s * sle = alloca(1024);
29 len = snprintf(buffer, sizeof buffer, "<10>Jan 02 03:04:05 progname[678]: msg");
30 assert(!parse_syslog_datagram(buffer, len, sle));
32 assert(sle->pid == 678);
33 assert(sle->priority == DLOG_FATAL);
34 const char *tag, *msg;
35 assert(!dlogutil_entry_get_tag(sle, &tag));
36 assert(!dlogutil_entry_get_message(sle, &msg));
38 assert(msg); // Can never be triggered, but SVACE complains without this check
39 assert(!strcmp("SYSLOG_USER", tag));
40 assert(!strcmp("msg", msg));
43 len = snprintf(buffer, sizeof buffer, "<10>Jan 02 03:04:05 progname: msg");
44 assert(!parse_syslog_datagram(buffer, len, sle));
46 assert(sle->pid == 0);
47 assert(sle->priority == DLOG_FATAL);
48 assert(!dlogutil_entry_get_tag(sle, &tag));
49 assert(!dlogutil_entry_get_message(sle, &msg));
51 assert(msg); // Same as above
52 assert(!strcmp("SYSLOG_USER", tag));
53 assert(!strcmp("msg", msg));