Replace () with (void) in function prototypes
[platform/core/system/dlog.git] / src / tests / queued_entry_neg.c
1 /*
2  * Copyright (c) 2018-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 // C
18 #include <assert.h>
19 #include <stddef.h>
20
21 // POSIX
22 #include <time.h>
23
24 // DLog
25 #include <logcommon.h>
26 #include <logconfig.h>
27 #include <queued_entry.h>
28 #include <queued_entry_timestamp.h>
29
30 int main(void)
31 {
32         struct log_config conf = {NULL, NULL};
33         const struct {
34                 const char *const str;
35                 dlogutil_sorting_order_e order;
36         } ordering = {
37                 "x_invalid", DLOGUTIL_SORT_RECV_MONO
38         };
39
40         log_config_set(&conf, "sort_by", ordering.str);
41         assert(get_order_from_config(&conf) == ordering.order);
42
43         struct timespec ts;
44         dlogutil_entry_s le = {
45                  .sec_sent_mono = 1,
46                 .nsec_sent_mono = 2,
47                  .sec_sent_real = 3,
48                 .nsec_sent_real = 4,
49                  .sec_recv_mono = 5,
50                 .nsec_recv_mono = 6,
51                  .sec_recv_real = 7,
52                 .nsec_recv_real = 8,
53         };
54
55         assert(dlogutil_entry_get_timestamp(NULL, DLOGUTIL_SORT_RECV_MONO, &ts) == TIZEN_ERROR_INVALID_PARAMETER);
56         assert(dlogutil_entry_get_timestamp(&le, DLOGUTIL_SORT_RECV_MONO, NULL) == TIZEN_ERROR_INVALID_PARAMETER);
57
58         // invalid entries always compare false (kinda like NaN floats)
59         const dlogutil_entry_s invalid_1 = { .nsec_sent_mono = -1 };
60         const dlogutil_entry_s invalid_2 = { .nsec_sent_mono = -1 };
61         const dlogutil_entry_s valid = { .sec_sent_mono = -555, .nsec_sent_mono = 123 };
62         assert(!log_entry_is_earlier(DLOGUTIL_SORT_SENT_MONO, &invalid_1, &invalid_2));
63         assert(!log_entry_is_earlier(DLOGUTIL_SORT_SENT_MONO, &invalid_2, &invalid_1));
64         assert(!log_entry_is_earlier(DLOGUTIL_SORT_SENT_MONO, &valid, &invalid_1));
65         assert(!log_entry_is_earlier(DLOGUTIL_SORT_SENT_MONO, &invalid_1, &valid));
66
67         assert(dlogutil_entry_get_tid(&le, &(pid_t){ 0 }) == TIZEN_ERROR_NO_DATA);
68         assert(dlogutil_entry_get_pid(&le, &(pid_t){ 0 }) == TIZEN_ERROR_NO_DATA);
69 }