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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
|
/*
* Copyright 2021 The Android Open Source Project
*
* 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.
*/
/*
* Generated mock file from original source file
* Functions generated:24
*
* mockcify.pl ver 0.3.0
*/
#include <cstdint>
#include <functional>
#include <map>
#include <string>
extern std::map<std::string, int> mock_function_count_map;
// Original included files, if any
// NOTE: Since this is a mock file with mock definitions some number of
// include files may not be required. The include-what-you-use
// still applies, but crafting proper inclusion is out of scope
// for this effort. This compilation unit may compile as-is, or
// may need attention to prune from (or add to ) the inclusion set.
#include <base/files/file_util.h>
#include <base/logging.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
#include <log/log.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sstream>
#include <type_traits>
#include "check.h"
#include "osi/include/config.h"
// Mocked compile conditionals, if any
namespace test {
namespace mock {
namespace osi_config {
// Shared state between mocked functions and tests
// Name: checksum_read
// Params: const char* filename
// Return: std::string
struct checksum_read {
std::string return_value{std::string()};
std::function<std::string(const char* filename)> body{
[this](const char* filename) { return return_value; }};
std::string operator()(const char* filename) { return body(filename); };
};
extern struct checksum_read checksum_read;
// Name: checksum_save
// Params: const std::string& checksum, const std::string& filename
// Return: bool
struct checksum_save {
bool return_value{false};
std::function<bool(const std::string& checksum, const std::string& filename)>
body{[this](const std::string& checksum, const std::string& filename) {
return return_value;
}};
bool operator()(const std::string& checksum, const std::string& filename) {
return body(checksum, filename);
};
};
extern struct checksum_save checksum_save;
// Name: config_get_bool
// Params: const config_t& config, const std::string& section, const
// std::string& key, bool def_value Return: bool
struct config_get_bool {
bool return_value{false};
std::function<bool(const config_t& config, const std::string& section,
const std::string& key, bool def_value)>
body{[this](const config_t& config, const std::string& section,
const std::string& key,
bool def_value) { return return_value; }};
bool operator()(const config_t& config, const std::string& section,
const std::string& key, bool def_value) {
return body(config, section, key, def_value);
};
};
extern struct config_get_bool config_get_bool;
// Name: config_get_int
// Params: const config_t& config, const std::string& section, const
// std::string& key, int def_value Return: int
struct config_get_int {
int return_value{0};
std::function<int(const config_t& config, const std::string& section,
const std::string& key, int def_value)>
body{[this](const config_t& config, const std::string& section,
const std::string& key,
int def_value) { return return_value; }};
int operator()(const config_t& config, const std::string& section,
const std::string& key, int def_value) {
return body(config, section, key, def_value);
};
};
extern struct config_get_int config_get_int;
// Name: config_get_string
// Params: const config_t& config, const std::string& section, const
// std::string& key, const std::string* def_value Return: const std::string*
struct config_get_string {
const std::string* return_value{0};
std::function<const std::string*(
const config_t& config, const std::string& section,
const std::string& key, const std::string* def_value)>
body{[this](const config_t& config, const std::string& section,
const std::string& key,
const std::string* def_value) { return return_value; }};
const std::string* operator()(const config_t& config,
const std::string& section,
const std::string& key,
const std::string* def_value) {
return body(config, section, key, def_value);
};
};
extern struct config_get_string config_get_string;
// Name: config_get_uint64
// Params: const config_t& config, const std::string& section, const
// std::string& key, uint64_t def_value Return: uint64_t
struct config_get_uint64 {
uint64_t return_value{0};
std::function<uint64_t(const config_t& config, const std::string& section,
const std::string& key, uint64_t def_value)>
body{[this](const config_t& config, const std::string& section,
const std::string& key,
uint64_t def_value) { return return_value; }};
uint64_t operator()(const config_t& config, const std::string& section,
const std::string& key, uint64_t def_value) {
return body(config, section, key, def_value);
};
};
extern struct config_get_uint64 config_get_uint64;
// Name: config_has_key
// Params: const config_t& config, const std::string& section, const
// std::string& key Return: bool
struct config_has_key {
bool return_value{false};
std::function<bool(const config_t& config, const std::string& section,
const std::string& key)>
body{[this](const config_t& config, const std::string& section,
const std::string& key) { return return_value; }};
bool operator()(const config_t& config, const std::string& section,
const std::string& key) {
return body(config, section, key);
};
};
extern struct config_has_key config_has_key;
// Name: config_has_section
// Params: const config_t& config, const std::string& section
// Return: bool
struct config_has_section {
bool return_value{false};
std::function<bool(const config_t& config, const std::string& section)> body{
[this](const config_t& config, const std::string& section) {
return return_value;
}};
bool operator()(const config_t& config, const std::string& section) {
return body(config, section);
};
};
extern struct config_has_section config_has_section;
// Name: config_new
// Params: const char* filename
// Return: std::unique_ptr<config_t>
struct config_new {
std::function<std::unique_ptr<config_t>(const char* filename)> body{
[](const char* filename) { return std::make_unique<config_t>(); }};
std::unique_ptr<config_t> operator()(const char* filename) {
return body(filename);
};
};
extern struct config_new config_new;
// Name: config_new_clone
// Params: const config_t& src
// Return: std::unique_ptr<config_t>
struct config_new_clone {
std::function<std::unique_ptr<config_t>(const config_t& src)> body{
[](const config_t& src) { return std::make_unique<config_t>(); }};
std::unique_ptr<config_t> operator()(const config_t& src) {
return body(src);
};
};
extern struct config_new_clone config_new_clone;
// Name: config_new_empty
// Params: void
// Return: std::unique_ptr<config_t>
struct config_new_empty {
std::function<std::unique_ptr<config_t>(void)> body{
[](void) { return std::make_unique<config_t>(); }};
std::unique_ptr<config_t> operator()(void) { return body(); };
};
extern struct config_new_empty config_new_empty;
// Name: config_remove_key
// Params: config_t* config, const std::string& section, const std::string& key
// Return: bool
struct config_remove_key {
bool return_value{false};
std::function<bool(config_t* config, const std::string& section,
const std::string& key)>
body{[this](config_t* config, const std::string& section,
const std::string& key) { return return_value; }};
bool operator()(config_t* config, const std::string& section,
const std::string& key) {
return body(config, section, key);
};
};
extern struct config_remove_key config_remove_key;
// Name: config_remove_section
// Params: config_t* config, const std::string& section
// Return: bool
struct config_remove_section {
bool return_value{false};
std::function<bool(config_t* config, const std::string& section)> body{
[this](config_t* config, const std::string& section) {
return return_value;
}};
bool operator()(config_t* config, const std::string& section) {
return body(config, section);
};
};
extern struct config_remove_section config_remove_section;
// Name: config_save
// Params: const config_t& config, const std::string& filename
// Return: bool
struct config_save {
bool return_value{false};
std::function<bool(const config_t& config, const std::string& filename)> body{
[this](const config_t& config, const std::string& filename) {
return return_value;
}};
bool operator()(const config_t& config, const std::string& filename) {
return body(config, filename);
};
};
extern struct config_save config_save;
// Name: config_set_bool
// Params: config_t* config, const std::string& section, const std::string& key,
// bool value Return: void
struct config_set_bool {
std::function<void(config_t* config, const std::string& section,
const std::string& key, bool value)>
body{[](config_t* config, const std::string& section,
const std::string& key, bool value) {}};
void operator()(config_t* config, const std::string& section,
const std::string& key, bool value) {
body(config, section, key, value);
};
};
extern struct config_set_bool config_set_bool;
// Name: config_set_int
// Params: config_t* config, const std::string& section, const std::string& key,
// int value Return: void
struct config_set_int {
std::function<void(config_t* config, const std::string& section,
const std::string& key, int value)>
body{[](config_t* config, const std::string& section,
const std::string& key, int value) {}};
void operator()(config_t* config, const std::string& section,
const std::string& key, int value) {
body(config, section, key, value);
};
};
extern struct config_set_int config_set_int;
// Name: config_set_string
// Params: config_t* config, const std::string& section, const std::string& key,
// const std::string& value Return: void
struct config_set_string {
std::function<void(config_t* config, const std::string& section,
const std::string& key, const std::string& value)>
body{[](config_t* config, const std::string& section,
const std::string& key, const std::string& value) {}};
void operator()(config_t* config, const std::string& section,
const std::string& key, const std::string& value) {
body(config, section, key, value);
};
};
extern struct config_set_string config_set_string;
// Name: config_set_uint64
// Params: config_t* config, const std::string& section, const std::string& key,
// uint64_t value Return: void
struct config_set_uint64 {
std::function<void(config_t* config, const std::string& section,
const std::string& key, uint64_t value)>
body{[](config_t* config, const std::string& section,
const std::string& key, uint64_t value) {}};
void operator()(config_t* config, const std::string& section,
const std::string& key, uint64_t value) {
body(config, section, key, value);
};
};
extern struct config_set_uint64 config_set_uint64;
// Name: config_t::Find
// Params: const std::string& section
// Return: std::list<section_t>::iterator
struct config_t_Find {
std::list<section_t> section_;
std::function<std::list<section_t>::iterator(const std::string& section)>
body{[this](const std::string& section) { return section_.begin(); }};
std::list<section_t>::iterator operator()(const std::string& section) {
return body(section);
};
};
extern struct config_t_Find config_t_Find;
// Name: config_t_Has
// Params: const std::string& key
// Return: bool
struct config_t_Has {
bool return_value{false};
std::function<bool(const std::string& key)> body{
[this](const std::string& key) { return return_value; }};
bool operator()(const std::string& key) { return body(key); };
};
extern struct config_t_Has config_t_Has;
// Name: section_t_Find
// Params: const std::string& key
// Return: std::list<entry_t>::iterator
struct section_t_Find {
std::list<entry_t> list_;
std::function<std::list<entry_t>::iterator(const std::string& key)> body{
[this](const std::string& key) { return list_.begin(); }};
std::list<entry_t>::iterator operator()(const std::string& key) {
return body(key);
};
};
extern struct section_t_Find section_t_Find;
// Name: section_t_Has
// Params: const std::string& key
// Return: bool
struct section_t_Has {
bool return_value{false};
std::function<bool(const std::string& key)> body{
[this](const std::string& key) { return return_value; }};
bool operator()(const std::string& key) { return body(key); };
};
extern struct section_t_Has section_t_Has;
// Name: section_t_Set
// Params: std::string key, std::string value
// Return: void
struct section_t_Set {
std::function<void(std::string key, std::string value)> body{
[](std::string key, std::string value) {}};
void operator()(std::string key, std::string value) { body(key, value); };
};
extern struct section_t_Set section_t_Set;
} // namespace osi_config
} // namespace mock
} // namespace test
// END mockcify generation
|