libamxs  0.6.0
Data Model Synchronization C API
test_amxs_sync_hierarchy.c File Reference
#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 <amxo/amxo.h>
#include <amxs/amxs.h>
#include "test_amxs_sync_hierarchy.h"
#include "dummy_be.h"
#include <amxc/amxc_macros.h>

Go to the source code of this file.

Functions

static amxs_status_t test_trans_cb (UNUSED const amxs_sync_entry_t *entry, UNUSED amxs_sync_direction_t direction, UNUSED const amxc_var_t *input, UNUSED amxc_var_t *output, UNUSED void *priv)
 
static amxs_status_t test_action_cb (UNUSED const amxs_sync_entry_t *entry, UNUSED amxs_sync_direction_t direction, UNUSED amxc_var_t *data, UNUSED void *priv)
 
void test_amxs_sync_ctx_new_args (UNUSED void **state)
 
void test_amxs_sync_ctx_new (UNUSED void **state)
 
void test_amxs_sync_ctx_init_args (UNUSED void **state)
 
void test_amxs_sync_ctx_init (UNUSED void **state)
 
void test_amxs_sync_ctx_clean (UNUSED void **state)
 
void test_amxs_sync_ctx_delete (UNUSED void **state)
 
void test_amxs_sync_object_new_args (UNUSED void **state)
 
void test_amxs_sync_object_new (UNUSED void **state)
 
void test_amxs_sync_object_delete (UNUSED void **state)
 
void test_amxs_sync_param_new_args (UNUSED void **state)
 
void test_amxs_sync_param_new (UNUSED void **state)
 
void test_amxs_sync_param_delete (UNUSED void **state)
 
void test_amxs_sync_ctx_add_param (UNUSED void **state)
 
void test_amxs_sync_ctx_add_object (UNUSED void **state)
 
void test_amxs_sync_object_add_param (UNUSED void **state)
 
void test_amxs_sync_object_add_object (UNUSED void **state)
 
void test_amxs_sync_ctx_set_dm (UNUSED void **state)
 
void test_amxs_sync_attr_update (UNUSED void **state)
 

Function Documentation

◆ test_action_cb()

static amxs_status_t test_action_cb ( UNUSED const amxs_sync_entry_t entry,
UNUSED amxs_sync_direction_t  direction,
UNUSED amxc_var_t *  data,
UNUSED void *  priv 
)
static

Definition at line 89 of file test_amxs_sync_hierarchy.c.

92  {
93  return amxs_status_ok;
94 }
@ amxs_status_ok
Definition: amxs_types.h:86

◆ test_amxs_sync_attr_update()

void test_amxs_sync_attr_update ( UNUSED void **  state)

Definition at line 530 of file test_amxs_sync_hierarchy.c.

