2 * Copyright (c) 2019-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.
17 #include "fdi_logger_wrap.c"
19 static void monitor_more_reads(size_t N, struct fd_info *fdi)
21 struct logger_priv_data *const lpd = (struct logger_priv_data *)fdi->priv_data;
27 for(size_t i = 0; i < N; ++i)
28 lpd->log_len += READS[i];
30 assert(READS[N] == ops_logger.read(fdi));
35 struct fd_info fdi = {
39 list_head used_paths = NULL;
42 assert(!ops_logger.create(&fdi, (struct log_config *) 0xABDUL, LOG_ID_RADIO, &used_paths, &(log_id_t){ LOG_ID_INVALID }));
43 assert(fdi.fd == 0xFD);
44 assert(fdi.priv_data);
46 ops_logger.destroy(&fdi);
47 assert(!fdi.priv_data);
49 open_buf_path = "def";
50 assert(!ops_logger.create(&fdi, (struct log_config *) 0xABDUL, LOG_ID_RADIO, &used_paths, &(log_id_t){ LOG_ID_INVALID }));
52 expected_ioctl = LOGGER_FLUSH_LOG;
54 assert(0 == ops_logger.clear(&fdi));
57 expected_ioctl = LOGGER_GET_LOG_BUF_SIZE;
58 ioctl_ret = -EALREADY;
59 assert(-EALREADY == ops_logger.get_capacity(&fdi, &sz));
60 assert(-EALREADY == ops_logger.get_usage(&fdi, &us));
62 expected_ioctl = LOGGER_GET_LOG_BUF_SIZE;
64 assert(0 == ops_logger.get_capacity(&fdi, &sz));
65 assert(0 == ops_logger.get_usage(&fdi, &us));
69 expected_ioctl = LOGGER_GET_LOG_BUF_SIZE;
70 fail_next_ioctl = true;
74 assert(0 == ops_logger.get_capacity(&fdi, &sz));
75 assert(-4665 == ops_logger.get_usage(&fdi, &us));
77 assert(0xDEADBEEF == us);
78 fail_next_ioctl = false;
80 expected_ioctl = LOGGER_GET_LOG_LEN;
82 assert(1 == ops_logger.prepare_print(&fdi, 123, false, (struct log_filter *) 0xCA5CADE));
84 monitor_more_reads(3, &fdi);
85 monitor_more_reads(6, &fdi);
86 monitor_more_reads(34, &fdi);
87 monitor_more_reads(55, &fdi);
88 monitor_more_reads(77, &fdi);
90 ops_logger.destroy(&fdi);