62 #include <amxc/amxc_variant.h>
63 #include <amxc/amxc_htable.h>
64 #include <amxc/amxc_lqueue.h>
66 #include <amxp/amxp_signal.h>
67 #include <amxp/amxp_slot.h>
69 #include <amxd/amxd_dm.h>
76 #include <amxc/amxc_macros.h>
78 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
162 .description =
"Dummy description",
181 UNUSED
const char* port,
182 UNUSED
const char* path,
183 UNUSED amxp_signal_mngr_t* sigmngr) {
251 assert_string_equal(symbol,
"amxb_be_info");
297 assert_ptr_equal(funcs, NULL);
300 assert_ptr_equal(funcs, NULL);
303 assert_ptr_equal(funcs, NULL);
306 assert_ptr_not_equal(funcs, NULL);
310 assert_ptr_not_equal(funcs, NULL);
327 assert_int_equal(
amxb_be_load(
"/path/to/some/sofile.so"), 0);
333 assert_ptr_equal(funcs, NULL);
336 assert_int_equal(
amxb_be_load(
"/path/to/some/sofile.so"), 0);
342 assert_int_not_equal(
amxb_be_load(
"/path/to/some/sofile.so"), 0);
351 assert_int_equal(
amxb_be_load(
"/path/to/some/sofile.so"), 0);
353 assert_int_equal(
amxb_be_load(
"/path/to/some/sofile.so"), 0);
355 assert_int_equal(
amxb_be_load(
"/path/to/some/sofile.so"), 0);
363 amxc_var_t shared_objects;
366 amxc_var_init(&shared_objects);
374 amxc_var_set_type(&shared_objects, AMXC_VAR_ID_CSTRING);
376 amxc_var_set_type(&shared_objects, AMXC_VAR_ID_LIST);
379 amxc_var_set(cstring_t, &shared_objects,
"/path/to/some/sofile.so");
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");
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");
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");
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");
418 amxc_var_clean(&shared_objects);
435 assert_int_equal(
amxb_connect(&c1,
"xbus:///var/run/test.sock"), 0);
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);
492 assert_int_equal(
amxb_be_load(
"/path/to/some/sofile.so"), 0);
496 assert_int_not_equal(
amxb_be_load(
"/path/to/some/sofile.so"), 0);
506 assert_int_equal(
amxb_be_load(
"/path/to/some/sofile.so"), 0);
510 assert_int_not_equal(
amxb_be_load(
"/path/to/some/sofile.so"), 0);
516 assert_int_not_equal(
amxb_be_load(
"/path/to/some/sofile.so"), 0);
520 assert_int_not_equal(
amxb_be_load(
"/path/to/some/sofile.so"), 0);
524 assert_int_not_equal(
amxb_be_load(
"/path/to/some/sofile.so"), 0);
532 assert_ptr_not_equal(libv, NULL);
533 assert_int_not_equal(libv->
major, 99999);
535 assert_int_equal(libv->
major, 99999);
537 assert_ptr_equal(libv, libv2);
538 assert_int_not_equal(libv->
major, 99999);
539 assert_int_not_equal(libv2->
major, 99999);
546 amxc_var_set_type(&
config, AMXC_VAR_ID_HTABLE);
548 amxc_var_add_key(amxc_htable_t, &
config,
"dummy", NULL);
561 assert_non_null(info);
Ambiorix bus agnostic API header file.
Ambiorix bus agnostic API header file.
struct _amxb_be_funcs amxb_be_funcs_t
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
const amxb_version_t * be_version
const amxb_version_t * max_supported
void * __wrap_dlopen(const char *filename, int flag)
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)
void test_amxb_set_config(UNUSED void **state)
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 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)
void * __wrap_dlsym(void *handle, const char *symbol)
int __real_dlclose(void *handle)
static amxb_be_funcs_t dummy_be2