Replace () with (void) in function prototypes
[platform/core/system/dlog.git] / src / tests / syslog_parser_pos.c
1 /*
2  * Copyright (c) 2017-2020, Samsung Electronics Co., Ltd. All rights reserved.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <logprint.h>
18 #include <queued_entry.h>
19 #include <stdio.h>
20 #include <assert.h>
21
22 int main(void)
23 {
24         char buffer[1024];
25         int len;
26         dlogutil_entry_s * sle = alloca(1024);
27
28         // Valid
29         len = snprintf(buffer, sizeof buffer, "<10>Jan 02 03:04:05 progname[678]: msg");
30         assert(!parse_syslog_datagram(buffer, len, sle));
31
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));
37         assert(tag);
38         assert(msg); // Can never be triggered, but SVACE complains without this check
39         assert(!strcmp("SYSLOG_USER", tag));
40         assert(!strcmp("msg", msg));
41
42         // Valid
43         len = snprintf(buffer, sizeof buffer, "<10>Jan 02 03:04:05 progname: msg");
44         assert(!parse_syslog_datagram(buffer, len, sle));
45
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));
50         assert(tag);
51         assert(msg); // Same as above
52         assert(!strcmp("SYSLOG_USER", tag));
53         assert(!strcmp("msg", msg));
54
55         return 0;
56 }