summaryrefslogtreecommitdiff
path: root/tests/gtest_common.h
blob: 0ca9f7e19b3b66250e608c229a9a6b4eb02aa760 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/**
 * @licence app begin@
 * Copyright (C) 2016  Advanced Driver Information Technology.
 * This code is developed by Advanced Driver Information Technology.
 * Copyright of Advanced Driver Information Technology, Bosch and DENSO.
 *
 * DLT gtest common header file.
 *
 * \copyright
 * This Source Code Form is subject to the terms of the
 * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
 * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 *
 * \author Onkar Palkar <onkar.palkar@wipro.com>
 *
 * \file: gtest_common.h
 * For further information see http://www.genivi.org/.
 * @licence end@
 */

/*******************************************************************************
 *                                                                            **
 *  SRC-MODULE: gtest_common.h                                                **
 *                                                                            **
 *  TARGET    : linux                                                         **
 *                                                                            **
 *  PROJECT   : DLT                                                           **
 *                                                                            **
 *  AUTHOR    : onkar.palkar@wipro.com                                        **
 *  PURPOSE   :                                                               **
 *                                                                            **
 *  REMARKS   :                                                               **
 *                                                                            **
 *  PLATFORM DEPENDANT [yes/no]: yes                                          **
 *                                                                            **
 *  TO BE CHANGED BY USER [yes/no]: no                                        **
 *                                                                            **
 ******************************************************************************/

/*******************************************************************************
*                      Author Identity                                       **
*******************************************************************************
*                                                                            **
* Initials     Name                       Company                            **
* --------     -------------------------  ---------------------------------- **
*  op          Onkar Palkar               Wipro                              **
*******************************************************************************/
#ifndef GTEST_COMMON_H
#define GTEST_COMMON_H
int dlt_logstorage_split_key(char *key, char *appid, char *ctxid);
int dlt_logstorage_update_all_contexts(DltDaemon *daemon,
                                       char *id,
                                       int curr_log_level,
                                       int cmp_flag,
                                       int verbose);
int dlt_logstorage_update_context(DltDaemon *daemon,
                                  char *apid,
                                  char *ctxid,
                                  char *ecuid,
                                  int curr_log_level,
                                  int verbose);
int dlt_logstorage_update_context_loglevel(DltDaemon *daemon,
                                           char *key,
                                           int curr_log_level,
                                           int verbose);
void dlt_daemon_logstorage_reset_application_loglevel(DltDaemon *daemon,
                                                      int dev_num,
                                                      int max_device,
                                                      int verbose);
typedef struct {
    char *key; /* The configuration key */
    int (*func)(DltLogStorage *handle, char *value); /* conf handler */
    int is_opt; /* If configuration is optional or not */
} DltLogstorageGeneralConf;

typedef enum {
    DLT_LOGSTORAGE_GENERAL_CONF_BLOCKMODE = 0,
    DLT_LOGSTORAGE_GENERAL_CONF_COUNT
} DltLogstorageGeneralConfType;

typedef struct {
    char *key; /* Configuration key */
    int (*func)(DltLogStorageFilterConfig *config, char *value); /* conf handler */
    int is_opt; /* If configuration is optional or not */
} DltLogstorageFilterConf;

