libamxb  4.8.2
Bus Agnostic C API
test_amxb_backend_mngr.c
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** SPDX-License-Identifier: BSD-2-Clause-Patent
4 **
5 ** SPDX-FileCopyrightText: Copyright (c) 2023 SoftAtHome
6 **
7 ** Redistribution and use in source and binary forms, with or without modification,
8 ** are permitted provided that the following conditions are met:
9 **
10 ** 1. Redistributions of source code must retain the above copyright notice,
11 ** this list of conditions and the following disclaimer.
12 **
13 ** 2. Redistributions in binary form must reproduce the above copyright notice,
14 ** this list of conditions and the following disclaimer in the documentation
15 ** and/or other materials provided with the distribution.
16 **
17 ** Subject to the terms and conditions of this license, each copyright holder
18 ** and contributor hereby grants to those receiving rights under this license
19 ** a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
20 ** (except for failure to satisfy the conditions of this license) patent license
21 ** to make, have made, use, offer to sell, sell, import, and otherwise transfer
22 ** this software, where such license applies only to those patent claims, already
23 ** acquired or hereafter acquired, licensable by such copyright holder or contributor
24 ** that are necessarily infringed by:
25 **
26 ** (a) their Contribution(s) (the licensed copyrights of copyright holders and
27 ** non-copyrightable additions of contributors, in source or binary form) alone;
28 ** or
29 **
30 ** (b) combination of their Contribution(s) with the work of authorship to which
31 ** such Contribution(s) was added by such copyright holder or contributor, if,
32 ** at the time the Contribution is added, such addition causes such combination
33 ** to be necessarily infringed. The patent license shall not apply to any other
34 ** combinations which include the Contribution.
35 **
36 ** Except as expressly stated above, no rights or licenses from any copyright
37 ** holder or contributor is granted under this license, whether expressly, by
38 ** implication, estoppel or otherwise.
39 **
40 ** DISCLAIMER
41 **
42 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
43 ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
46 ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47 ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
48 ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
49 ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
50 ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
51 ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 **
53 ****************************************************************************/
54 
55 #include <stdlib.h>
56 #include <dlfcn.h>
57 #include <stdarg.h>
58 #include <stddef.h>
59 #include <setjmp.h>
60 #include <cmocka.h>
61 
62 #include <amxc/amxc_variant.h>
63 #include <amxc/amxc_htable.h>
64 #include <amxc/amxc_lqueue.h>
65 
66 #include <amxp/amxp_signal.h>
67 #include <amxp/amxp_slot.h>
68 
69 #include <amxd/amxd_dm.h>
70 
71 #include <amxb/amxb_be.h>
72 #include <amxb/amxb.h>
73 
74 #include "test_amxb_backend_mngr.h"
75 
76 #include <amxc/amxc_macros.h>
77 
78 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
79 
80 void* __real_dlopen(const char* filename, int flag);
81 int __real_dlclose(void* handle);
82 
83 void* __wrap_dlopen(const char* filename, int flag);
84 int __wrap_dlclose(void* handle);
85 void* __wrap_dlsym(void* handle, const char* symbol);
86 
87 static void* fake_handle = NULL;
88 static char* fake_ctx = "fake";
89 static int return_val = 0;
90 
91 static uint32_t min_version_id = 0;
92 static uint32_t max_version_id = 0;
93 static bool has_info = true;
94 static bool register_be = true;
95 
97  { // id = 0
98  .major = 0,
99  .minor = -1,
100  .build = -1,
101  },
102  { // id = 1
103  .major = 0,
104  .minor = 1,
105  .build = -1,
106  },
107  { // id = 2
108  .major = 0,
109  .minor = 1,
110  .build = -1,
111  },
112  { // id = 3
113  .major = 0,
114  .minor = 0,
115  .build = -1
116  },
117  { // id = 4
118  .major = 999,
119  .minor = 999,
120  .build = 999
121  },
122  { // id = 5
123  .major = 4,
124  .minor = 999,
125  .build = 999
126  },
127  { // id = 6
128  .major = 4,
129  .minor = 8,
130  .build = 999
131  },
132  {
133  .major = -1,
134  }
135 };
136 
138  { // id = 0
139  .major = 4,
140  .minor = 99,
141  .build = 999,
142  },
143  {
144  .major = 4,
145  .minor = 8,
146  .build = 999,
147  },
148  {
149  .major = -1,
150  }
151 };
152 
154  .major = 0,
155  .minor = 0,
156  .build = 7
157 };
158 
161  .name = "dummy",
162  .description = "Dummy description",
163 };
164 
166  if(min_version_id == UINT32_MAX) {
167  be_info.min_supported = NULL;
168  } else {
170  }
171  if(max_version_id == UINT32_MAX) {
172  be_info.max_supported = NULL;
173  } else {
175  }
176 
177  return &be_info;
178 }
179 
180 static void* fake_connect(UNUSED const char* host,
181  UNUSED const char* port,
182  UNUSED const char* path,
183  UNUSED amxp_signal_mngr_t* sigmngr) {
184  return fake_ctx;
185 }
186 
187 static int fake_disconnect(void* ctx) {
188  assert_ptr_equal(ctx, fake_ctx);
189  return 0;
190 }
191 
194  .disconnect = fake_disconnect,
195  .size = sizeof(amxb_be_funcs_t),
196  .name = "xbus",
197 };
198 
200  .connect = NULL,
201  .size = sizeof(amxb_be_funcs_t),
202  .name = "xbus",
203 };
204 
206  .connect = NULL,
207  .size = sizeof(amxb_be_funcs_t),
208  .name = "ybus",
209 };
210 
212  .connect = NULL,
213  .size = sizeof(amxb_be_funcs_t),
214  .name = "",
215 };
216 
218  .connect = NULL,
219  .size = sizeof(amxb_be_funcs_t),
220  .name = NULL,
221 };
222 
224  .connect = NULL,
225  .size = sizeof(amxb_be_funcs_t),
226  .name = "test",
227 };
228 
229 void* __wrap_dlopen(UNUSED const char* filename, UNUSED int flag) {
230  if(fake_handle != NULL) {
231  if(register_be) {
232  if(dummy_be1.handle == NULL) {
233  assert_int_equal(amxb_be_register(&dummy_be1), 0);
234  assert_ptr_equal(dummy_be1.handle, NULL);
235  } else if(dummy_be3.handle == NULL) {
236  assert_int_equal(amxb_be_register(&dummy_be3), 0);
237  assert_ptr_equal(dummy_be3.handle, NULL);
238  } else {
239  return NULL;
240  }
241  }
242  }
243  return fake_handle;
244 }
245 
246 int __wrap_dlclose(UNUSED void* handle) {
247  return return_val;
248 }
249 
250 void* __wrap_dlsym(UNUSED void* handle, const char* symbol) {
251  assert_string_equal(symbol, "amxb_be_info");
252  if(has_info) {
253  return fake_get_version_info;
254  } else {
255  return NULL;
256  }
257 }
258 
259 void test_amxb_be_register(UNUSED void** state) {
260  assert_int_not_equal(amxb_be_register(NULL), 0);
261  assert_int_equal(amxb_be_register(&dummy_be1), 0);
262  assert_int_not_equal(amxb_be_register(&dummy_be1), 0);
263  assert_int_not_equal(amxb_be_register(&dummy_be2), 0);
264  assert_int_equal(amxb_be_register(&dummy_be3), 0);
265  assert_int_not_equal(amxb_be_register(&dummy_be4), 0);
266  assert_int_not_equal(amxb_be_register(&dummy_be5), 0);
267 
268  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
269  assert_int_equal(amxb_be_unregister(&dummy_be3), 0);
270  assert_ptr_equal(dummy_be3.handle, NULL);
271  assert_ptr_equal(dummy_be1.handle, NULL);
272 }
273 
274 void test_amxb_be_unregister(UNUSED void** state) {
275  assert_int_equal(amxb_be_register(&dummy_be1), 0);
276  assert_int_equal(amxb_be_register(&dummy_be3), 0);
277 
278  assert_int_not_equal(amxb_be_unregister(NULL), 0);
279  assert_int_not_equal(amxb_be_unregister(&dummy_be2), 0);
280  assert_int_not_equal(amxb_be_unregister(&dummy_be4), 0);
281  assert_int_not_equal(amxb_be_unregister(&dummy_be5), 0);
282  assert_int_not_equal(amxb_be_unregister(&dummy_be6), 0);
283 
284  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
285  assert_int_equal(amxb_be_unregister(&dummy_be3), 0);
286  assert_ptr_equal(dummy_be3.handle, NULL);
287  assert_ptr_equal(dummy_be1.handle, NULL);
288 }
289 
290 void test_amxb_be_find(UNUSED void** state) {
291  const amxb_be_funcs_t* funcs = NULL;
292 
293  assert_int_equal(amxb_be_register(&dummy_be1), 0);
294  assert_int_equal(amxb_be_register(&dummy_be3), 0);
295 
296  funcs = amxb_be_find(NULL);
297  assert_ptr_equal(funcs, NULL);
298 
299  funcs = amxb_be_find("test");
300  assert_ptr_equal(funcs, NULL);
301 
302  funcs = amxb_be_find("");
303  assert_ptr_equal(funcs, NULL);
304 
305  funcs = amxb_be_find("xbus");
306  assert_ptr_not_equal(funcs, NULL);
307  assert_ptr_equal(funcs, &dummy_be1);
308 
309  funcs = amxb_be_find("ybus");
310  assert_ptr_not_equal(funcs, NULL);
311  assert_ptr_equal(funcs, &dummy_be3);
312 
313  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
314  assert_int_equal(amxb_be_unregister(&dummy_be3), 0);
315  assert_ptr_equal(dummy_be3.handle, NULL);
316  assert_ptr_equal(dummy_be1.handle, NULL);
317 }
318 
319 void test_amxb_be_load(UNUSED void** state) {
320  const amxb_be_funcs_t* funcs = NULL;
321  fake_handle = __real_dlopen(NULL, RTLD_NOW);
322 
323  min_version_id = 0;
324  max_version_id = 1;
325  assert_int_not_equal(amxb_be_load(NULL), 0);
326  assert_int_not_equal(amxb_be_load(""), 0);
327  assert_int_equal(amxb_be_load("/path/to/some/sofile.so"), 0);
328  assert_ptr_equal(dummy_be1.handle, fake_handle);
329  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
330  assert_ptr_equal(dummy_be1.handle, NULL);
331 
332  funcs = amxb_be_find("xbus");
333  assert_ptr_equal(funcs, NULL);
334 
335  register_be = false;
336  assert_int_equal(amxb_be_load("/path/to/some/sofile.so"), 0);
337  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
338  assert_ptr_equal(dummy_be1.handle, NULL);
339  register_be = true;
340 
341  fake_handle = NULL;
342  assert_int_not_equal(amxb_be_load("/path/to/some/sofile.so"), 0);
343 }
344 
345 void test_amxb_be_load_same_multiple_times(UNUSED void** state) {
346  fake_handle = __real_dlopen(NULL, RTLD_NOW);
347 
348  register_be = false;
349  min_version_id = 0;
350  max_version_id = 1;
351  assert_int_equal(amxb_be_load("/path/to/some/sofile.so"), 0);
352  assert_ptr_equal(dummy_be1.handle, fake_handle);
353  assert_int_equal(amxb_be_load("/path/to/some/sofile.so"), 0);
354  assert_ptr_equal(dummy_be1.handle, fake_handle);
355  assert_int_equal(amxb_be_load("/path/to/some/sofile.so"), 0);
356  assert_ptr_equal(dummy_be1.handle, fake_handle);
357  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
358  assert_ptr_equal(dummy_be1.handle, NULL);
359  register_be = true;
360 }
361 
362 void test_amxb_be_load_multiple(UNUSED void** state) {
363  amxc_var_t shared_objects;
364  fake_handle = __real_dlopen(NULL, RTLD_NOW);
365 
366  amxc_var_init(&shared_objects);
367 
368  min_version_id = 0;
369  max_version_id = 1;
370 
371  assert_int_not_equal(amxb_be_load_multiple(NULL), 0);
372  assert_int_not_equal(amxb_be_load_multiple(&shared_objects), 0);
373 
374  amxc_var_set_type(&shared_objects, AMXC_VAR_ID_CSTRING);
375  assert_int_not_equal(amxb_be_load_multiple(&shared_objects), 0);
376  amxc_var_set_type(&shared_objects, AMXC_VAR_ID_LIST);
377  assert_int_not_equal(amxb_be_load_multiple(&shared_objects), 0);
378 
379  amxc_var_set(cstring_t, &shared_objects, "/path/to/some/sofile.so");
380  assert_int_equal(amxb_be_load_multiple(&shared_objects), 0);
381  assert_ptr_equal(dummy_be1.handle, fake_handle);
382  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
383 
384  amxc_var_set_type(&shared_objects, AMXC_VAR_ID_LIST);
385  amxc_var_add(cstring_t, &shared_objects, "/path/to/some/sofile1.so");
386  amxc_var_add(cstring_t, &shared_objects, "/path/to/some/sofile2.so");
387  assert_int_equal(amxb_be_load_multiple(&shared_objects), 0);
388  assert_ptr_equal(dummy_be1.handle, fake_handle);
389  assert_ptr_equal(dummy_be3.handle, fake_handle);
390  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
391  assert_int_equal(amxb_be_unregister(&dummy_be3), 0);
392 
393  amxc_var_add(cstring_t, &shared_objects, "/path/to/some/sofile1.so");
394  amxc_var_add(cstring_t, &shared_objects, "/path/to/some/sofile2.so");
395  amxc_var_add(cstring_t, &shared_objects, "/path/to/some/sofile3.so");
396  assert_int_not_equal(amxb_be_load_multiple(&shared_objects), 0);
397  assert_ptr_equal(dummy_be1.handle, fake_handle);
398  assert_ptr_equal(dummy_be3.handle, fake_handle);
399  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
400  assert_int_equal(amxb_be_unregister(&dummy_be3), 0);
401 
402  amxc_var_set_type(&shared_objects, AMXC_VAR_ID_CSTRING);
403  amxc_var_set(cstring_t, &shared_objects, "/path/to/some/sofile1.so:/path/to/some/sofile2.so");
404  assert_int_equal(amxb_be_load_multiple(&shared_objects), 0);
405  assert_ptr_equal(dummy_be1.handle, fake_handle);
406  assert_ptr_equal(dummy_be3.handle, fake_handle);
407  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
408  assert_int_equal(amxb_be_unregister(&dummy_be3), 0);
409 
410  amxc_var_set_type(&shared_objects, AMXC_VAR_ID_CSTRING);
411  amxc_var_set(cstring_t, &shared_objects, "/path/to/some/sofile1.so:/path/to/some/sofile2.so:/path/to/some/sofile3.so");
412  assert_int_not_equal(amxb_be_load_multiple(&shared_objects), 0);
413  assert_ptr_equal(dummy_be1.handle, fake_handle);
414  assert_ptr_equal(dummy_be3.handle, fake_handle);
415  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
416  assert_int_equal(amxb_be_unregister(&dummy_be3), 0);
417 
418  amxc_var_clean(&shared_objects);
419 }
420 
421 void test_amxb_be_remove(UNUSED void** state) {
422  amxb_bus_ctx_t* c1 = NULL;
423 
424  fake_handle = __real_dlopen(NULL, RTLD_NOW);
425 
426  min_version_id = 0;
427  max_version_id = 1;
428 
429  assert_int_equal(amxb_be_register(&dummy_be1), 0);
431 
432  assert_int_not_equal(amxb_be_remove(NULL), 0);
433  assert_int_not_equal(amxb_be_remove(""), 0);
434 
435  assert_int_equal(amxb_connect(&c1, "xbus:///var/run/test.sock"), 0);
436 
437  assert_int_equal(amxb_be_remove("xbus"), 0);
438  assert_int_not_equal(amxb_be_unregister(&dummy_be1), 0);
439  assert_int_not_equal(amxb_be_remove("xbus"), 0);
440 
441  assert_int_equal(amxb_be_register(&dummy_be1), 0);
442  dummy_be1.handle = NULL;
443  assert_int_not_equal(amxb_be_remove("xbus"), 0);
444  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
445 
446  assert_int_equal(amxb_be_register(&dummy_be1), 0);
448  return_val = -1;
449  assert_int_not_equal(amxb_be_remove("xbus"), 0);
450  return_val = 0;
451  assert_int_not_equal(amxb_be_unregister(&dummy_be1), 0);
452 }
453 
454 void test_amxb_be_remove_all(UNUSED void** state) {
455  fake_handle = __real_dlopen(NULL, RTLD_NOW);
456  amxb_bus_ctx_t* c1 = NULL;
457  amxb_bus_ctx_t* c2 = NULL;
458 
459  assert_int_equal(amxb_be_register(&dummy_be1), 0);
460  assert_int_equal(amxb_be_register(&dummy_be3), 0);
463 
464  assert_int_equal(amxb_connect(&c1, "xbus:///var/run/test.sock"), 0);
465  assert_int_equal(amxb_connect(&c2, "xbus:///var/run/test.sock"), 0);
466 
467  amxb_free(&c1);
468 
470  assert_int_not_equal(amxb_be_unregister(&dummy_be1), 0);
471  dummy_be1.handle = NULL;
472  assert_int_not_equal(amxb_be_unregister(&dummy_be3), 0);
473  dummy_be3.handle = NULL;
474 
475  assert_int_equal(amxb_be_register(&dummy_be1), 0);
477  return_val = -1;
479  return_val = 0;
480  assert_int_not_equal(amxb_be_unregister(&dummy_be1), 0);
481  dummy_be1.handle = NULL;
482 }
483 
484 void test_amxb_be_load_version_checking(UNUSED void** state) {
485  fake_handle = __real_dlopen(NULL, RTLD_NOW);
486 
487  min_version_id = 0;
488  max_version_id = 0;
489  for(uint32_t i = 0; i < ARRAY_SIZE(sup_min_version); i++) {
490  min_version_id = i;
491  if(i < 4) {
492  assert_int_equal(amxb_be_load("/path/to/some/sofile.so"), 0);
493  assert_ptr_equal(dummy_be1.handle, fake_handle);
494  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
495  } else {
496  assert_int_not_equal(amxb_be_load("/path/to/some/sofile.so"), 0);
497  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
498  }
499  }
500 
501  min_version_id = 0;
502  max_version_id = 1;
503  for(uint32_t i = 0; i < ARRAY_SIZE(sup_min_version); i++) {
504  min_version_id = i;
505  if(i < 4) {
506  assert_int_equal(amxb_be_load("/path/to/some/sofile.so"), 0);
507  assert_ptr_equal(dummy_be1.handle, fake_handle);
508  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
509  } else {
510  assert_int_not_equal(amxb_be_load("/path/to/some/sofile.so"), 0);
511  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
512  }
513  }
514 
515  min_version_id = UINT32_MAX;
516  assert_int_not_equal(amxb_be_load("/path/to/some/sofile.so"), 0);
517  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
518  min_version_id = 0;
519  max_version_id = UINT32_MAX;
520  assert_int_not_equal(amxb_be_load("/path/to/some/sofile.so"), 0);
521  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
522  max_version_id = 0;
523  has_info = false;
524  assert_int_not_equal(amxb_be_load("/path/to/some/sofile.so"), 0);
525  assert_int_equal(amxb_be_unregister(&dummy_be1), 0);
526  has_info = true;
527 }
528 
529 void test_amxb_be_get_version(UNUSED void** state) {
531  amxb_version_t* libv2 = NULL;
532  assert_ptr_not_equal(libv, NULL);
533  assert_int_not_equal(libv->major, 99999);
534  libv->major = 99999;
535  assert_int_equal(libv->major, 99999);
536  libv2 = (amxb_version_t*) amxb_get_version();
537  assert_ptr_equal(libv, libv2);
538  assert_int_not_equal(libv->major, 99999);
539  assert_int_not_equal(libv2->major, 99999);
540 }
541 
542 void test_amxb_set_config(UNUSED void** state) {
543  amxc_var_t config;
544 
545  amxc_var_init(&config);
546  amxc_var_set_type(&config, AMXC_VAR_ID_HTABLE);
547 
548  amxc_var_add_key(amxc_htable_t, &config, "dummy", NULL);
549  assert_int_equal(amxb_set_config(&config), 0);
550 
551  amxc_var_clean(&config);
552 }
553 
554 void test_amxb_be_get_info(UNUSED void** state) {
555  fake_handle = __real_dlopen(NULL, RTLD_NOW);
556  const amxb_be_info_t* info = NULL;
557 
558  assert_int_equal(amxb_be_register(&dummy_be1), 0);
559 
560  info = amxb_be_get_info("xbus");
561  assert_non_null(info);
562  info = amxb_be_get_info("test");
563  assert_null(info);
564  info = amxb_be_get_info("");
565  assert_null(info);
566  info = amxb_be_get_info(NULL);
567  assert_null(info);
568 
570 
571  info = amxb_be_get_info("xbus");
572  assert_null(info);
573 
574  return_val = 0;
575  assert_int_not_equal(amxb_be_unregister(&dummy_be1), 0);
576 }
Ambiorix bus agnostic API header file.
Ambiorix bus agnostic API header file.
config
Definition: test.odl:56
struct _amxb_be_funcs amxb_be_funcs_t
Definition: amxb_types.h:79
int amxb_be_unregister(amxb_be_funcs_t *const funcs)
Unregisters a backend interface.
const amxb_version_t * amxb_get_version(void)
Gets the version of the library.
int amxb_be_register(amxb_be_funcs_t *const funcs)
Registers backend interface.
const amxb_be_info_t * amxb_be_get_info(const char *name)
Gets a backend information.
int amxb_be_load(const char *path_name)
Loads a shared object that implements a bus specific backend interface.
int amxb_be_load_multiple(amxc_var_t *const bes)
Loads multiple shared objects that each implement a bus specific backend interface.
int amxb_be_remove(const char *backend_name)
Removes and unloads a backend with a given name.
amxb_be_funcs_t * amxb_be_find(const char *name)
Gets a backend function table using its name.
int amxb_set_config(amxc_var_t *const configuration)
Passes configuration options to the backends.
void amxb_be_remove_all(void)
Removes and unloads all backends.
int amxb_connect(amxb_bus_ctx_t **ctx, const char *uri)
Create a bus connection.
void amxb_free(amxb_bus_ctx_t **ctx)
Frees allocated memory.
The back-end interface structure.
amxb_be_connect_fn_t connect
const amxb_version_t * min_supported
Definition: amxb_types.h:105
const amxb_version_t * be_version
Definition: amxb_types.h:107
const amxb_version_t * max_supported
Definition: amxb_types.h:106
int32_t major
Definition: amxb_types.h:99
void * __wrap_dlopen(const char *filename, int flag)
static bool register_be
static int fake_disconnect(void *ctx)
void test_amxb_be_remove(UNUSED void **state)
void test_amxb_be_get_version(UNUSED void **state)
static amxb_be_funcs_t dummy_be1
void test_amxb_be_load(UNUSED void **state)
static int return_val
void test_amxb_set_config(UNUSED void **state)
#define ARRAY_SIZE(arr)
static amxb_version_t sup_min_version[]
static uint32_t min_version_id
static void * fake_handle
void test_amxb_be_unregister(UNUSED void **state)
static amxb_be_funcs_t dummy_be5
static amxb_be_funcs_t dummy_be4
void test_amxb_be_load_version_checking(UNUSED void **state)
void * __real_dlopen(const char *filename, int flag)
int __wrap_dlclose(void *handle)
void test_amxb_be_get_info(UNUSED void **state)
static amxb_be_funcs_t dummy_be6
static char * fake_ctx
static void * fake_connect(UNUSED const char *host, UNUSED const char *port, UNUSED const char *path, UNUSED amxp_signal_mngr_t *sigmngr)
void test_amxb_be_find(UNUSED void **state)
static amxb_be_info_t * fake_get_version_info()
void test_amxb_be_load_same_multiple_times(UNUSED void **state)
void test_amxb_be_register(UNUSED void **state)
void test_amxb_be_remove_all(UNUSED void **state)
static amxb_be_funcs_t dummy_be3
static uint32_t max_version_id
static amxb_be_info_t be_info
static amxb_version_t be_version
static amxb_version_t sup_max_version[]
void test_amxb_be_load_multiple(UNUSED void **state)
static bool has_info
void * __wrap_dlsym(void *handle, const char *symbol)
int __real_dlclose(void *handle)
static amxb_be_funcs_t dummy_be2