#include <stdlib.h>
#include <stdarg.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include <setjmp.h>
#include <cmocka.h>
#include <amxc/amxc_variant.h>
#include <amxc/amxc_htable.h>
#include <amxc/amxc_lqueue.h>
#include <amxp/amxp_signal.h>
#include <amxp/amxp_slot.h>
#include <amxd/amxd_dm.h>
#include <amxb/amxb_be.h>
#include <amxb/amxb.h>
#include "test_amxb_ba_connect.h"
#include <amxc/amxc_macros.h>
Go to the source code of this file.
◆ __wrap_dlclose() [1/2]
int __wrap_dlclose |
( |
UNUSED void * |
handle | ) |
|
◆ __wrap_dlclose() [2/2]
int __wrap_dlclose |
( |
void * |
handle | ) |
|
◆ dummy_accept()
static void* dummy_accept |
( |
UNUSED void * |
ctx, |
|
|
UNUSED amxp_signal_mngr_t * |
sigmngr |
|
) |
| |
|
static |
◆ dummy_connect()
static void* dummy_connect |
( |
const char * |
host, |
|
|
const char * |
port, |
|
|
const char * |
path, |
|
|
UNUSED amxp_signal_mngr_t * |
sigmngr |
|
) |
| |
|
static |
Definition at line 86 of file test_amxb_ba_connect.c.
static char verify_port[64]
static char verify_host[64]
static char verify_path[64]
◆ dummy_disconnect()
static int dummy_disconnect |
( |
void * |
ctx | ) |
|
|
static |
◆ dummy_free()
static void dummy_free |
( |
void * |
ctx | ) |
|
|
static |
◆ dummy_get_fd()
static int dummy_get_fd |
( |
void * |
ctx | ) |
|
|
static |
◆ dummy_read()
static int dummy_read |
( |
void *const |
ctx | ) |
|
|
static |
◆ dummy_read_raw()
static int dummy_read_raw |
( |
void *const |
ctx, |
|
|
UNUSED void * |
buf, |
|
|
UNUSED size_t |
size |
|
) |
| |
|
static |
◆ test_amxb_accept()
void test_amxb_accept |
( |
UNUSED void ** |
state | ) |
|
Definition at line 209 of file test_amxb_ba_connect.c.
215 assert_int_equal(
amxb_listen(&lctx,
"xbus:/tmp/test.sock"), 0);
217 assert_ptr_not_equal(actx, NULL);
int amxb_be_unregister(amxb_be_funcs_t *const funcs)
Unregisters a backend interface.
int amxb_be_register(amxb_be_funcs_t *const funcs)
Registers backend interface.
int amxb_accept(amxb_bus_ctx_t *listen_ctx, amxb_bus_ctx_t **accepted_ctx)
Accepts an incomming connection request.
int amxb_listen(amxb_bus_ctx_t **ctx, const char *uri)
Create a listen socket.
void amxb_free(amxb_bus_ctx_t **ctx)
Frees allocated memory.
int amxb_disconnect(amxb_bus_ctx_t *ctx)
Disconnects a bus connection.
static amxb_be_funcs_t dummy_be1
◆ test_amxb_connect()
void test_amxb_connect |
( |
UNUSED void ** |
state | ) |
|
Definition at line 157 of file test_amxb_ba_connect.c.
164 assert_int_equal(
amxb_connect(NULL,
"xbus://test:80/var/run/xbus.sock"), -1);
166 assert_ptr_equal(ctx, NULL);
169 assert_ptr_equal(ctx, NULL);
174 assert_int_equal(
amxb_connect(&ctx,
"xbus://test:80/var/run/xbus.sock"), 0);
175 assert_ptr_not_equal(ctx, NULL);
178 assert_string_equal(
verify_path,
"/var/run/xbus.sock");
179 assert_int_not_equal(
amxb_connect(&ctx,
"xbus://test:80/var/run/xbus.sock"), 0);
183 assert_int_equal(
amxb_connect(&ctx,
"xbus://test:80/var/run/xbus.sock"), 0);
188 assert_ptr_equal(ctx, NULL);
int amxb_connect(amxb_bus_ctx_t **ctx, const char *uri)
Create a bus connection.
#define AMXB_ERROR_BACKEND_FAILED
Back-end failed.
#define AMXB_ERROR_NOT_SUPPORTED_OP
Function/operation not supported.
#define AMXB_ERROR_NOT_SUPPORTED_SCHEME
URI scheme not supported.
#define AMXB_ERROR_INVALID_URI
Invalid URI.
static amxb_be_funcs_t dummy_be2
◆ test_amxb_disconnect()
void test_amxb_disconnect |
( |
UNUSED void ** |
state | ) |
|
Definition at line 226 of file test_amxb_ba_connect.c.
233 assert_int_equal(
amxb_connect(&ctx,
"xbus://test:80/var/run/xbus.sock"), 0);
234 assert_ptr_not_equal(ctx, NULL);
238 assert_ptr_equal(ctx, NULL);
240 assert_ptr_equal(ctx, NULL);
242 assert_int_equal(
amxb_connect(&ctx,
"zbus://test:80/var/run/zbus.sock"), 0);
243 assert_ptr_not_equal(ctx, NULL);
245 assert_ptr_not_equal(ctx, NULL);
247 assert_ptr_equal(ctx, NULL);
static amxb_be_funcs_t dummy_be3
◆ test_amxb_find_uris()
void test_amxb_find_uris |
( |
UNUSED void ** |
state | ) |
|
Definition at line 311 of file test_amxb_ba_connect.c.
317 assert_int_equal(
amxb_connect(&ctx1,
"xbus://test:80/var/run/xbus.sock"), 0);
318 assert_int_equal(
amxb_connect(&ctx2,
"zbus://test:80/var/run/zbus.sock"), 0);
320 assert_ptr_equal(
amxb_find_uri(
"xbus://test:80/var/run/xbus.sock"), ctx1);
321 assert_ptr_equal(
amxb_find_uri(
"zbus://test:80/var/run/zbus.sock"), ctx2);
322 assert_ptr_equal(
amxb_find_uri(
"ybus://test:80/var/run/ybus.sock"), NULL);
327 assert_ptr_equal(
amxb_find_uri(
"xbus://test:80/var/run/xbus.sock"), NULL);
328 assert_ptr_equal(
amxb_find_uri(
"zbus://test:80/var/run/zbus.sock"), NULL);
329 assert_ptr_equal(
amxb_find_uri(
"ybus://test:80/var/run/ybus.sock"), NULL);
amxb_bus_ctx_t * amxb_find_uri(const char *uri)
Find the bus context for a given uri.
◆ test_amxb_get_fd()
void test_amxb_get_fd |
( |
UNUSED void ** |
state | ) |
|
Definition at line 253 of file test_amxb_ba_connect.c.
260 assert_int_equal(
amxb_connect(&ctx,
"xbus://test:80/var/run/xbus.sock"), 0);
270 assert_int_equal(
amxb_connect(&ctx,
"zbus://test:80/var/run/zbus.sock"), 0);
int amxb_get_fd(const amxb_bus_ctx_t *const ctx)
Get the connection file descriptor.
◆ test_amxb_list_uris()
void test_amxb_list_uris |
( |
UNUSED void ** |
state | ) |
|
Definition at line 336 of file test_amxb_ba_connect.c.
339 amxc_array_t* array = NULL;
343 assert_int_equal(
amxb_connect(&ctx1,
"xbus://test:80/var/run/xbus.sock"), 0);
344 assert_int_equal(
amxb_connect(&ctx2,
"zbus://test:80/var/run/zbus.sock"), 0);
347 assert_int_equal(amxc_array_size(array), 2);
348 amxc_array_delete(&array, NULL);
354 assert_int_equal(amxc_array_size(array), 0);
355 amxc_array_delete(&array, NULL);
amxc_array_t * amxb_list_uris(void)
List all open connections by their uri.
◆ test_amxb_listen()
void test_amxb_listen |
( |
UNUSED void ** |
state | ) |
|
◆ test_amxb_read()
void test_amxb_read |
( |
UNUSED void ** |
state | ) |
|
Definition at line 282 of file test_amxb_ba_connect.c.
287 assert_int_equal(
amxb_connect(&ctx,
"xbus://test:80/var/run/xbus.sock"), 0);
295 assert_ptr_equal(ctx, NULL);
297 assert_int_equal(
amxb_connect(&ctx,
"zbus://test:80/var/run/zbus.sock"), 0);
308 assert_int_not_equal(
amxb_read(NULL), 0);
int amxb_read(const amxb_bus_ctx_t *const ctx)
Reads data from the file descriptor.
◆ test_amxb_read_raw()
void test_amxb_read_raw |
( |
UNUSED void ** |
state | ) |
|
Definition at line 361 of file test_amxb_ba_connect.c.
367 assert_int_equal(
amxb_connect(&ctx,
"xbus://test:80/var/run/xbus.sock"), 0);
377 assert_ptr_equal(ctx, NULL);
379 assert_int_equal(
amxb_connect(&ctx,
"zbus://test:80/var/run/zbus.sock"), 0);
int amxb_read_raw(const amxb_bus_ctx_t *const ctx, void *buf, size_t count)
Attempts to read up to count bytes from the file descriptor into the buffer starting at buf.
◆ dummy_be1
Initial value:= {
.name = "xbus",
}
struct _amxb_be_funcs amxb_be_funcs_t
static int dummy_read_raw(void *const ctx, UNUSED void *buf, UNUSED size_t size)
static void * dummy_connect(const char *host, const char *port, const char *path, UNUSED amxp_signal_mngr_t *sigmngr)
static int dummy_get_fd(void *ctx)
static void * dummy_accept(UNUSED void *ctx, UNUSED amxp_signal_mngr_t *sigmngr)
static int dummy_disconnect(void *ctx)
static void dummy_free(void *ctx)
static int dummy_read(void *const ctx)
Definition at line 129 of file test_amxb_ba_connect.c.
◆ dummy_be2
◆ dummy_be3
◆ dummy_ctx
◆ return_val
◆ verify_host
◆ verify_path
◆ verify_port