1 /*
2  * Copyright 2021 The Android Open Source Project
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
17 /*
18  * Generated mock file from original source file
19  *   Functions generated:24
20  *
21  *  mockcify.pl ver 0.3.0
22  */
23 
24 #include <cstdint>
25 #include <functional>
26 #include <string>
27 
28 // Original included files, if any
29 #include <base/files/file_util.h>
30 #include <fcntl.h>
31 #include <libgen.h>
32 #include <stdlib.h>
33 #include <sys/stat.h>
34 #include <unistd.h>
35 
36 #include "osi/include/config.h"
37 
38 // Mocked compile conditionals, if any
39 
40 namespace test {
41 namespace mock {
42 namespace osi_config {
43 
44 // Shared state between mocked functions and tests
45 // Name: checksum_read
46 // Params: const char* filename
47 // Return: std::string
48 struct checksum_read {
49   std::string return_value{std::string()};
50   std::function<std::string(const char* filename)> body{
51           [this](const char* /* filename */) { return return_value; }};
operatorchecksum_read52   std::string operator()(const char* filename) { return body(filename); }
53 };
54 extern struct checksum_read checksum_read;
55 
56 // Name: checksum_save
57 // Params: const std::string& checksum, const std::string& filename
58 // Return: bool
59 struct checksum_save {
60   bool return_value{false};
61   std::function<bool(const std::string& checksum, const std::string& filename)> body{
62           [this](const std::string& /* checksum */, const std::string& /* filename */) {
63             return return_value;
64           }};
operatorchecksum_save65   bool operator()(const std::string& checksum, const std::string& filename) {
66     return body(checksum, filename);
67   }
68 };
69 extern struct checksum_save checksum_save;
70 
71 // Name: config_get_bool
72 // Params: const config_t& config, const std::string& section, const
73 // std::string& key, bool def_value Return: bool
74 struct config_get_bool {
75   bool return_value{false};
76   std::function<bool(const config_t& config, const std::string& section, const std::string& key,
77                      bool def_value)>
78           body{[this](const config_t& /* config */, const std::string& /* section */,
79                       const std::string& /* key */, bool /* def_value */) { return return_value; }};
operatorconfig_get_bool80   bool operator()(const config_t& config, const std::string& section, const std::string& key,
81                   bool def_value) {
82     return body(config, section, key, def_value);
83   }
84 };
85 extern struct config_get_bool config_get_bool;
86 
87 // Name: config_get_int
88 // Params: const config_t& config, const std::string& section, const
89 // std::string& key, int def_value Return: int
90 struct config_get_int {
91   int return_value{0};
92   std::function<int(const config_t& config, const std::string& section, const std::string& key,
93                     int def_value)>
94           body{[this](const config_t& /* config */, const std::string& /* section */,
95                       const std::string& /* key */, int /* def_value */) { return return_value; }};
operatorconfig_get_int96   int operator()(const config_t& config, const std::string& section, const std::string& key,
97                  int def_value) {
98     return body(config, section, key, def_value);
99   }
100 };
101 extern struct config_get_int config_get_int;
102 
103 // Name: config_get_string
104 // Params: const config_t& config, const std::string& section, const
105 // std::string& key, const std::string* def_value Return: const std::string*
106 struct config_get_string {
107   const std::string* return_value{0};
108   std::function<const std::string*(const config_t& config, const std::string& section,
109                                    const std::string& key, const std::string* def_value)>
110           body{[this](const config_t& /* config */, const std::string& /* section */,
111                       const std::string& /* key */,
112                       const std::string* /* def_value */) { return return_value; }};
operatorconfig_get_string113   const std::string* operator()(const config_t& config, const std::string& section,
114                                 const std::string& key, const std::string* def_value) {
115     return body(config, section, key, def_value);
116   }
117 };
118 extern struct config_get_string config_get_string;
119 
120 // Name: config_get_uint64
121 // Params: const config_t& config, const std::string& section, const
122 // std::string& key, uint64_t def_value Return: uint64_t
123 struct config_get_uint64 {
124   uint64_t return_value{0};
125   std::function<uint64_t(const config_t& config, const std::string& section, const std::string& key,
126                          uint64_t def_value)>
127           body{[this](const config_t& /* config */, const std::string& /* section */,
128                       const std::string& /* key */,
129                       uint64_t /* def_value */) { return return_value; }};
operatorconfig_get_uint64130   uint64_t operator()(const config_t& config, const std::string& section, const std::string& key,
131                       uint64_t def_value) {
132     return body(config, section, key, def_value);
133   }
134 };
135 extern struct config_get_uint64 config_get_uint64;
136 
137 // Name: config_has_key
138 // Params: const config_t& config, const std::string& section, const
139 // std::string& key Return: bool
140 struct config_has_key {
141   bool return_value{false};
142   std::function<bool(const config_t& config, const std::string& section, const std::string& key)>
143           body{[this](const config_t& /* config */, const std::string& /* section */,
144                       const std::string& /* key */) { return return_value; }};
operatorconfig_has_key145   bool operator()(const config_t& config, const std::string& section, const std::string& key) {
146     return body(config, section, key);
147   }
148 };
149 extern struct config_has_key config_has_key;
150 
151 // Name: config_has_section
152 // Params: const config_t& config, const std::string& section
153 // Return: bool
154 struct config_has_section {
155   bool return_value{false};
156   std::function<bool(const config_t& /* config */, const std::string& /* section */)> body{
157           [this](const config_t& /* config */, const std::string& /* section */) {
158             return return_value;
159           }};
operatorconfig_has_section160   bool operator()(const config_t& config, const std::string& section) {
161     return body(config, section);
162   }
163 };
164 extern struct config_has_section config_has_section;
165 
166 // Name: config_new
167 // Params: const char* filename
168 // Return: std::unique_ptr<config_t>
169 struct config_new {
170   std::function<std::unique_ptr<config_t>(const char* filename)> body{
171           [](const char* /* filename */) { return std::make_unique<config_t>(); }};
operatorconfig_new172   std::unique_ptr<config_t> operator()(const char* filename) { return body(filename); }
173 };
174 extern struct config_new config_new;
175 
176 // Name: config_new_clone
177 // Params: const config_t& src
178 // Return: std::unique_ptr<config_t>
179 struct config_new_clone {
180   std::function<std::unique_ptr<config_t>(const config_t& src)> body{
181           [](const config_t& /* src */) { return std::make_unique<config_t>(); }};
operatorconfig_new_clone182   std::unique_ptr<config_t> operator()(const config_t& src) { return body(src); }
183 };
184 extern struct config_new_clone config_new_clone;
185 
186 // Name: config_new_empty
187 // Params: void
188 // Return: std::unique_ptr<config_t>
189 struct config_new_empty {
190   std::function<std::unique_ptr<config_t>(void)> body{
191           [](void) { return std::make_unique<config_t>(); }};
operatorconfig_new_empty192   std::unique_ptr<config_t> operator()(void) { return body(); }
193 };
194 extern struct config_new_empty config_new_empty;
195 
196 // Name: config_remove_key
197 // Params: config_t* config, const std::string& section, const std::string& key
198 // Return: bool
199 struct config_remove_key {
200   bool return_value{false};
201   std::function<bool(config_t* config, const std::string& section, const std::string& key)> body{
202           [this](config_t* /* config */, const std::string& /* section */,
203                  const std::string& /* key */) { return return_value; }};
operatorconfig_remove_key204   bool operator()(config_t* config, const std::string& section, const std::string& key) {
205     return body(config, section, key);
206   }
207 };
208 extern struct config_remove_key config_remove_key;
209 
210 // Name: config_remove_section
211 // Params: config_t* config, const std::string& section
212 // Return: bool
213 struct config_remove_section {
214   bool return_value{false};
215   std::function<bool(config_t* config, const std::string& section)> body{
216           [this](config_t* /* config */, const std::string& /* section */) {
217             return return_value;
218           }};
operatorconfig_remove_section219   bool operator()(config_t* config, const std::string& section) { return body(config, section); }
220 };
221 extern struct config_remove_section config_remove_section;
222 
223 // Name: config_save
224 // Params: const config_t& config, const std::string& filename
225 // Return: bool
226 struct config_save {
227   bool return_value{false};
228   std::function<bool(const config_t& config, const std::string& filename)> body{
229           [this](const config_t& /* config */, const std::string& /* filename */) {
230             return return_value;
231           }};
operatorconfig_save232   bool operator()(const config_t& config, const std::string& filename) {
233     return body(config, filename);
234   }
235 };
236 extern struct config_save config_save;
237 
238 // Name: config_set_bool
239 // Params: config_t* config, const std::string& section, const std::string& key,
240 // bool value Return: void
241 struct config_set_bool {
242   std::function<void(config_t* config, const std::string& section, const std::string& key,
243                      bool value)>
244           body{[](config_t* /* config */, const std::string& /* section */,
245                   const std::string& /* key */, bool /* value */) {}};
operatorconfig_set_bool246   void operator()(config_t* config, const std::string& section, const std::string& key,
247                   bool value) {
248     body(config, section, key, value);
249   }
250 };
251 extern struct config_set_bool config_set_bool;
252 
253 // Name: config_set_int
254 // Params: config_t* config, const std::string& section, const std::string& key,
255 // int value Return: void
256 struct config_set_int {
257   std::function<void(config_t* config, const std::string& section, const std::string& key,
258                      int value)>
259           body{[](config_t* /* config */, const std::string& /* section */,
260                   const std::string& /* key */, int /* value */) {}};
operatorconfig_set_int261   void operator()(config_t* config, const std::string& section, const std::string& key, int value) {
262     body(config, section, key, value);
263   }
264 };
265 extern struct config_set_int config_set_int;
266 
267 // Name: config_set_string
268 // Params: config_t* config, const std::string& section, const std::string& key,
269 // const std::string& value Return: void
270 struct config_set_string {
271   std::function<void(config_t* config, const std::string& section, const std::string& key,
272                      const std::string& value)>
273           body{[](config_t* /* config */, const std::string& /* section */,
274                   const std::string& /* key */, const std::string& /* value */) {}};
operatorconfig_set_string275   void operator()(config_t* config, const std::string& section, const std::string& key,
276                   const std::string& value) {
277     body(config, section, key, value);
278   }
279 };
280 extern struct config_set_string config_set_string;
281 
282 // Name: config_set_uint64
283 // Params: config_t* config, const std::string& section, const std::string& key,
284 // uint64_t value Return: void
285 struct config_set_uint64 {
286   std::function<void(config_t* config, const std::string& section, const std::string& key,
287                      uint64_t value)>
288           body{[](config_t* /* config */, const std::string& /* section */,
289                   const std::string& /* key */, uint64_t /* value */) {}};
operatorconfig_set_uint64290   void operator()(config_t* config, const std::string& section, const std::string& key,
291                   uint64_t value) {
292     body(config, section, key, value);
293   }
294 };
295 extern struct config_set_uint64 config_set_uint64;
296 
297 // Name: config_t::Find
298 // Params: const std::string& section
299 // Return: std::list<section_t>::iterator
300 struct config_t_Find {
301   std::list<section_t> section_;
302   std::function<std::list<section_t>::iterator(const std::string& section)> body{
303           [this](const std::string& /* section */) { return section_.begin(); }};
operatorconfig_t_Find304   std::list<section_t>::iterator operator()(const std::string& section) { return body(section); }
305 };
306 extern struct config_t_Find config_t_Find;
307 
308 // Name: config_t_Has
309 // Params: const std::string& key
310 // Return: bool
311 struct config_t_Has {
312   bool return_value{false};
313   std::function<bool(const std::string& key)> body{
314           [this](const std::string& /* key */) { return return_value; }};
operatorconfig_t_Has315   bool operator()(const std::string& key) { return body(key); }
316 };
317 extern struct config_t_Has config_t_Has;
318 
319 // Name: section_t_Find
320 // Params: const std::string& key
321 // Return: std::list<entry_t>::iterator
322 struct section_t_Find {
323   std::list<entry_t> list_;
324   std::function<std::list<entry_t>::iterator(const std::string& key)> body{
325           [this](const std::string& /* key */) { return list_.begin(); }};
operatorsection_t_Find326   std::list<entry_t>::iterator operator()(const std::string& key) { return body(key); }
327 };
328 extern struct section_t_Find section_t_Find;
329 
330 // Name: section_t_Has
331 // Params: const std::string& key
332 // Return: bool
333 struct section_t_Has {
334   bool return_value{false};
335   std::function<bool(const std::string& key)> body{
336           [this](const std::string& /* key */) { return return_value; }};
operatorsection_t_Has337   bool operator()(const std::string& key) { return body(key); }
338 };
339 extern struct section_t_Has section_t_Has;
340 
341 // Name: section_t_Set
342 // Params: std::string key, std::string value
343 // Return: void
344 struct section_t_Set {
345   std::function<void(std::string key, std::string value)> body{
346           [](std::string /* key */, std::string /* value */) {}};
operatorsection_t_Set347   void operator()(std::string key, std::string value) { body(key, value); }
348 };
349 extern struct section_t_Set section_t_Set;
350 
351 }  // namespace osi_config
352 }  // namespace mock
353 }  // namespace test
354 
355 // END mockcify generation
356