src/tests/sort_vector \
src/tests/fd_info_pos \
src/tests/fd_info_neg \
- src/tests/fdi_logger \
+ src/tests/fdi_logger_pos \
+ src/tests/fdi_logger_neg \
src/tests/fdi_pipe \
src/tests/libdlog_pipe \
src/tests/libdlog_android_pos \
src_tests_fd_info_neg_CFLAGS = $(check_CFLAGS)
src_tests_fd_info_neg_LDFLAGS = $(AM_LDFLAGS) -Wl,--wrap=sort_vector_push,--wrap=malloc,--wrap=free,--wrap=close,--wrap=dlogutil_entry_get_timestamp,--wrap=log_should_print_line
-src_tests_fdi_logger_SOURCES = src/tests/fdi_logger.c src/libdlogutil/fdi_logger.c src/shared/ptrs_list.c src/shared/logcommon.c
-src_tests_fdi_logger_CFLAGS = $(check_CFLAGS)
-src_tests_fdi_logger_LDFLAGS = $(AM_LDFLAGS) -Wl,--wrap=logger_open_buffer_from_config_get_path,--wrap=dlogutil_filter_options_set_filterspec,--wrap=parse_androidlogger_message,--wrap=copy_recv_timestamp,--wrap=malloc,--wrap=read,--wrap=close,--wrap=ioctl,--wrap=calloc
+src_tests_fdi_logger_pos_SOURCES = src/tests/fdi_logger_pos.c src/libdlogutil/fdi_logger.c src/shared/ptrs_list.c src/shared/logcommon.c
+src_tests_fdi_logger_pos_CFLAGS = $(check_CFLAGS)
+src_tests_fdi_logger_pos_LDFLAGS = $(AM_LDFLAGS) -Wl,--wrap=logger_open_buffer_from_config_get_path,--wrap=dlogutil_filter_options_set_filterspec,--wrap=parse_androidlogger_message,--wrap=copy_recv_timestamp,--wrap=malloc,--wrap=read,--wrap=close,--wrap=ioctl,--wrap=calloc
+
+src_tests_fdi_logger_neg_SOURCES = src/tests/fdi_logger_neg.c src/libdlogutil/fdi_logger.c src/shared/ptrs_list.c src/shared/logcommon.c
+src_tests_fdi_logger_neg_CFLAGS = $(check_CFLAGS)
+src_tests_fdi_logger_neg_LDFLAGS = $(AM_LDFLAGS) -Wl,--wrap=logger_open_buffer_from_config_get_path,--wrap=dlogutil_filter_options_set_filterspec,--wrap=parse_androidlogger_message,--wrap=copy_recv_timestamp,--wrap=malloc,--wrap=read,--wrap=close,--wrap=ioctl,--wrap=calloc
src_tests_fdi_pipe_SOURCES = src/tests/fdi_pipe.c src/libdlogutil/fdi_pipe.c src/shared/logconfig.c src/shared/ptrs_list.c src/shared/logprint.c src/shared/parsers.c src/shared/logcommon.c
src_tests_fdi_pipe_CFLAGS = $(check_CFLAGS)
--- /dev/null
+/*
+ * Copyright (c) 2019-2020, Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "fdi_logger_wrap.c"
+
+int main()
+{
+ struct fd_info fdi = {
+ .fd = -1,
+ .priv_data = NULL,
+ };
+ list_head used_paths = NULL;
+
+ ops_logger.destroy(&fdi);
+
+ fail_malloc = 1;
+ assert(-ENOMEM == ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
+
+ open_buf_ret = -536;
+ assert(-536 == ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
+ open_buf_ret = 0;
+ assert(-EINVAL == ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
+
+ open_buf_path = "abc";
+ open_buf_ret = 1;
+ fail_malloc = 2;
+ assert(-ENOMEM == ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
+ assert(fdi.fd < 0);
+ assert(!fdi.priv_data);
+
+ fail_calloc = true;
+ assert(-ENOMEM == ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
+ assert(fdi.fd < 0);
+ assert(!fdi.priv_data);
+ fail_calloc = false;
+
+ assert(!ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
+ ops_logger.destroy(&fdi);
+ fdi.fd = -1;
+
+ assert(-EALREADY == ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
+ assert(fdi.fd == -1);
+ assert(!fdi.priv_data);
+
+ open_buf_path = "def";
+ assert(!ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
+
+ expected_ioctl = LOGGER_FLUSH_LOG;
+ ioctl_ret = -77;
+ assert(-77 == ops_logger.clear(&fdi));
+
+ unsigned int sz;
+ expected_ioctl = LOGGER_GET_LOG_BUF_SIZE;
+ ioctl_ret = -EALREADY;
+ assert(-EALREADY == ops_logger.getsize(&fdi, &sz));
+
+ expected_ioctl = LOGGER_GET_LOG_LEN;
+ ioctl_ret = -67;
+ assert(-67 == ops_logger.prepare_print(&fdi, 123, false, (dlogutil_filter_options_s *) 0xCA5CADE));
+
+ expected_ioctl = -1;
+ assert(!ops_logger.prepare_print(&fdi, DLOGUTIL_MODE_CONTINUOUS, false, (dlogutil_filter_options_s *) 0xCA5CADE));
+
+ fail_read = true;
+ assert(-334 == ops_logger.read(&fdi));
+ fail_read = false;
+
+ for (size_t i = 0; i < NELEMS(READS) + 15; ++i) {
+ assert(!ops_logger.has_log(&fdi));
+ fail_read = true;
+ assert(NULL == ops_logger.extract_entry(&fdi));
+ assert(NULL == ops_logger.peek_entry(&fdi));
+ assert(NULL == ops_logger.extract_entry(&fdi));
+ fail_read = false;
+ fail_malloc = !(rand() % 4) * 3;
+ ops_logger.read(&fdi);
+ if (!fail_malloc && i < NELEMS(READS) && READS[i] > sizeof(struct android_logger_entry)) {
+ assert(ops_logger.has_log(&fdi));
+ assert(-EAGAIN == ops_logger.read(&fdi));
+ const dlogutil_entry_s *const le = ops_logger.peek_entry(&fdi);
+ assert(le);
+ assert(le == ops_logger.peek_entry(&fdi));
+ fail_read = true;
+ assert(le == ops_logger.extract_entry(&fdi));
+ fail_read = false;
+ free((dlogutil_entry_s *) le);
+ }
+ fail_malloc = 0;
+ assert(!ops_logger.has_log(&fdi));
+ assert(NULL == ops_logger.peek_entry(&fdi));
+ fail_read = true;
+ assert(NULL == ops_logger.extract_entry(&fdi));
+ fail_read = false;
+ }
+
+ ops_logger.destroy(&fdi);
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020, Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "fdi_logger_wrap.c"
+
+int main()
+{
+ struct fd_info fdi = {
+ .fd = -1,
+ .priv_data = NULL,
+ };
+ list_head used_paths = NULL;
+
+ open_buf_ret = 1;
+ assert(!ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
+ assert(fdi.fd == 0xFD);
+ assert(fdi.priv_data);
+
+ ops_logger.destroy(&fdi);
+ assert(!fdi.priv_data);
+
+ open_buf_path = "def";
+ assert(!ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
+
+ expected_ioctl = LOGGER_FLUSH_LOG;
+ ioctl_ret = 15;
+ assert(0 == ops_logger.clear(&fdi));
+
+ unsigned int sz;
+ expected_ioctl = LOGGER_GET_LOG_BUF_SIZE;
+ ioctl_ret = 2019;
+ assert(0 == ops_logger.getsize(&fdi, &sz));
+ assert(2019 == sz);
+
+ expected_ioctl = LOGGER_GET_LOG_LEN;
+ ioctl_ret = 0;
+ assert(1 == ops_logger.prepare_print(&fdi, 123, false, (dlogutil_filter_options_s *) 0xCA5CADE));
+
+ ops_logger.destroy(&fdi);
+}
+/*
+ * Copyright (c) 2019-2020, Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
// C
#include <assert.h>
return ioctl_ret;
}
-int main()
-{
- struct fd_info fdi = {
- .fd = -1,
- .priv_data = NULL,
- };
- list_head used_paths = NULL;
-
- ops_logger.destroy(&fdi);
-
- fail_malloc = 1;
- assert(-ENOMEM == ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
-
- open_buf_ret = -536;
- assert(-536 == ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
- open_buf_ret = 0;
- assert(-EINVAL == ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
-
- open_buf_path = "abc";
- open_buf_ret = 1;
- fail_malloc = 2;
- assert(-ENOMEM == ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
- assert(fdi.fd < 0);
- assert(!fdi.priv_data);
-
- fail_calloc = true;
- assert(-ENOMEM == ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
- assert(fdi.fd < 0);
- assert(!fdi.priv_data);
- fail_calloc = false;
-
- assert(!ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
- assert(fdi.fd == 0xFD);
- assert(fdi.priv_data);
-
- ops_logger.destroy(&fdi);
- assert(!fdi.priv_data);
- fdi.fd = -1;
-
- assert(-EALREADY == ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
- assert(fdi.fd == -1);
- assert(!fdi.priv_data);
-
- open_buf_path = "def";
- assert(!ops_logger.create(&fdi, (struct log_config *) 0xABDUL, "radio", &used_paths));
-
- expected_ioctl = LOGGER_FLUSH_LOG;
- ioctl_ret = -77;
- assert(-77 == ops_logger.clear(&fdi));
- ioctl_ret = 15;
- assert(0 == ops_logger.clear(&fdi));
-
- unsigned int sz;
- expected_ioctl = LOGGER_GET_LOG_BUF_SIZE;
- ioctl_ret = -EALREADY;
- assert(-EALREADY == ops_logger.getsize(&fdi, &sz));
- ioctl_ret = 2019;
- assert(0 == ops_logger.getsize(&fdi, &sz));
- assert(2019 == sz);
-
- expected_ioctl = LOGGER_GET_LOG_LEN;
- ioctl_ret = -67;
- assert(-67 == ops_logger.prepare_print(&fdi, 123, false, (dlogutil_filter_options_s *) 0xCA5CADE));
- expected_ioctl = LOGGER_GET_LOG_LEN;
- ioctl_ret = 0;
- assert(1 == ops_logger.prepare_print(&fdi, 123, false, (dlogutil_filter_options_s *) 0xCA5CADE));
-
- expected_ioctl = -1;
- assert(!ops_logger.prepare_print(&fdi, DLOGUTIL_MODE_CONTINUOUS, false, (dlogutil_filter_options_s *) 0xCA5CADE));
-
- fail_read = true;
- assert(-334 == ops_logger.read(&fdi));
- fail_read = false;
-
- for (size_t i = 0; i < NELEMS(READS) + 15; ++i) {
- assert(!ops_logger.has_log(&fdi));
- fail_read = true;
- assert(NULL == ops_logger.extract_entry(&fdi));
- assert(NULL == ops_logger.peek_entry(&fdi));
- assert(NULL == ops_logger.extract_entry(&fdi));
- fail_read = false;
- fail_malloc = !(rand() % 4) * 3;
- ops_logger.read(&fdi);
- if (!fail_malloc && i < NELEMS(READS) && READS[i] > sizeof(struct android_logger_entry)) {
- assert(ops_logger.has_log(&fdi));
- assert(-EAGAIN == ops_logger.read(&fdi));
- const dlogutil_entry_s *const le = ops_logger.peek_entry(&fdi);
- assert(le);
- assert(le == ops_logger.peek_entry(&fdi));
- fail_read = true;
- assert(le == ops_logger.extract_entry(&fdi));
- fail_read = false;
- free((dlogutil_entry_s *) le);
- }
- fail_malloc = 0;
- assert(!ops_logger.has_log(&fdi));
- assert(NULL == ops_logger.peek_entry(&fdi));
- fail_read = true;
- assert(NULL == ops_logger.extract_entry(&fdi));
- fail_read = false;
- }
-
- ops_logger.destroy(&fdi);
-}