2 * Copyright (c) 2018-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.
25 #include <logcommon.h>
26 #include <logconfig.h>
27 #include <queued_entry.h>
28 #include <queued_entry_timestamp.h>
32 struct log_config conf = {NULL, NULL};
34 const char *const str;
35 dlogutil_sorting_order_e order;
37 "x_invalid", DLOGUTIL_SORT_RECV_MONO
40 log_config_set(&conf, "sort_by", ordering.str);
41 assert(get_order_from_config(&conf) == ordering.order);
44 dlogutil_entry_s le = {
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);
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));
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);