typedef enum {
    DLT_LOGSTORAGE_FILTER_CONF_LOGAPPNAME = 0,
    DLT_LOGSTORAGE_FILTER_CONF_CONTEXTNAME,
    DLT_LOGSTORAGE_FILTER_CONF_LOGLEVEL,
    DLT_LOGSTORAGE_FILTER_CONF_FILE,
    DLT_LOGSTORAGE_FILTER_CONF_FILESIZE,
    DLT_LOGSTORAGE_FILTER_CONF_NOFILES,
    DLT_LOGSTORAGE_FILTER_CONF_SYNCBEHAVIOR,
    DLT_LOGSTORAGE_FILTER_CONF_ECUID,
    DLT_LOGSTORAGE_FILTER_CONF_COUNT
} DltLogstorageFilterConfType;

    int dlt_logstorage_hash_create(int num_entries,
                                   struct hsearch_data *htab);
    int dlt_logstorage_hash_destroy(struct hsearch_data *htab);
    int dlt_logstorage_hash_add(char *key, void *value,
                                   struct hsearch_data *htab);
    void *dlt_logstorage_hash_find(char *key, struct hsearch_data *htab);
    int dlt_logstorage_count_ids(const char *str);
    int dlt_logstorage_read_number(unsigned int *number, char *value);
    int dlt_logstorage_read_list_of_names(char **names, char *value);
    int dlt_logstorage_check_apids(DltLogStorageFilterConfig *config, char *value);
    int dlt_logstorage_check_ctids(DltLogStorageFilterConfig *config, char *value);
    int dlt_logstorage_check_loglevel(DltLogStorageFilterConfig *config, char *value);
    int dlt_logstorage_check_filename(DltLogStorageFilterConfig *config, char *value);
    int dlt_logstorage_check_filesize(DltLogStorageFilterConfig *config, char *value);
    int dlt_logstorage_check_nofiles(DltLogStorageFilterConfig *config, char *value);
    int dlt_logstorage_check_sync_strategy(DltLogStorageFilterConfig *config, char *value);
    int dlt_logstorage_check_ecuid(DltLogStorageFilterConfig *config, char *value);
    int dlt_logstorage_check_param(DltLogStorageFilterConfig *config,
                                      DltLogstorageFilterConfType ctype,
                                      char *value);
    int dlt_logstorage_check_blockmode(DltLogStorage *handle,
                                          char *value);
    int dlt_logstorage_check_general_param(DltLogStorage *handle,
                                              DltLogstorageGeneralConfType ctype,
                                              char *value);
    int dlt_daemon_setup_general_properties(DltLogStorage *handle,
                                               DltConfigFile *config_file,
                                               char *sec_name);
    int dlt_logstorage_store_filters(DltLogStorage *handle,
                                        char *config_file_name);
    void dlt_logstorage_free(DltLogStorage *handle, int reason);
    int dlt_logstorage_create_keys(char *appids,
                                      char *ctxids,
                                      char **keys,
                                      int *num_keys);
    int dlt_logstorage_prepare_table(DltLogStorage *handle,
                                        DltLogStorageFilterConfig *data);
    int dlt_logstorage_validate_filter_name(char *name);
    void dlt_logstorage_filter_set_strategy(DltLogStorageFilterConfig *config,
                                               int strategy);
    int dlt_logstorage_load_config(DltLogStorage *handle);
    int dlt_logstorage_filter(DltLogStorage *handle,
                              DltLogStorageFilterConfig **config,
                              char *apid,
                              char *ctid,
                              char *ecuid,
                              int log_level);
void dlt_logstorage_log_file_name(char *log_file_name,
                                  DltLogStorageUserConfig *file_config,
                                  char *name,
                                  int idx);
void dlt_logstorage_sort_file_name(DltLogStorageFileList **head);
void dlt_logstorage_rearrange_file_name(DltLogStorageFileList **head);
unsigned int dlt_logstorage_get_idx_of_log_file(
    DltLogStorageUserConfig *file_config,
    char *file);
int dlt_logstorage_storage_dir_info(DltLogStorageUserConfig *file_config,
                                    char *path,
                                    DltLogStorageFilterConfig *config);
int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config,
                                 DltLogStorageUserConfig *file_config,
                                 char *dev_path,
                                 int msg_size);
