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.
26 #include <logconfig.h>
27 #include <loglimiter.h>
29 void __log_limiter_update(const struct log_config *config) { }
30 void __log_limiter_destroy(void) { }
31 void __dynamic_config_destroy() { }
33 static bool destroyed;
39 int wtl_android(log_id_t buf_id, log_priority pri, const char *tag, const char *msg, struct timespec *tp_mono) { return 45835705; }
40 int wtl_pipe(log_id_t buf_id, log_priority pri, const char *tag, const char *msg, struct timespec *tp_mono) { return 0xDECC16; }
42 void __dlog_init_pipe(const struct log_config *conf) { write_to_log = wtl_pipe; }
43 void __dlog_init_android(const struct log_config *conf)
45 write_to_log = wtl_android;
46 destroy_backend = destroy;
49 static struct log_config CONFIG;
50 static bool fail_conf_read;
51 static bool conf_read_called;
52 int __wrap_log_config_read(struct log_config *config)
54 conf_read_called = true;
55 config->begin = config->last = NULL;
60 log_config_copy(config, &CONFIG);
64 struct pass_log_result limiter_ret;
65 struct pass_log_result __log_limiter_pass_log(const char *tag, int prio) { return limiter_ret; }
67 static bool limiter_created;
68 int __log_limiter_create(const struct log_config *config)
70 limiter_created = true;
74 static bool use_dynamic_conf;
75 bool __dynamic_config_create(struct log_config *config) { return use_dynamic_conf; }
77 static bool dynamic_config_called;
78 void __dynamic_config_update() { dynamic_config_called = true; }
81 int __wrap_snprintf(char *str, size_t size, const char *format, ...)
83 if (fail_snprintf && !strcmp(format, "enable_%s")) {
84 errno = -ENAMETOOLONG;
90 const int ret = vsnprintf(str, size, format, va);
95 int dlog_vprint_wrap_va_list(log_priority pri, const char *tag, const char *msg, ...)
100 const int ret = dlog_vprint(pri, tag, msg, ap);
108 /* These are a copy of TCT tests:
109 * repository: test/tct/native/api on tizen.org
110 * commit: aa0758c84abc5a10f60df68f4f86efe7dc1216c6, 2019-01-21
112 * Most of the TCT code for DLog is boilerplate setting up the
113 * framework and such. Since that is quite worthless, this file
114 * only copies the meritum. In particular, there are multiple
115 * calls to dlog_print for reporting test results in the TCT;
116 * it is important to keep this in mind when comparing how much
117 * dlog_print seems to get called in TCT code vs the handful of
118 * lines present in this file, since actual test cases consist
119 * of just the latter.
121 * The other checks earlier in this file should already catch
122 * everything the TCT tests do but it's good to work with the
123 * exact params used in the TCT tests to handle any edge cases
124 * that might appear and, more importantly, to have this done
125 * at build time since the actual TCT suite is a total hassle
126 * to work with, especially given its simplicity.
128 * Note that we still use the emulated functions since the real
129 * TCT test is done on a live system; the build environment has
130 * nowhere to actually send the logs and the tests only really
131 * check for parameter correctness. */
133 // src/itc/dlog/ITs-dlog.c : ITc_dlog_dlog_print_p
134 assert(dlog_print(DLOG_DEBUG, "DLOG_TEST", "[Dlog_ITC] Dlog Test Message\n") >= 0);
135 assert(dlog_print(DLOG_INFO , "DLOG_TEST", "[Dlog_ITC] Dlog Test Message\n") >= 0);
136 assert(dlog_print(DLOG_WARN , "DLOG_TEST", "[Dlog_ITC] Dlog Test Message\n") >= 0);
137 assert(dlog_print(DLOG_ERROR, "DLOG_TEST", "[Dlog_ITC] Dlog Test Message\n") >= 0);
139 // src/itc/dlog/ITs-dlog.c : ITc_dlog_dlog_vprint_p
140 assert(dlog_vprint_wrap_va_list(DLOG_DEBUG, "DLOG_TEST", "[Dlog_ITC] Dlog Test Message\n") >= 0);
141 assert(dlog_vprint_wrap_va_list(DLOG_INFO , "DLOG_TEST", "[Dlog_ITC] Dlog Test Message\n") >= 0);
142 assert(dlog_vprint_wrap_va_list(DLOG_WARN , "DLOG_TEST", "[Dlog_ITC] Dlog Test Message\n") >= 0);
143 assert(dlog_vprint_wrap_va_list(DLOG_ERROR, "DLOG_TEST", "[Dlog_ITC] Dlog Test Message\n") >= 0);
145 // src/utc/dlog/utc-SystemFW-dlog-print-func.c
146 assert(dlog_print(DLOG_INFO, "DLOG_TEST", "dlog test message for tct-mgr\n") > 0);
147 assert(dlog_print(-1, NULL, NULL) < 1);
149 // src/utc/dlog/utc-SystemFW-dlog-vprint-func.c
150 assert(dlog_vprint_wrap_va_list(DLOG_INFO, "DLOG_TEST", "dlog test message for tct-mgr\n") > 0);
151 assert(dlog_vprint_wrap_va_list(-1, NULL, NULL) < 1);