530  {
531  amxs_sync_ctx_t* ctx = NULL;
532  amxs_sync_object_t* object = NULL;
533  amxs_sync_param_t* param = NULL;
534 
535  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_ONLY_A_TO_B), 0);
536  assert_int_equal(amxs_sync_object_new(&object, "A.", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
537  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
538 
545 
546  assert_int_equal(amxs_sync_object_add_param(object, param), 0);
551 
552  assert_int_equal(amxs_sync_ctx_add_object(ctx, object), 0);
557 
558  amxs_sync_ctx_delete(&ctx);
559 }
@ amxs_sync_a_to_b
Definition: amxs_types.h:80
@ amxs_sync_b_to_a
Definition: amxs_types.h:81
bool amxs_sync_entry_direction_allowed(const amxs_sync_entry_t *entry, amxs_sync_direction_t direction)
Definition: amxs_util.c:231
amxs_status_t amxs_sync_object_new(amxs_sync_object_t **object, const char *object_a, const char *object_b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, void *priv)
Synchronization object constructor function.
amxs_status_t amxs_sync_object_add_param(amxs_sync_object_t *object, amxs_sync_param_t *param)
Adds a synchronization parameter to a synchronization object.
amxs_status_t amxs_sync_param_new(amxs_sync_param_t **param, const char *param_a, const char *param_b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, void *priv)
Synchronization parameter constructor function.
#define AMXS_SYNC_DEFAULT
Default synchronization attributes.
Definition: amxs_types.h:190
#define AMXS_SYNC_ONLY_A_TO_B
Only synchronize from object A to object B.
Definition: amxs_types.h:200
amxs_status_t amxs_sync_ctx_new(amxs_sync_ctx_t **ctx, const char *object_a, const char *object_b, int attributes)
Synchronization context constructor function.
void amxs_sync_ctx_delete(amxs_sync_ctx_t **ctx)
Synchronization context destructor function.
amxs_status_t amxs_sync_ctx_add_object(amxs_sync_ctx_t *ctx, amxs_sync_object_t *object)
Adds a synchronization object to a synchronization context.
Definition: amxs_types.h:161
static amxs_status_t test_action_cb(UNUSED const amxs_sync_entry_t *entry, UNUSED amxs_sync_direction_t direction, UNUSED amxc_var_t *data, UNUSED void *priv)
static amxs_status_t test_trans_cb(UNUSED const amxs_sync_entry_t *entry, UNUSED amxs_sync_direction_t direction, UNUSED const amxc_var_t *input, UNUSED amxc_var_t *output, UNUSED void *priv)

◆ test_amxs_sync_ctx_add_object()

void test_amxs_sync_ctx_add_object ( UNUSED void **  state)

Definition at line 438 of file test_amxs_sync_hierarchy.c.

438  {
439  amxs_sync_ctx_t* ctx = NULL;
440  amxs_sync_object_t* object = NULL;
441 
442  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
443  assert_int_equal(amxs_sync_object_new(&object, "A.", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
444  assert_int_equal(amxs_sync_ctx_add_object(ctx, object), 0);
445  amxs_sync_ctx_delete(&ctx);
446 
447  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
448  assert_int_equal(amxs_sync_ctx_add_new_object(ctx, "A.", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
449  assert_int_not_equal(amxs_sync_ctx_add_new_object(ctx, "A.", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
450  amxs_sync_ctx_delete(&ctx);
451 
452  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
453  assert_int_equal(amxs_sync_ctx_add_new_object(ctx, "A.", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
454  assert_int_equal(amxs_sync_ctx_add_new_object(ctx, "A.", "C.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
455  assert_int_equal(amxs_sync_ctx_add_new_param(ctx, "A", "B", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
456  amxs_sync_ctx_delete(&ctx);
457 
458  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
459  assert_int_equal(amxs_sync_ctx_add_new_copy_object(ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
460  assert_int_not_equal(amxs_sync_ctx_add_new_copy_object(ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
461  amxs_sync_ctx_delete(&ctx);
462 }
amxs_status_t amxs_sync_ctx_add_new_copy_object(amxs_sync_ctx_t *ctx, const char *object_a, const char *object_b, int attributes)
Creates and adds a synchronization object to a synchronization context.
amxs_status_t amxs_sync_ctx_add_new_param(amxs_sync_ctx_t *ctx, const char *param_a, const char *param_b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, void *priv)
Creates and adds a synchronization parameter to a synchronization context.
amxs_status_t amxs_sync_ctx_add_new_object(amxs_sync_ctx_t *ctx, const char *object_a, const char *object_b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, void *priv)
Creates and adds a synchronization object to a synchronization context.

◆ test_amxs_sync_ctx_add_param()

void test_amxs_sync_ctx_add_param ( UNUSED void **  state)

Definition at line 385 of file test_amxs_sync_hierarchy.c.

385  {
386  amxs_sync_ctx_t* ctx = NULL;
387  amxs_sync_param_t* param = NULL;
388 
389  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
390  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
391  assert_int_equal(amxs_sync_ctx_add_param(ctx, param), 0);
392  assert_int_not_equal(amxs_sync_ctx_add_param(ctx, param), 0);
393  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_ONLY_A_TO_B, test_trans_cb, test_action_cb, NULL), 0);
394  assert_int_not_equal(amxs_sync_ctx_add_param(ctx, param), 0);
395  amxs_sync_param_delete(&param);
396  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B, test_trans_cb, test_action_cb, NULL), 0);
397  assert_int_not_equal(amxs_sync_ctx_add_param(ctx, param), 0);
398  amxs_sync_param_delete(&param);
399  amxs_sync_ctx_delete(&ctx);
400 
401  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
402  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_ONLY_A_TO_B, test_trans_cb, test_action_cb, NULL), 0);
403  assert_int_equal(amxs_sync_ctx_add_param(ctx, param), 0);
404  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B, test_trans_cb, test_action_cb, NULL), 0);
405  assert_int_equal(amxs_sync_ctx_add_param(ctx, param), 0);
406  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
407  assert_int_not_equal(amxs_sync_ctx_add_param(ctx, param), 0);
408  amxs_sync_param_delete(&param);
409  amxs_sync_ctx_delete(&ctx);
410 
411  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_ONLY_A_TO_B), 0);
412  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_ONLY_A_TO_B, test_trans_cb, test_action_cb, NULL), 0);
413  assert_int_equal(amxs_sync_ctx_add_param(ctx, param), 0);
414  assert_int_equal(amxs_sync_param_new(&param, "C", "B", AMXS_SYNC_ONLY_A_TO_B, test_trans_cb, test_action_cb, NULL), 0);
415  assert_int_equal(amxs_sync_ctx_add_param(ctx, param), 0);
416  assert_int_equal(amxs_sync_param_new(&param, "D", "E", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
417  assert_int_equal(amxs_sync_ctx_add_param(ctx, param), 0);
418  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B, test_trans_cb, test_action_cb, NULL), 0);
419  assert_int_not_equal(amxs_sync_ctx_add_param(ctx, param), 0);
420  amxs_sync_param_delete(&param);
421  amxs_sync_ctx_delete(&ctx);
422 
423  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
424  assert_int_equal(amxs_sync_ctx_add_new_param(ctx, "A", "B", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
425  assert_int_not_equal(amxs_sync_ctx_add_new_param(ctx, "A", "B", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
426  amxs_sync_ctx_delete(&ctx);
427 
428  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B), 0);
429  assert_int_not_equal(amxs_sync_ctx_add_new_param(ctx, "A", "B", AMXS_SYNC_ONLY_A_TO_B, test_trans_cb, test_action_cb, NULL), 0);
430  amxs_sync_ctx_delete(&ctx);
431 
432  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
433  assert_int_equal(amxs_sync_ctx_add_new_copy_param(ctx, "A", "B", AMXS_SYNC_DEFAULT), 0);
434  assert_int_not_equal(amxs_sync_ctx_add_new_copy_param(ctx, "A", "B", AMXS_SYNC_DEFAULT), 0);
435  amxs_sync_ctx_delete(&ctx);
436 }
void amxs_sync_param_delete(amxs_sync_param_t **param)
Synchronization parameter destructor function.
#define AMXS_SYNC_INIT_B
Take the initial values from object B.
Definition: amxs_types.h:205
#define AMXS_SYNC_ONLY_B_TO_A
Only synchronize from object B to object A.
Definition: amxs_types.h:195
amxs_status_t amxs_sync_ctx_add_param(amxs_sync_ctx_t *ctx, amxs_sync_param_t *param)
Adds a synchronization parameter to a synchronization context.
amxs_status_t amxs_sync_ctx_add_new_copy_param(amxs_sync_ctx_t *ctx, const char *param_a, const char *param_b, int attributes)
Creates and adds a synchronization parameter to a synchronization context.

◆ test_amxs_sync_ctx_clean()

void test_amxs_sync_ctx_clean ( UNUSED void **  state)

Definition at line 193 of file test_amxs_sync_hierarchy.c.

193  {
194  amxs_sync_ctx_t ctx;
195 
196  assert_int_equal(amxs_sync_ctx_init(&ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
197 
198  amxs_sync_ctx_clean(NULL);
199  amxs_sync_ctx_clean(&ctx);
200  amxs_sync_ctx_clean(&ctx);
201 }
amxs_status_t amxs_sync_ctx_init(amxs_sync_ctx_t *ctx, const char *object_a, const char *object_b, int attributes)
Synchronization context initialization function.
void amxs_sync_ctx_clean(amxs_sync_ctx_t *ctx)
Synchronization context cleanup function.

◆ test_amxs_sync_ctx_delete()

void test_amxs_sync_ctx_delete ( UNUSED void **  state)

Definition at line 203 of file test_amxs_sync_hierarchy.c.

203  {
204  amxs_sync_ctx_t* ctx = NULL;
205 
206  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
207 
208  amxs_sync_ctx_delete(NULL);
209  amxs_sync_ctx_delete(&ctx);
210  amxs_sync_ctx_delete(&ctx);
211 }

◆ test_amxs_sync_ctx_init()

void test_amxs_sync_ctx_init ( UNUSED void **  state)

Definition at line 164 of file test_amxs_sync_hierarchy.c.

164  {
165  amxs_sync_ctx_t ctx;
166 
167  assert_int_equal(amxs_sync_ctx_init(&ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
168  assert_string_equal(ctx.a, "A.");
169  assert_string_equal(ctx.b, "B.");
170  assert_int_equal(ctx.attributes, AMXS_SYNC_DEFAULT);
171  assert_int_equal(ctx.type, amxs_sync_type_ctx);
172  assert_ptr_equal(ctx.action_cb, NULL);
173  assert_ptr_equal(ctx.translation_cb, NULL);
174  assert_ptr_equal(ctx.priv, NULL);
175  assert_ptr_equal(ctx.bus_ctx_a, NULL);
176  assert_ptr_equal(ctx.bus_ctx_b, NULL);
177  assert_true(amxc_llist_is_empty(&ctx.entries));
178  assert_true(amxc_llist_is_empty(&ctx.subscriptions));
179  assert_ptr_equal(ctx.it.llist, NULL);
180 
181  amxs_sync_ctx_clean(&ctx);
182  assert_ptr_equal(ctx.a, NULL);
183  assert_ptr_equal(ctx.b, NULL);
184  assert_int_equal(ctx.attributes, 0);
185  assert_int_equal(ctx.type, amxs_sync_type_invalid);
186  assert_ptr_equal(ctx.action_cb, NULL);
187  assert_ptr_equal(ctx.translation_cb, NULL);
188  assert_ptr_equal(ctx.priv, NULL);
189  assert_ptr_equal(ctx.bus_ctx_a, NULL);
190  assert_ptr_equal(ctx.bus_ctx_b, NULL);
191 }
@ amxs_sync_type_invalid
Definition: amxs_types.h:99
@ amxs_sync_type_ctx
Definition: amxs_types.h:100
char * a
Definition: amxs_types.h:163
amxs_sync_entry_type_t type
Definition: amxs_types.h:170
amxc_llist_it_t it
Definition: amxs_types.h:162
void * priv
Definition: amxs_types.h:168
amxb_bus_ctx_t * bus_ctx_a
Definition: amxs_types.h:171
amxs_translation_cb_t translation_cb
Definition: amxs_types.h:167
amxc_llist_t subscriptions
Definition: amxs_types.h:173
amxs_action_cb_t action_cb
Definition: amxs_types.h:166
int attributes
Definition: amxs_types.h:165
char * b
Definition: amxs_types.h:164
amxc_llist_t entries
Definition: amxs_types.h:169
amxb_bus_ctx_t * bus_ctx_b
Definition: amxs_types.h:172

◆ test_amxs_sync_ctx_init_args()

void test_amxs_sync_ctx_init_args ( UNUSED void **  state)

Definition at line 143 of file test_amxs_sync_hierarchy.c.

143  {
144  amxs_sync_ctx_t ctx;
145 
146  assert_int_not_equal(amxs_sync_ctx_init(&ctx, NULL, NULL, AMXS_SYNC_DEFAULT), 0);
147  assert_int_not_equal(amxs_sync_ctx_init(NULL, NULL, NULL, AMXS_SYNC_DEFAULT), 0);
148  assert_int_not_equal(amxs_sync_ctx_init(&ctx, "A.", NULL, AMXS_SYNC_DEFAULT), 0);
149  assert_int_not_equal(amxs_sync_ctx_init(&ctx, NULL, "B.", AMXS_SYNC_DEFAULT), 0);
150  assert_int_not_equal(amxs_sync_ctx_init(&ctx, "A", "B.", AMXS_SYNC_DEFAULT), 0);
151  assert_int_not_equal(amxs_sync_ctx_init(&ctx, "A.", "B", AMXS_SYNC_DEFAULT), 0);
152  assert_int_not_equal(amxs_sync_ctx_init(&ctx, "A.", "B.", AMXS_SYNC_ONLY_A_TO_B | AMXS_SYNC_ONLY_B_TO_A), 0);
153  assert_int_not_equal(amxs_sync_ctx_init(&ctx, "A.", "B.", AMXS_SYNC_ONLY_A_TO_B | AMXS_SYNC_INIT_B), 0);
154  assert_int_not_equal(amxs_sync_ctx_init(&ctx, "A.", "B.", AMXS_SYNC_ONLY_B_TO_A), 0);
155  assert_int_equal(amxs_sync_ctx_init(&ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
156  amxs_sync_ctx_clean(&ctx);
157  assert_int_equal(amxs_sync_ctx_init(&ctx, "A.", NULL, AMXS_SYNC_ONLY_A_TO_B), 0);
158  amxs_sync_ctx_clean(&ctx);
159  assert_int_not_equal(amxs_sync_ctx_init(&ctx, NULL, "B.", AMXS_SYNC_ONLY_B_TO_A), 0);
160  assert_int_equal(amxs_sync_ctx_init(&ctx, NULL, "B.", AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B), 0);
161  amxs_sync_ctx_clean(&ctx);
162 }

◆ test_amxs_sync_ctx_new()

void test_amxs_sync_ctx_new ( UNUSED void **  state)

Definition at line 121 of file test_amxs_sync_hierarchy.c.

121  {
122  amxs_sync_ctx_t* ctx = NULL;
123 
124  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
125  assert_ptr_not_equal(ctx, NULL);
126  assert_string_equal(ctx->a, "A.");
127  assert_string_equal(ctx->b, "B.");
128  assert_int_equal(ctx->attributes, AMXS_SYNC_DEFAULT);
129  assert_int_equal(ctx->type, amxs_sync_type_ctx);
130  assert_ptr_equal(ctx->action_cb, NULL);
131  assert_ptr_equal(ctx->translation_cb, NULL);
132  assert_ptr_equal(ctx->priv, NULL);
133  assert_ptr_equal(ctx->bus_ctx_a, NULL);
134  assert_ptr_equal(ctx->bus_ctx_b, NULL);
135  assert_true(amxc_llist_is_empty(&ctx->entries));
136  assert_true(amxc_llist_is_empty(&ctx->subscriptions));
137  assert_ptr_equal(ctx->it.llist, NULL);
138 
139  amxs_sync_ctx_delete(&ctx);
140  assert_ptr_equal(ctx, NULL);
141 }

◆ test_amxs_sync_ctx_new_args()

void test_amxs_sync_ctx_new_args ( UNUSED void **  state)

Definition at line 96 of file test_amxs_sync_hierarchy.c.

96  {
97  amxs_sync_ctx_t* ctx = NULL;
98 
99  assert_int_not_equal(amxs_sync_ctx_new(&ctx, NULL, NULL, AMXS_SYNC_DEFAULT), 0);
100  assert_ptr_equal(ctx, NULL);
101  assert_int_not_equal(amxs_sync_ctx_new(NULL, NULL, NULL, AMXS_SYNC_DEFAULT), 0);
102  assert_ptr_equal(ctx, NULL);
103  assert_int_not_equal(amxs_sync_ctx_new(&ctx, "A.", NULL, AMXS_SYNC_DEFAULT), 0);
104  assert_ptr_equal(ctx, NULL);
105  assert_int_not_equal(amxs_sync_ctx_new(&ctx, NULL, "B.", AMXS_SYNC_DEFAULT), 0);
106  assert_ptr_equal(ctx, NULL);
107  assert_int_not_equal(amxs_sync_ctx_new(&ctx, "A", "B.", AMXS_SYNC_DEFAULT), 0);
108  assert_ptr_equal(ctx, NULL);
109  assert_int_not_equal(amxs_sync_ctx_new(&ctx, "A.", "B", AMXS_SYNC_DEFAULT), 0);
110  assert_ptr_equal(ctx, NULL);
111  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
112  amxs_sync_ctx_delete(&ctx);
113  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", NULL, AMXS_SYNC_ONLY_A_TO_B), 0);
114  amxs_sync_ctx_delete(&ctx);
115  assert_int_not_equal(amxs_sync_ctx_new(&ctx, NULL, "B.", AMXS_SYNC_ONLY_B_TO_A), 0);
116  assert_ptr_equal(ctx, NULL);
117  assert_int_equal(amxs_sync_ctx_new(&ctx, NULL, "B.", AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B), 0);
118  amxs_sync_ctx_delete(&ctx);
119 }

◆ test_amxs_sync_ctx_set_dm()

void test_amxs_sync_ctx_set_dm ( UNUSED void **  state)

Definition at line 504 of file test_amxs_sync_hierarchy.c.

504  {
505  amxs_sync_ctx_t* ctx = NULL;
506  amxd_dm_t* dm = test_get_dm();
507 
508  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_DEFAULT), 0);
509  assert_int_equal(amxs_sync_ctx_set_local_dm(ctx, dm, dm), 0);
510  assert_int_equal(amxs_sync_ctx_set_local_dm(ctx, NULL, dm), 0);
511  assert_int_equal(amxs_sync_ctx_set_local_dm(ctx, dm, NULL), 0);
512  assert_int_equal(amxs_sync_ctx_set_local_dm(ctx, NULL, NULL), 0);
513  amxs_sync_ctx_delete(&ctx);
514 
515  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_ONLY_A_TO_B), 0);
516  assert_int_not_equal(amxs_sync_ctx_set_local_dm(ctx, dm, dm), 0);
517  assert_int_equal(amxs_sync_ctx_set_local_dm(ctx, NULL, dm), 0);
518  assert_int_not_equal(amxs_sync_ctx_set_local_dm(ctx, dm, NULL), 0);
519  assert_int_equal(amxs_sync_ctx_set_local_dm(ctx, NULL, NULL), 0);
520  amxs_sync_ctx_delete(&ctx);
521 
522  assert_int_equal(amxs_sync_ctx_new(&ctx, "A.", "B.", AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B), 0);
523  assert_int_not_equal(amxs_sync_ctx_set_local_dm(ctx, dm, dm), 0);
524  assert_int_not_equal(amxs_sync_ctx_set_local_dm(ctx, NULL, dm), 0);
525  assert_int_equal(amxs_sync_ctx_set_local_dm(ctx, dm, NULL), 0);
526  assert_int_equal(amxs_sync_ctx_set_local_dm(ctx, NULL, NULL), 0);
527  amxs_sync_ctx_delete(&ctx);
528 }
amxs_status_t amxs_sync_ctx_set_local_dm(amxs_sync_ctx_t *ctx, amxd_dm_t *dm_a, amxd_dm_t *dm_b)
Set the local datamodel pointer for the sync root objects.
amxd_dm_t * test_get_dm(void)
Definition: dummy_be.c:264

◆ test_amxs_sync_object_add_object()

void test_amxs_sync_object_add_object ( UNUSED void **  state)

Definition at line 484 of file test_amxs_sync_hierarchy.c.

484  {
485  amxs_sync_object_t* parent = NULL;
486  amxs_sync_object_t* child = NULL;
487 
488  assert_int_equal(amxs_sync_object_new(&parent, "A.", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
489  assert_int_equal(amxs_sync_object_new(&child, "C.", "D.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
490  assert_int_equal(amxs_sync_object_add_object(parent, child), 0);
491  amxs_sync_object_delete(&parent);
492 
493  assert_int_equal(amxs_sync_object_new(&parent, "A.", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
494  assert_int_equal(amxs_sync_object_add_new_object(parent, "C.", "D.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
495  assert_int_not_equal(amxs_sync_object_add_new_object(parent, "C.", "D.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
496  amxs_sync_object_delete(&parent);
497 
498  assert_int_equal(amxs_sync_object_new(&parent, "A.", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
499  assert_int_equal(amxs_sync_object_add_new_copy_object(parent, "C.", "D.", AMXS_SYNC_DEFAULT), 0);
500  assert_int_not_equal(amxs_sync_object_add_new_copy_object(parent, "C.", "D.", AMXS_SYNC_DEFAULT), 0);
501  amxs_sync_object_delete(&parent);
502 }
amxs_status_t amxs_sync_object_add_new_copy_object(amxs_sync_object_t *parent, const char *object_a, const char *object_b, int attributes)
Creates and adds a synchronization object to a synchronization object.
amxs_status_t amxs_sync_object_add_new_object(amxs_sync_object_t *parent, const char *object_a, const char *object_b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, void *priv)
Creates and adds a synchronization object to a synchronization object.
void amxs_sync_object_delete(amxs_sync_object_t **object)
Synchronization object destructor function.
amxs_status_t amxs_sync_object_add_object(amxs_sync_object_t *parent, amxs_sync_object_t *child)
Adds a synchronization object to a synchronization object.

◆ test_amxs_sync_object_add_param()

void test_amxs_sync_object_add_param ( UNUSED void **  state)

Definition at line 464 of file test_amxs_sync_hierarchy.c.

464  {
465  amxs_sync_object_t* object = NULL;
466  amxs_sync_param_t* param = NULL;
467 
468  assert_int_equal(amxs_sync_object_new(&object, "A.", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
469  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
470  assert_int_equal(amxs_sync_object_add_param(object, param), 0);
471  amxs_sync_object_delete(&object);
472 
473  assert_int_equal(amxs_sync_object_new(&object, "A.", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
474  assert_int_equal(amxs_sync_object_add_new_param(object, "A", "B", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
475  assert_int_not_equal(amxs_sync_object_add_new_param(object, "A", "B", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
476  amxs_sync_object_delete(&object);
477 
478  assert_int_equal(amxs_sync_object_new(&object, "A.", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
479  assert_int_equal(amxs_sync_object_add_new_copy_param(object, "A", "B", AMXS_SYNC_DEFAULT), 0);
480  assert_int_not_equal(amxs_sync_object_add_new_copy_param(object, "A", "B", AMXS_SYNC_DEFAULT), 0);
481  amxs_sync_object_delete(&object);
482 }
amxs_status_t amxs_sync_object_add_new_copy_param(amxs_sync_object_t *object, const char *param_a, const char *param_b, int attributes)
Creates and adds a synchronization parameter to a synchronization object.
amxs_status_t amxs_sync_object_add_new_param(amxs_sync_object_t *object, const char *param_a, const char *param_b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, void *priv)
Creates and adds a synchronization parameter to a synchronization object.

◆ test_amxs_sync_object_delete()

void test_amxs_sync_object_delete ( UNUSED void **  state)

Definition at line 291 of file test_amxs_sync_hierarchy.c.

291  {
292  amxs_sync_object_t* object = NULL;
293 
294  assert_int_equal(amxs_sync_object_new(&object, "A.", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
295 
297  amxs_sync_object_delete(&object);
298  amxs_sync_object_delete(&object);
299 }

◆ test_amxs_sync_object_new()

void test_amxs_sync_object_new ( UNUSED void **  state)

Definition at line 251 of file test_amxs_sync_hierarchy.c.

251  {
252  amxs_sync_object_t* object = NULL;
253 
254  assert_int_equal(amxs_sync_object_new(&object, "A.", "B.", AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B, test_trans_cb, test_action_cb, NULL), 0);
255  assert_ptr_not_equal(object, NULL);
256  assert_string_equal(object->a, "A.");
257  assert_string_equal(object->b, "B.");
258  assert_int_equal(object->attributes, AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B);
259  assert_int_equal(object->type, amxs_sync_type_object);
260  assert_ptr_equal(object->action_cb, test_action_cb);
261  assert_ptr_equal(object->translation_cb, test_trans_cb);
262  assert_ptr_equal(object->priv, NULL);
263  assert_ptr_equal(object->bus_ctx_a, NULL);
264  assert_ptr_equal(object->bus_ctx_b, NULL);
265  assert_true(amxc_llist_is_empty(&object->entries));
266  assert_true(amxc_llist_is_empty(&object->subscriptions));
267  assert_ptr_equal(object->it.llist, NULL);
268 
269  amxs_sync_object_delete(&object);
270  assert_ptr_equal(object, NULL);
271 
272  assert_int_equal(amxs_sync_object_new_copy(&object, "A.", "B.", AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B), 0);
273  assert_ptr_not_equal(object, NULL);
274  assert_string_equal(object->a, "A.");
275  assert_string_equal(object->b, "B.");
276  assert_int_equal(object->attributes, AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B);
277  assert_int_equal(object->type, amxs_sync_type_object);
278  assert_ptr_equal(object->action_cb, amxs_sync_object_copy_action_cb);
279  assert_ptr_equal(object->translation_cb, amxs_sync_object_copy_trans_cb);
280  assert_ptr_equal(object->priv, NULL);
281  assert_ptr_equal(object->bus_ctx_a, NULL);
282  assert_ptr_equal(object->bus_ctx_b, NULL);
283  assert_true(amxc_llist_is_empty(&object->entries));
284  assert_true(amxc_llist_is_empty(&object->subscriptions));
285  assert_ptr_equal(object->it.llist, NULL);
286 
287  amxs_sync_object_delete(&object);
288  assert_ptr_equal(object, NULL);
289 }
@ amxs_sync_type_object
Definition: amxs_types.h:101
amxs_status_t amxs_sync_object_new_copy(amxs_sync_object_t **object, const char *object_a, const char *object_b, int attributes)
Synchronization object constructor function.
amxs_status_t amxs_sync_object_copy_trans_cb(const amxs_sync_entry_t *entry, amxs_sync_direction_t direction, const amxc_var_t *input, amxc_var_t *output, void *priv)
Translates data from a dm:instance-added or dm:instance-removed event to data suited for an amxb call...
amxs_status_t amxs_sync_object_copy_action_cb(const amxs_sync_entry_t *entry, amxs_sync_direction_t direction, amxc_var_t *data, void *priv)
Adds, removes or updates an object with the given data using an amxb call.

◆ test_amxs_sync_object_new_args()

void test_amxs_sync_object_new_args ( UNUSED void **  state)

Definition at line 213 of file test_amxs_sync_hierarchy.c.

213  {
214  amxs_sync_object_t* object = NULL;
215 
216  assert_int_not_equal(amxs_sync_object_new(NULL, "A.", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
217  assert_ptr_equal(object, NULL);
218  assert_int_not_equal(amxs_sync_object_new(&object, "A", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
219  assert_ptr_equal(object, NULL);
220  assert_int_not_equal(amxs_sync_object_new(&object, "A.", "B", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
221  assert_ptr_equal(object, NULL);
222  assert_int_not_equal(amxs_sync_object_new(&object, "A.", NULL, AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
223  assert_ptr_equal(object, NULL);
224  assert_int_not_equal(amxs_sync_object_new(&object, NULL, "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
225  assert_ptr_equal(object, NULL);
226  assert_int_not_equal(amxs_sync_object_new(&object, "A.", NULL, AMXS_SYNC_ONLY_B_TO_A, test_trans_cb, test_action_cb, NULL), 0);
227  assert_ptr_equal(object, NULL);
228  assert_int_not_equal(amxs_sync_object_new(&object, NULL, "B.", AMXS_SYNC_ONLY_A_TO_B, test_trans_cb, test_action_cb, NULL), 0);
229  assert_ptr_equal(object, NULL);
230  assert_int_not_equal(amxs_sync_object_new(&object, NULL, "B.", AMXS_SYNC_ONLY_B_TO_A, test_trans_cb, test_action_cb, NULL), 0);
231  assert_ptr_equal(object, NULL);
232 
233  assert_int_equal(amxs_sync_object_new(&object, NULL, "B.", AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B, test_trans_cb, test_action_cb, NULL), 0);
234  amxs_sync_object_delete(&object);
235  assert_int_equal(amxs_sync_object_new(&object, "A.", "B.", AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B, test_trans_cb, test_action_cb, NULL), 0);
236  amxs_sync_object_delete(&object);
237  assert_int_equal(amxs_sync_object_new(&object, "A.", "B.", AMXS_SYNC_ONLY_A_TO_B, test_trans_cb, test_action_cb, NULL), 0);
238  amxs_sync_object_delete(&object);
239  assert_int_equal(amxs_sync_object_new(&object, "A.", "B.", AMXS_SYNC_DEFAULT, NULL, test_action_cb, NULL), 0);
240  amxs_sync_object_delete(&object);
241  assert_int_equal(amxs_sync_object_new(&object, "A.", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, NULL, NULL), 0);
242  amxs_sync_object_delete(&object);
243  assert_int_equal(amxs_sync_object_new(&object, "A.", "B.", AMXS_SYNC_DEFAULT, NULL, NULL, NULL), 0);
244  amxs_sync_object_delete(&object);
245  assert_int_equal(amxs_sync_object_new(&object, "A.", "B.", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
246  amxs_sync_object_delete(&object);
247  assert_int_equal(amxs_sync_object_new(&object, "A.", "B.", AMXS_SYNC_DEFAULT | AMXS_SYNC_INIT_B, test_trans_cb, test_action_cb, NULL), 0);
248  amxs_sync_object_delete(&object);
249 }

◆ test_amxs_sync_param_delete()

void test_amxs_sync_param_delete ( UNUSED void **  state)

Definition at line 375 of file test_amxs_sync_hierarchy.c.

375  {
376  amxs_sync_param_t* param = NULL;
377 
378  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
379 
381  amxs_sync_param_delete(&param);
382  amxs_sync_param_delete(&param);
383 }

◆ test_amxs_sync_param_new()

void test_amxs_sync_param_new ( UNUSED void **  state)

Definition at line 335 of file test_amxs_sync_hierarchy.c.

335  {
336  amxs_sync_param_t* param = NULL;
337 
338  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B, test_trans_cb, test_action_cb, NULL), 0);
339  assert_ptr_not_equal(param, NULL);
340  assert_string_equal(param->a, "A");
341  assert_string_equal(param->b, "B");
342  assert_int_equal(param->attributes, AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B);
343  assert_int_equal(param->type, amxs_sync_type_param);
344  assert_ptr_equal(param->action_cb, test_action_cb);
345  assert_ptr_equal(param->translation_cb, test_trans_cb);
346  assert_ptr_equal(param->priv, NULL);
347  assert_ptr_equal(param->bus_ctx_a, NULL);
348  assert_ptr_equal(param->bus_ctx_b, NULL);
349  assert_true(amxc_llist_is_empty(&param->entries));
350  assert_true(amxc_llist_is_empty(&param->subscriptions));
351  assert_ptr_equal(param->it.llist, NULL);
352 
353  amxs_sync_param_delete(&param);
354  assert_ptr_equal(param, NULL);
355 
356  assert_int_equal(amxs_sync_param_new_copy(&param, "A", "B", AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B), 0);
357  assert_ptr_not_equal(param, NULL);
358  assert_string_equal(param->a, "A");
359  assert_string_equal(param->b, "B");
360  assert_int_equal(param->attributes, AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B);
361  assert_int_equal(param->type, amxs_sync_type_param);
362  assert_ptr_equal(param->action_cb, amxs_sync_param_copy_action_cb);
363  assert_ptr_equal(param->translation_cb, amxs_sync_param_copy_trans_cb);
364  assert_ptr_equal(param->priv, NULL);
365  assert_ptr_equal(param->bus_ctx_a, NULL);
366  assert_ptr_equal(param->bus_ctx_b, NULL);
367  assert_true(amxc_llist_is_empty(&param->entries));
368  assert_true(amxc_llist_is_empty(&param->subscriptions));
369  assert_ptr_equal(param->it.llist, NULL);
370 
371  amxs_sync_param_delete(&param);
372  assert_ptr_equal(param, NULL);
373 }
@ amxs_sync_type_param
Definition: amxs_types.h:102
amxs_status_t amxs_sync_param_new_copy(amxs_sync_param_t **param, const char *param_a, const char *param_b, int attributes)
Synchronization parameter constructor function.
amxs_status_t amxs_sync_param_copy_trans_cb(const amxs_sync_entry_t *entry, amxs_sync_direction_t direction, const amxc_var_t *input, amxc_var_t *output, void *priv)
Translates data from a dm:object-changed event to data suited for an amxb_set call for a single param...
amxs_status_t amxs_sync_param_copy_action_cb(const amxs_sync_entry_t *entry, amxs_sync_direction_t direction, amxc_var_t *data, void *priv)
Sets the new parameter value.

◆ test_amxs_sync_param_new_args()

void test_amxs_sync_param_new_args ( UNUSED void **  state)

Definition at line 301 of file test_amxs_sync_hierarchy.c.

301  {
302  amxs_sync_param_t* param = NULL;
303 
304  assert_int_not_equal(amxs_sync_param_new(NULL, "A", "B", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
305  assert_ptr_equal(param, NULL);
306  assert_int_not_equal(amxs_sync_param_new(&param, "A", NULL, AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
307  assert_ptr_equal(param, NULL);
308  assert_int_not_equal(amxs_sync_param_new(&param, NULL, "B", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
309  assert_ptr_equal(param, NULL);
310  assert_int_not_equal(amxs_sync_param_new(&param, "A", NULL, AMXS_SYNC_ONLY_B_TO_A, test_trans_cb, test_action_cb, NULL), 0);
311  assert_ptr_equal(param, NULL);
312  assert_int_not_equal(amxs_sync_param_new(&param, NULL, "B", AMXS_SYNC_ONLY_A_TO_B, test_trans_cb, test_action_cb, NULL), 0);
313  assert_ptr_equal(param, NULL);
314  assert_int_not_equal(amxs_sync_param_new(&param, NULL, "B", AMXS_SYNC_ONLY_B_TO_A, test_trans_cb, test_action_cb, NULL), 0);
315  assert_ptr_equal(param, NULL);
316 
317  assert_int_equal(amxs_sync_param_new(&param, NULL, "B", AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B, test_trans_cb, test_action_cb, NULL), 0);
318  amxs_sync_param_delete(&param);
319  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_ONLY_B_TO_A | AMXS_SYNC_INIT_B, test_trans_cb, test_action_cb, NULL), 0);
320  amxs_sync_param_delete(&param);
321  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_ONLY_A_TO_B, test_trans_cb, test_action_cb, NULL), 0);
322  amxs_sync_param_delete(&param);
323  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_DEFAULT, NULL, test_action_cb, NULL), 0);
324  amxs_sync_param_delete(&param);
325  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_DEFAULT, test_trans_cb, NULL, NULL), 0);
326  amxs_sync_param_delete(&param);
327  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_DEFAULT, NULL, NULL, NULL), 0);
328  amxs_sync_param_delete(&param);
329  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_DEFAULT, test_trans_cb, test_action_cb, NULL), 0);
330  amxs_sync_param_delete(&param);
331  assert_int_equal(amxs_sync_param_new(&param, "A", "B", AMXS_SYNC_DEFAULT | AMXS_SYNC_INIT_B, test_trans_cb, test_action_cb, NULL), 0);
332  amxs_sync_param_delete(&param);
333 }

◆ test_trans_cb()

static amxs_status_t test_trans_cb ( UNUSED const amxs_sync_entry_t entry,
UNUSED amxs_sync_direction_t  direction,
UNUSED const amxc_var_t *  input,
UNUSED amxc_var_t *  output,
UNUSED void *  priv 
)
static

Definition at line 81 of file test_amxs_sync_hierarchy.c.

85  {
86  return amxs_status_ok;
87 }