libamxs  0.6.0
Data Model Synchronization C API
test_amxs_sync_hierarchy.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 <stdarg.h>
57 #include <stddef.h>
58 #include <string.h>
59 #include <unistd.h>
60 #include <setjmp.h>
61 #include <cmocka.h>
62 
63 #include <amxc/amxc_variant.h>
64 #include <amxc/amxc_htable.h>
65 #include <amxc/amxc_lqueue.h>
66 
67 #include <amxp/amxp_signal.h>
68 #include <amxp/amxp_slot.h>
69 
70 #include <amxd/amxd_dm.h>
71 
72 #include <amxo/amxo.h>
73 
74 #include <amxs/amxs.h>
75 
77 #include "dummy_be.h"
78 
79 #include <amxc/amxc_macros.h>
80 
81 static amxs_status_t test_trans_cb(UNUSED const amxs_sync_entry_t* entry,
82  UNUSED amxs_sync_direction_t direction,
83  UNUSED const amxc_var_t* input,
84  UNUSED amxc_var_t* output,
85  UNUSED void* priv) {
86  return amxs_status_ok;
87 }
88 
89 static amxs_status_t test_action_cb(UNUSED const amxs_sync_entry_t* entry,
90  UNUSED amxs_sync_direction_t direction,
91  UNUSED amxc_var_t* data,
92  UNUSED void* priv) {
93  return amxs_status_ok;
94 }
95 
96 void test_amxs_sync_ctx_new_args(UNUSED void** state) {
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 }
120 
121 void test_amxs_sync_ctx_new(UNUSED void** state) {
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 }
142 
143 void test_amxs_sync_ctx_init_args(UNUSED void** state) {
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 }
163 
164 void test_amxs_sync_ctx_init(UNUSED void** state) {
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 }
192 
193 void test_amxs_sync_ctx_clean(UNUSED void** state) {
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 }
202 
203 void test_amxs_sync_ctx_delete(UNUSED void** state) {
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 }
212 
213 void test_amxs_sync_object_new_args(UNUSED void** state) {
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 }
250 
251 void test_amxs_sync_object_new(UNUSED void** state) {
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 }
290 
291 void test_amxs_sync_object_delete(UNUSED void** state) {
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 }
300 
301 void test_amxs_sync_param_new_args(UNUSED void** state) {
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 }
334 
335 void test_amxs_sync_param_new(UNUSED void** state) {
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 }
374 
375 void test_amxs_sync_param_delete(UNUSED void** state) {
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 }
384 
385 void test_amxs_sync_ctx_add_param(UNUSED void** state) {
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 }
437 
438 void test_amxs_sync_ctx_add_object(UNUSED void** state) {
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 }
463 
464 void test_amxs_sync_object_add_param(UNUSED void** state) {
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 }
483 
484 void test_amxs_sync_object_add_object(UNUSED void** state) {
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 }
503 
504 void test_amxs_sync_ctx_set_dm(UNUSED void** state) {
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 }
529 
530 void test_amxs_sync_attr_update(UNUSED void** state) {
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_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.
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_ok
Definition: amxs_types.h:86
enum _amxs_sync_direction amxs_sync_direction_t
@ amxs_sync_a_to_b
Definition: amxs_types.h:80
@ amxs_sync_b_to_a
Definition: amxs_types.h:81
enum _amxs_status amxs_status_t
@ amxs_sync_type_param
Definition: amxs_types.h:102
@ amxs_sync_type_invalid
Definition: amxs_types.h:99
@ amxs_sync_type_object
Definition: amxs_types.h:101
@ amxs_sync_type_ctx
Definition: amxs_types.h:100
bool amxs_sync_entry_direction_allowed(const amxs_sync_entry_t *entry, amxs_sync_direction_t direction)
Definition: amxs_util.c:231
amxd_dm_t * test_get_dm(void)
Definition: dummy_be.c:264
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_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_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_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.
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_add_param(amxs_sync_object_t *object, amxs_sync_param_t *param)
Adds a synchronization parameter 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_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.
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.
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.
void amxs_sync_param_delete(amxs_sync_param_t **param)
Synchronization parameter destructor function.
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_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
#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_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_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.
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.
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.
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_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.
void amxs_sync_ctx_delete(amxs_sync_ctx_t **ctx)
Synchronization context destructor function.
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.
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.
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.
void amxs_sync_ctx_clean(amxs_sync_ctx_t *ctx)
Synchronization context cleanup function.
Definition: amxs_types.h:161
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
void test_amxs_sync_ctx_add_object(UNUSED void **state)
void test_amxs_sync_object_add_object(UNUSED void **state)
void test_amxs_sync_ctx_new_args(UNUSED void **state)
void test_amxs_sync_object_new(UNUSED void **state)
void test_amxs_sync_ctx_init(UNUSED void **state)
void test_amxs_sync_object_delete(UNUSED void **state)
void test_amxs_sync_param_new(UNUSED void **state)
void test_amxs_sync_ctx_clean(UNUSED void **state)
void test_amxs_sync_ctx_init_args(UNUSED void **state)
void test_amxs_sync_ctx_delete(UNUSED void **state)
void test_amxs_sync_ctx_set_dm(UNUSED void **state)
void test_amxs_sync_attr_update(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_object_add_param(UNUSED void **state)
void test_amxs_sync_param_new_args(UNUSED void **state)
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)
void test_amxs_sync_object_new_args(UNUSED void **state)
void test_amxs_sync_ctx_new(UNUSED void **state)