test_config_redirect_SOURCES = \
tests/test_config_redirect.c
-
check_PROGRAMS = \
src/tests/test_ptrs_list_foreach_pos \
src/tests/test_compression_common \
bin_SCRIPTS = dlog_test dlog_test_header dlog_cpu
+
+
+
coveragetestsdir = $(bindir)/tizen-unittests/dlog
coveragetests_SCRIPTS = run-unittest.sh
+coveragetests_PROGRAMS = test_capi_coverage test_libdlogutil_cov
+test_capi_coverage_CFLAGS = \
+ $(AM_CFLAGS) \
+ -fPIE
+test_capi_coverage_LDFLAGS = \
+ $(AM_LDFLAGS) \
+ -pie
+test_capi_coverage_DEPENDENCIES = \
+ libdlog.la \
+ libdlogutil.la \
+ libdlog_redirect_stdout.la
+test_capi_coverage_LDADD = \
+ libdlog.la \
+ libdlogutil.la \
+ libdlog_redirect_stdout.la
+test_capi_coverage_SOURCES = \
+ tests/test_capi_coverage.c
+
+# packaging won't let us have the same program in 2 packages
+test_libdlogutil_cov_CFLAGS = $(test_libdlogutil_CFLAGS)
+test_libdlogutil_cov_LDFLAGS = $(test_libdlogutil_LDFLAGS)
+test_libdlogutil_cov_DEPENDENCIES = $(test_libdlogutil_DEPENDENCIES)
+test_libdlogutil_cov_LDADD = $(test_libdlogutil_LDADD)
+test_libdlogutil_cov_SOURCES = $(test_libdlogutil_SOURCES)
+
+
+
docdir = $(datadir)/doc/dlog
doc_DATA = \
--- /dev/null
+/* MIT License
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE. */
+
+// dlog public API
+#include <dlog.h>
+#include <dlog-redirect-stdout.h>
+
+// dlog secret API
+#include <extra_sinks.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <limits.h>
+
+int dlog_vprint_native(log_priority prio, const char *tag, const char *fmt, va_list ap);
+int dlog_print_native(log_priority prio, const char *tag, const char *fmt, ...);
+int dlog_vprint_dotnet(log_priority prio, const char *tag, const char *fmt, va_list ap);
+int dlog_print_dotnet(log_priority prio, const char *tag, const char *fmt, ...);
+
+void va_stuff(log_priority prio, const char *tag, const char *fmt, ...)
+{
+ va_list va;
+ va_start(va, fmt);
+
+ va_list va_dotnet, va_native, va_vprint, va_iprint;
+ va_copy(va_native, va);
+ va_copy(va_dotnet, va);
+ va_copy(va_vprint, va);
+ va_copy(va_iprint, va);
+
+ dlog_vprint_native(prio, tag, fmt, va_native);
+ dlog_vprint_dotnet(prio, tag, fmt, va_dotnet);
+ dlog_vprint(prio, tag, fmt, va_vprint);
+ __dlog_vprint(LOG_ID_MAIN, prio, tag, fmt, va_iprint);
+
+ va_end(va);
+ va_end(va_native);
+ va_end(va_dotnet);
+ va_end(va_vprint);
+ va_end(va_iprint);
+}
+
+int main()
+{
+ dlog_connect_fd(LOG_ID_INVALID, 1, "x", DLOG_INFO);
+ dlog_connect_fd(SINK_DOTNET , 1, "x", DLOG_INFO);
+ dlog_connect_fd(LOG_ID_MAIN , -1, "x", DLOG_INFO);
+ dlog_connect_fd(LOG_ID_MAIN , 1, NULL, DLOG_INFO);
+ dlog_connect_fd(LOG_ID_MAIN , 1, "", DLOG_INFO);
+ dlog_connect_fd(LOG_ID_MAIN , 1, "x", -999);
+ dlog_connect_fd(LOG_ID_MAIN , 1, "x", +999);
+ dlog_connect_fd(LOG_ID_MAIN , 999, "x", DLOG_INFO);
+ dlog_connect_fd(LOG_ID_MAIN , INT_MAX, "x", DLOG_INFO);
+
+ dlog_connect_fd(LOG_ID_MAIN , STDOUT_FILENO, "x", DLOG_INFO);
+ dlog_connect_fd(LOG_ID_RADIO , STDOUT_FILENO, "x", DLOG_INFO);
+ dlog_connect_fd(LOG_ID_SYSTEM , STDOUT_FILENO, "x", DLOG_INFO);
+ dlog_connect_fd(LOG_ID_APPS , STDOUT_FILENO, "x", DLOG_INFO);
+ dlog_connect_fd(SINK_DOTNET , STDOUT_FILENO, "x", DLOG_INFO);
+ dlog_connect_fd(SINK_NATIVE , STDOUT_FILENO, "x", DLOG_INFO);
+ dlog_connect_fd(LOG_ID_MAIN , STDERR_FILENO, "x", DLOG_INFO);
+
+
+ int const fd_null = open("/dev/null" , O_RDONLY);
+ int const fd_logs = open("/dev/log_main", O_RDONLY);
+ int const fd_else = open("/dev/kmsg" , O_RDONLY);
+
+ dlog_is_log_fd( -1);
+ dlog_is_log_fd( 999);
+ dlog_is_log_fd(fd_null);
+ dlog_is_log_fd(fd_logs);
+ dlog_is_log_fd(fd_else);
+
+ close(fd_null);
+ close(fd_logs);
+ close(fd_else);
+
+
+ dlog_set_minimum_priority( -99);
+ dlog_set_minimum_priority( +99);
+ dlog_set_minimum_priority(DLOG_VERBOSE);
+
+ va_stuff(DLOG_ERROR, "x", "x");
+
+ dlog_print_native(DLOG_ERROR, "x", "x");
+ dlog_print_dotnet(DLOG_ERROR, "x", "x");
+
+ __dlog_print(LOG_ID_MAIN, DLOG_ERROR, "x", "x");
+ __dlog_sec_print(LOG_ID_MAIN, DLOG_ERROR, "x", "x");
+ __dlog_critical_print(LOG_ID_MAIN, DLOG_ERROR, "x", "x");
+ __dlog_print(LOG_ID_MAIN, DLOG_ERROR, "x", "x");
+}