/* gtest_dlt_daemon_gateway */
typedef enum {
    GW_CONF_IP_ADDRESS = 0,
    GW_CONF_PORT,
    GW_CONF_ECUID,
    GW_CONF_CONNECT,
    GW_CONF_TIMEOUT,
    GW_CONF_SEND_CONTROL,
    GW_CONF_SEND_PERIODIC_CONTROL,
    GW_CONF_SEND_SERIAL_HEADER,
    GW_CONF_COUNT
} DltGatewayConfType;
int enable_all(DltServiceIdFlag *flags);
int init_flags(DltServiceIdFlag *flags);
int set_bit(DltServiceIdFlag *flags, int id);
int bit(DltServiceIdFlag *flags, int id);
int dlt_daemon_filter_name(DltMessageFilter *mf,
                                   DltFilterConfiguration *config,
                                   char *value);
int dlt_daemon_filter_level(DltMessageFilter *mf,
                                   DltFilterConfiguration *config,
                                   char *value);
int dlt_daemon_filter_control_mask(DltMessageFilter *mf,
                                          DltFilterConfiguration *config,
                                          char *value);
int dlt_daemon_filter_client_mask(DltMessageFilter *mf,
                                         DltFilterConfiguration *config,
                                         char *value);
int dlt_daemon_filter_injections(DltMessageFilter *mf,
                                        DltFilterConfiguration *config,
                                        char *value);
int dlt_daemon_set_injection_service_ids(int **ids,
                                                int *num,
                                                char *value);
DltInjectionConfig *dlt_daemon_filter_find_injection_by_name(
    DltInjectionConfig *injections,
    char *name);
int dlt_daemon_injection_name(DltMessageFilter *mf,
                                         DltInjectionConfig *config,
                                         char *value);
int dlt_daemon_injection_apid(DltMessageFilter *mf,
                                         DltInjectionConfig *config,
                                         char *value);
int dlt_daemon_injection_ctid(DltMessageFilter *mf,
                                         DltInjectionConfig *config,
                                         char *value);
int dlt_daemon_injection_ecu_id(DltMessageFilter *mf,
                                           DltInjectionConfig *config,
                                           char *value);
int dlt_daemon_injection_service_id(DltMessageFilter *mf,
                                               DltInjectionConfig *config,
                                               char *value);
int dlt_daemon_get_name(DltMessageFilter *mf, char *val);
int dlt_daemon_get_default_level(DltMessageFilter *mf, char *val);
int dlt_daemon_get_backend(DltMessageFilter *mf, char *val);
int dlt_daemon_setup_filter_section(DltMessageFilter *mf,
                                           DltConfigFile *config,
                                           char *sec_name);
int dlt_daemon_setup_filter_properties(DltMessageFilter *mf,
                                              DltConfigFile *config,
                                              char *sec_name);
void dlt_daemon_filter_backend_level_changed(unsigned int level,
                                             void *ptr1,
                                             void *ptr2);
int dlt_gateway_check_ip(DltGatewayConnection *con, char *value);
int dlt_gateway_check_port(DltGatewayConnection *con, char *value);
int dlt_gateway_check_ecu(DltGatewayConnection *con, char *value);
int dlt_gateway_check_connect_trigger(DltGatewayConnection *con,
                                             char *value);
int dlt_gateway_check_timeout(DltGatewayConnection *con, char *value);
int dlt_gateway_check_send_serial(DltGatewayConnection *con, char *value);
int dlt_gateway_allocate_control_messages(DltGatewayConnection *con);
int dlt_gateway_check_control_messages(DltGatewayConnection *con,
                                              char *value);
int dlt_gateway_check_periodic_control_messages(DltGatewayConnection *con,
                                              char *value);
int dlt_gateway_check_param(DltGateway *gateway,
                                   DltGatewayConnection *con,
                                   DltGatewayConfType ctype,
                                   char *value);
int dlt_gateway_configure(DltGateway *gateway, char *config_file, int verbose);
int dlt_gateway_store_connection(DltGateway *gateway,
                                 DltGatewayConnection *tmp,
                                 int verbose);
int dlt_gateway_parse_get_log_info(DltDaemon *daemon,
                                   char *ecu,
                                   DltMessage *msg,
                                   int verbose);
#endif