libamxd  6.4.1
Data Model Manager
test_amxd_object_hierarchy.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <cmocka.h>
#include <amxc/amxc.h>
#include <amxp/amxp_signal.h>
#include <amxp/amxp_slot.h>
#include <amxd/amxd_dm.h>
#include <amxd/amxd_object.h>
#include "test_amxd_object.h"
#include <amxc/amxc_macros.h>

Go to the source code of this file.

Functions

void test_amxd_object_add_object (UNUSED void **state)
 
void test_amxd_object_add_object_invalid_args (UNUSED void **state)
 
void test_amxd_object_get_parent (UNUSED void **state)
 
void test_amxd_object_get_root (UNUSED void **state)
 
void test_amxd_object_get_dm (UNUSED void **state)
 
void test_amxd_object_get_child (UNUSED void **state)
 
void test_amxd_object_get_instance (UNUSED void **state)
 
void test_amxd_object_get_instance_difficult_alias_name (UNUSED void **state)
 
void test_amxd_object_get (UNUSED void **state)
 
void test_amxd_object_find (UNUSED void **state)
 
void test_amxd_object_findf (UNUSED void **state)
 
void test_amxd_object_get_path (UNUSED void **state)
 
static void check_path_down (amxd_object_t *const object, UNUSED int32_t depth, void *priv)
 
static void check_path_up (amxd_object_t *const object, UNUSED int32_t depth, void *priv)
 
void test_amxd_object_walk (UNUSED void **state)
 
static bool no_tempate_child_objects (amxd_object_t *const object, UNUSED int32_t depth, void *priv)
 
static bool no_root_objects (amxd_object_t *const object, UNUSED int32_t depth, void *priv)
 
static void check_path_down_filtered (amxd_object_t *const object, UNUSED int32_t depth, void *priv)
 
void test_amxd_object_walk_filtered (UNUSED void **state)
 
static void check_path_down_depth (amxd_object_t *const object, UNUSED int32_t depth, void *priv)
 
static void check_path_up_depth (amxd_object_t *const object, UNUSED int32_t depth, void *priv)
 
void test_amxd_object_walk_depth (UNUSED void **state)
 
void test_amxd_object_walk_invalid_args (UNUSED void **state)
 
void test_amxd_object_is_child_of (UNUSED void **state)
 

Variables

static amxd_dm_t dm
 
static int pos = 0
 
static char * expected_paths_down []
 
static char * expected_paths_up []
 
static char * expected_paths_down_filtered []
 
static char * expected_paths_down_depth []
 
static char * expected_paths_up_depth []
 

Function Documentation

◆ check_path_down()

static void check_path_down ( amxd_object_t *const  object,
UNUSED int32_t  depth,
void *  priv 
)
static

Definition at line 631 of file test_amxd_object_hierarchy.c.

633  {
635  assert_ptr_equal(priv, NULL);
636 
637  printf("%s == %s?\n", expected_paths_down[pos], path);
638 
639  if(path == NULL) {
640  assert_ptr_equal(expected_paths_down[pos], NULL);
641  } else {
642  assert_string_equal(path, expected_paths_down[pos]);
643  }
644  free(path);
645  pos++;
646 }
#define AMXD_OBJECT_NAMED
Name and path format flag - default behavior, use name for instance objects.
Definition: amxd_object.h:164
#define AMXD_OBJECT_EXTENDED
Path format flag - set name or index of instrance objects between '[' and ']'.
Definition: amxd_object.h:188
amxd_object_t amxd_status_t amxd_status_t char * amxd_object_get_path(const amxd_object_t *object, const uint32_t flags)
Get the full path of the object.
static int pos
static char * expected_paths_down[]

◆ check_path_down_depth()

static void check_path_down_depth ( amxd_object_t *const  object,
UNUSED int32_t  depth,
void *  priv 
)
static

Definition at line 800 of file test_amxd_object_hierarchy.c.

802  {
803  char* path = amxd_object_get_path(object, AMXD_OBJECT_NAMED);
804  assert_ptr_equal(priv, NULL);
805 
806  printf("%s == %s?\n", expected_paths_down_depth[pos], path);
807 
808  if(path == NULL) {
809  assert_ptr_equal(expected_paths_down_depth[pos], NULL);
810  } else {
811  assert_string_equal(path, expected_paths_down_depth[pos]);
812  }
813  free(path);
814  pos++;
815 }
static char * expected_paths_down_depth[]

◆ check_path_down_filtered()

static void check_path_down_filtered ( amxd_object_t *const  object,
UNUSED int32_t  depth,
void *  priv 
)
static

Definition at line 744 of file test_amxd_object_hierarchy.c.

746  {
747  char* path = amxd_object_get_path(object, AMXD_OBJECT_NAMED);
748  assert_ptr_equal(priv, NULL);
749 
750  printf("%s == %s?\n", expected_paths_down_filtered[pos], path);
751 
752  if(path == NULL) {
753  assert_ptr_equal(expected_paths_down_filtered[pos], NULL);
754  } else {
755  assert_string_equal(path, expected_paths_down_filtered[pos]);
756  }
757  free(path);
758  pos++;
759 }
static char * expected_paths_down_filtered[]

◆ check_path_up()

static void check_path_up ( amxd_object_t *const  object,
UNUSED int32_t  depth,
void *  priv 
)
static

Definition at line 655 of file test_amxd_object_hierarchy.c.

657  {
659  assert_ptr_equal(priv, NULL);
660 
661  printf("%s == %s?\n", expected_paths_up[pos], path);
662 
663  if(path == NULL) {
664  assert_ptr_equal(expected_paths_up[pos], NULL);
665  } else {
666  assert_string_equal(path, expected_paths_up[pos]);
667  }
668  free(path);
669  pos++;
670 }
static char * expected_paths_up[]

◆ check_path_up_depth()

static void check_path_up_depth ( amxd_object_t *const  object,
UNUSED int32_t  depth,
void *  priv 
)
static

Definition at line 822 of file test_amxd_object_hierarchy.c.

824  {
826  assert_ptr_equal(priv, NULL);
827 
828  printf("%s == %s?\n", expected_paths_up_depth[pos], path);
829 
830  if(path == NULL) {
831  assert_ptr_equal(expected_paths_up_depth[pos], NULL);
832  } else {
833  assert_string_equal(path, expected_paths_up_depth[pos]);
834  }
835  free(path);
836  pos++;
837 }
#define AMXD_OBJECT_INDEXED
Name and path format flag - use index for instance objects.
Definition: amxd_object.h:176
static char * expected_paths_up_depth[]

◆ no_root_objects()

static bool no_root_objects ( amxd_object_t *const  object,
UNUSED int32_t  depth,
void *  priv 
)
static

Definition at line 737 of file test_amxd_object_hierarchy.c.

739  {
740  assert_ptr_equal(priv, NULL);
741  return object->type != amxd_object_root;
742 }
@ amxd_object_root
Definition: amxd_types.h:178

◆ no_tempate_child_objects()

static bool no_tempate_child_objects ( amxd_object_t *const  object,
UNUSED int32_t  depth,
void *  priv 
)
static

Definition at line 719 of file test_amxd_object_hierarchy.c.

721  {
722  assert_ptr_equal(priv, NULL);
723  if((object->type == amxd_object_instance) ||
724  ( object->type == amxd_object_template) ||
725  ( object->type == amxd_object_root)) {
726  return true;
727  }
728 
729  if((amxd_object_get_parent(object) != NULL) &&
730  ( amxd_object_get_parent(object)->type != amxd_object_template)) {
731  return true;
732  }
733 
734  return false;
735 }
@ amxd_object_template
Definition: amxd_types.h:183
@ amxd_object_instance
Definition: amxd_types.h:186
amxd_object_t * amxd_object_get_parent(const amxd_object_t *const object)
Get the parent object.
amxd_object_type_t type
Definition: amxd_types.h:236

◆ test_amxd_object_add_object()

void test_amxd_object_add_object ( UNUSED void **  state)

Definition at line 77 of file test_amxd_object_hierarchy.c.

77  {
78  amxd_object_t* parent = NULL;
79  amxd_object_t* child = NULL;
80  amxd_object_t* mib = NULL;
81 
82  assert_int_equal(amxd_dm_init(&dm), 0);
83 
84  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
85  assert_int_equal(amxd_object_new(&child, amxd_object_singleton, "child"), 0);
86 
87  assert_int_equal(amxd_object_add_object(parent, child), 0);
88 
89  assert_int_equal(amxd_dm_add_root_object(&dm, parent), 0);
90  assert_int_not_equal(amxd_object_add_object(child, child), 0);
91  assert_int_not_equal(amxd_object_add_object(parent, parent), 0);
92 
93  assert_int_equal(amxd_object_add_object(parent, child), 0);
94  assert_int_not_equal(amxd_object_add_object(child, parent), 0);
95 
96  assert_int_equal(amxd_object_new(&mib, amxd_object_mib, "test-mib"), 0);
97  assert_int_equal(amxd_object_new(&child, amxd_object_singleton, "child"), 0);
98  assert_int_equal(amxd_object_add_object(mib, child), 0);
99  assert_int_not_equal(amxd_object_add_object(parent, mib), 0);
100 
101  amxd_object_delete(&mib);
102 
103  amxd_dm_clean(&dm);
104 }
@ amxd_object_mib
Definition: amxd_types.h:188
@ amxd_object_singleton
Definition: amxd_types.h:181
amxd_status_t amxd_dm_add_root_object(amxd_dm_t *const dm, amxd_object_t *const object)
Adds an object to the root of the data model.
Definition: amxd_dm.c:418
amxd_status_t amxd_dm_init(amxd_dm_t *dm)
Initializes a data model structure.
Definition: amxd_dm.c:334
void amxd_dm_clean(amxd_dm_t *dm)
Cleans a data model structure.
Definition: amxd_dm.c:365
amxd_status_t amxd_object_add_object(amxd_object_t *const parent, amxd_object_t *const child)
Adds an object in the data model tree.
Definition: amxd_object.c:207
amxd_status_t amxd_object_new(amxd_object_t **object, const amxd_object_type_t type, const char *name)
Data model object constructor function.
Definition: amxd_object.c:185
void amxd_object_delete(amxd_object_t **object)
Invokes the destroy handler(s) of the object.
static amxd_dm_t dm

◆ test_amxd_object_add_object_invalid_args()

void test_amxd_object_add_object_invalid_args ( UNUSED void **  state)

Definition at line 106 of file test_amxd_object_hierarchy.c.

106  {
107  amxd_object_t* parent = NULL;
108  amxd_object_t* child = NULL;
109  amxd_dm_t dm2;
110 
111  assert_int_equal(amxd_dm_init(&dm), 0);
112  assert_int_equal(amxd_dm_init(&dm2), 0);
113 
114  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
115  assert_int_equal(amxd_object_new(&child, amxd_object_mib, "child"), 0);
116  assert_int_equal(amxd_dm_add_root_object(&dm, parent), 0);
117 
118  assert_int_not_equal(amxd_object_add_object(parent, NULL), 0);
119  assert_int_not_equal(amxd_object_add_object(NULL, child), 0);
120  assert_int_not_equal(amxd_object_add_object(parent, child), 0);
121 
122  assert_int_not_equal(amxd_object_add_object(parent, amxd_dm_get_root(&dm2)), 0);
123 
124  amxd_object_delete(&child);
125 
126  amxd_dm_clean(&dm2);
127  amxd_dm_clean(&dm);
128 }
amxd_object_t * amxd_dm_get_root(amxd_dm_t *const dm)
Fetches the root object of the data model.
Definition: amxd_dm.c:456

◆ test_amxd_object_find()

void test_amxd_object_find ( UNUSED void **  state)

Definition at line 431 of file test_amxd_object_hierarchy.c.

431  {
432  amxd_object_t* parent = NULL;
433  amxd_object_t* child1 = NULL;
434  amxd_object_t* child2 = NULL;
435  amxd_object_t* instance = NULL;
436 
437  assert_int_equal(amxd_dm_init(&dm), 0);
438 
439  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
440  assert_int_equal(amxd_object_new(&child1, amxd_object_template, "child"), 0);
441  assert_int_equal(amxd_object_new(&child2, amxd_object_template, "sub-child"), 0);
442  assert_int_equal(amxd_dm_add_root_object(&dm, parent), 0);
443  assert_int_equal(amxd_object_add_object(parent, child1), 0);
444  assert_int_equal(amxd_object_add_object(child1, child2), 0);
445  assert_int_equal(amxd_object_new_instance(&instance, child1, "sub-child", 0, NULL), 0);
446 
447  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent"), parent);
448  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent.child"), child1);
449  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent.child.sub-child"), child2);
450  assert_ptr_equal(amxd_object_findf(parent, "child.sub-child"), child2);
451  assert_ptr_equal(amxd_object_findf(parent, ".child.sub-child"), child2);
452  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent.child.[sub-child]"), instance);
453  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent.child.[1]"), instance);
454 
455  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent.child.[2]"), NULL);
456  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent.child.[not-existing]"), NULL);
457  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent.child.not-existing"), NULL);
458 
459  assert_ptr_equal(amxd_object_findf(NULL, "parent.child.[2]"), NULL);
460  assert_ptr_equal(amxd_object_findf(parent, NULL), NULL);
461 
462  amxd_dm_clean(&dm);
463 }
amxd_object_t * amxd_object_findf(amxd_object_t *object, const char *rel_path,...) __attribute__((format(printf
Find an object in the data model tree, starting from an object.
amxd_status_t amxd_object_new_instance(amxd_object_t **object, amxd_object_t *templ, const char *name, uint32_t index, amxc_var_t *values)
Data model object constructor function.

◆ test_amxd_object_findf()

void test_amxd_object_findf ( UNUSED void **  state)

Definition at line 465 of file test_amxd_object_hierarchy.c.

465  {
466  amxd_object_t* parent = NULL;
467  amxd_object_t* child1 = NULL;
468  amxd_object_t* child2 = NULL;
469  amxd_object_t* instance = NULL;
470 
471  assert_int_equal(amxd_dm_init(&dm), 0);
472 
473  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
474  assert_int_equal(amxd_object_new(&child1, amxd_object_template, "child"), 0);
475  assert_int_equal(amxd_object_new(&child2, amxd_object_template, "sub-child"), 0);
476  assert_int_equal(amxd_dm_add_root_object(&dm, parent), 0);
477  assert_int_equal(amxd_object_add_object(parent, child1), 0);
478  assert_int_equal(amxd_object_add_object(child1, child2), 0);
479  assert_int_equal(amxd_object_new_instance(&instance, child1, "sub-child", 0, NULL), 0);
480 
481  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "%s", "parent"), parent);
482  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "%s.child", "parent"), child1);
483  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent.child.%s", "sub-child"), child2);
484  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent.child.[%s]", "sub-child"), instance);
485  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent.child.[%d]", 1), instance);
486  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent.child.%d", 1), instance);
487  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent..child..%d.", 1), instance);
488  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent.child..[%s].", "sub-child"), instance);
489  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "..."), amxd_dm_get_root(&dm));
490 
491  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent.child.[%d]", 2), NULL);
492  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent.child.[%s]", "not-existing"), NULL);
493  assert_ptr_equal(amxd_object_findf(amxd_dm_get_root(&dm), "parent.child.%s", "not-existing"), NULL);
494 
495  assert_ptr_equal(amxd_object_findf(NULL, "%s.child.[2]", "parent"), NULL);
496  assert_ptr_equal(amxd_object_findf(parent, NULL), NULL);
497 
498  amxd_dm_clean(&dm);
499 }

◆ test_amxd_object_get()

void test_amxd_object_get ( UNUSED void **  state)

Definition at line 394 of file test_amxd_object_hierarchy.c.

394  {
395  amxd_object_t* parent = NULL;
396  amxd_object_t* child1 = NULL;
397  amxd_object_t* child2 = NULL;
398  amxd_object_t* instance = NULL;
399  amxd_object_t* mib = NULL;
400 
401  assert_int_equal(amxd_dm_init(&dm), 0);
402 
403  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
404  assert_int_equal(amxd_object_new(&child1, amxd_object_template, "child"), 0);
405  assert_int_equal(amxd_object_new(&child2, amxd_object_template, "sub-child"), 0);
406  assert_int_equal(amxd_dm_add_root_object(&dm, parent), 0);
407  assert_int_equal(amxd_object_add_object(parent, child1), 0);
408  assert_int_equal(amxd_object_add_object(child1, child2), 0);
409  assert_int_equal(amxd_object_new_instance(&instance, child1, "sub-child", 0, NULL), 0);
410 
411  assert_ptr_equal(amxd_object_get(parent, "child"), child1);
412  assert_ptr_equal(amxd_object_get(parent, "invalid"), NULL);
413  assert_ptr_equal(amxd_object_get(child1, "test"), NULL);
414  assert_ptr_equal(amxd_object_get(child1, "sub-child"), instance);
415  assert_ptr_equal(amxd_object_get(child1, "1"), instance);
416  assert_ptr_equal(amxd_object_get(amxd_dm_get_root(&dm), "parent"), parent);
417 
418  assert_int_equal(amxd_object_new(&mib, amxd_object_mib, "test-mib"), 0);
419  assert_int_equal(amxd_object_new(&child1, amxd_object_template, "mib-child"), 0);
420  assert_int_equal(amxd_object_add_object(mib, child1), 0);
421  assert_ptr_equal(amxd_object_get(mib, "mib-child"), child1);
422  amxd_object_delete(&mib);
423 
424  assert_ptr_equal(amxd_object_get(parent, ""), NULL);
425  assert_ptr_equal(amxd_object_get(parent, NULL), NULL);
426  assert_ptr_equal(amxd_object_get(NULL, "test"), NULL);
427 
428  amxd_dm_clean(&dm);
429 }
amxd_object_t * amxd_object_get(const amxd_object_t *object, const char *name)
Get an instance or child of an object.

◆ test_amxd_object_get_child()

void test_amxd_object_get_child ( UNUSED void **  state)

Definition at line 228 of file test_amxd_object_hierarchy.c.

228  {
229  amxd_object_t* parent = NULL;
230  amxd_object_t* child1 = NULL;
231  amxd_object_t* child2 = NULL;
232  amxd_object_t* instance = NULL;
233  amxd_object_t* mib = NULL;
234 
235  assert_int_equal(amxd_dm_init(&dm), 0);
236 
237  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
238  assert_int_equal(amxd_object_new(&child1, amxd_object_template, "child"), 0);
239  assert_int_equal(amxd_object_new(&child2, amxd_object_template, "sub-child"), 0);
240  assert_int_equal(amxd_dm_add_root_object(&dm, parent), 0);
241  assert_int_equal(amxd_object_add_object(parent, child1), 0);
242  assert_int_equal(amxd_object_add_object(child1, child2), 0);
243  assert_int_equal(amxd_object_new_instance(&instance, child1, "sub-child", 0, NULL), 0);
244 
245  assert_ptr_equal(amxd_object_get_child(parent, "child"), child1);
246  assert_ptr_equal(amxd_object_get_child(parent, "chi"), NULL);
247  assert_ptr_equal(amxd_object_get_child(parent, "invalid"), NULL);
248  assert_ptr_equal(amxd_object_get_child(child1, "test"), NULL);
249  assert_ptr_equal(amxd_object_get_child(child1, "sub-child"), child2);
250  assert_ptr_equal(amxd_object_get_child(amxd_dm_get_root(&dm), "parent"), parent);
251 
252  assert_int_equal(amxd_object_new(&mib, amxd_object_mib, "test-mib"), 0);
253  assert_int_equal(amxd_object_new(&child1, amxd_object_template, "mib-child"), 0);
254  assert_int_equal(amxd_object_add_object(mib, child1), 0);
255  assert_ptr_equal(amxd_object_get_child(mib, "mib-child"), child1);
256  amxd_object_delete(&mib);
257 
258  assert_ptr_equal(amxd_object_get_child(parent, ""), NULL);
259  assert_ptr_equal(amxd_object_get_child(parent, NULL), NULL);
260  assert_ptr_equal(amxd_object_get_child(NULL, "test"), NULL);
261 
262  amxd_dm_clean(&dm);
263 }
amxd_object_t * amxd_object_get_child(const amxd_object_t *object, const char *name)
Get a child of the object.

◆ test_amxd_object_get_dm()

void test_amxd_object_get_dm ( UNUSED void **  state)

Definition at line 197 of file test_amxd_object_hierarchy.c.

197  {
198  amxd_object_t* parent = NULL;
199  amxd_object_t* child = NULL;
200  amxd_object_t* instance = NULL;
201  amxd_object_t* mib = NULL;
202 
203  assert_int_equal(amxd_dm_init(&dm), 0);
204 
205  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
206  assert_int_equal(amxd_object_new(&child, amxd_object_template, "child"), 0);
207  assert_int_equal(amxd_dm_add_root_object(&dm, parent), 0);
208  assert_int_equal(amxd_object_add_object(parent, child), 0);
209  assert_int_equal(amxd_object_new_instance(&instance, child, "test", 0, NULL), 0);
210 
211  assert_ptr_equal(amxd_object_get_dm(instance), &dm);
212  assert_ptr_equal(amxd_object_get_dm(child), &dm);
213  assert_ptr_equal(amxd_object_get_dm(parent), &dm);
214  assert_ptr_equal(amxd_object_get_dm(amxd_dm_get_root(&dm)), &dm);
215 
216  assert_int_equal(amxd_object_new(&mib, amxd_object_mib, "test-mib"), 0);
217  assert_ptr_equal(amxd_object_get_dm(mib), NULL);
218  assert_ptr_equal(amxd_object_get_dm(NULL), NULL);
219  amxd_object_delete(&mib);
220 
221  assert_int_equal(amxd_object_new(&child, amxd_object_template, "child"), 0);
222  assert_ptr_equal(amxd_object_get_dm(child), NULL);
223  amxd_object_delete(&child);
224 
225  amxd_dm_clean(&dm);
226 }
amxd_dm_t * amxd_object_get_dm(const amxd_object_t *const object)
Get the data model.

◆ test_amxd_object_get_instance()

void test_amxd_object_get_instance ( UNUSED void **  state)

Definition at line 265 of file test_amxd_object_hierarchy.c.

265  {
266  amxd_object_t* parent = NULL;
267  amxd_object_t* child1 = NULL;
268  amxd_object_t* child2 = NULL;
269  amxd_object_t* instance = NULL;
270  amxd_object_t* mib = NULL;
271 
272  assert_int_equal(amxd_dm_init(&dm), 0);
273 
274  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
275  assert_int_equal(amxd_object_new(&child1, amxd_object_template, "child"), 0);
276  assert_int_equal(amxd_object_new(&child2, amxd_object_template, "sub-child"), 0);
277  assert_int_equal(amxd_dm_add_root_object(&dm, parent), 0);
278  assert_int_equal(amxd_object_add_object(parent, child1), 0);
279  assert_int_equal(amxd_object_add_object(child1, child2), 0);
280  assert_int_equal(amxd_object_new_instance(&instance, child1, "sub-child", 0, NULL), 0);
281 
282  assert_ptr_equal(amxd_object_get_instance(parent, "child", 0), NULL);
283  assert_ptr_equal(amxd_object_get_instance(parent, "invalid", 0), NULL);
284  assert_ptr_equal(amxd_object_get_instance(child1, "test", 0), NULL);
285  assert_ptr_equal(amxd_object_get_instance(child1, "sub-child", 0), instance);
286  assert_ptr_equal(amxd_object_get_instance(child1, "sub", 0), NULL);
287  assert_ptr_equal(amxd_object_get_instance(child1, NULL, 1), instance);
288  assert_ptr_equal(amxd_object_get_instance(child1, "", 1), instance);
289  assert_ptr_equal(amxd_object_get_instance(amxd_dm_get_root(&dm), "parent", 0), NULL);
290 
291  assert_int_equal(amxd_object_new(&mib, amxd_object_mib, "test-mib"), 0);
292  assert_int_equal(amxd_object_new(&child1, amxd_object_template, "mib-child"), 0);
293  assert_int_equal(amxd_object_add_object(mib, child1), 0);
294  assert_ptr_equal(amxd_object_get_instance(mib, "mib-child", 0), NULL);
295  amxd_object_delete(&mib);
296 
297  assert_ptr_equal(amxd_object_get_instance(parent, "", 0), NULL);
298  assert_ptr_equal(amxd_object_get_instance(parent, NULL, 0), NULL);
299  assert_ptr_equal(amxd_object_get_instance(NULL, "test", 0), NULL);
300 
301  amxd_dm_clean(&dm);
302 }
amxd_object_t * amxd_object_get_instance(const amxd_object_t *object, const char *name, uint32_t index)
Get an instance of the template object.

◆ test_amxd_object_get_instance_difficult_alias_name()

void test_amxd_object_get_instance_difficult_alias_name ( UNUSED void **  state)

Definition at line 304 of file test_amxd_object_hierarchy.c.

304  {
305  amxd_object_t* root = NULL;
306  amxd_object_t* template = NULL;
307  amxd_param_t* param = NULL;
308  const char* names[] = {
309  "normal_alias",
310  "another_normal_alias",
311  "we can use spaces",
312  "dot.in_the_middle",
313  "dot_at_the_end.",
314  "[brackets]",
315  "textbefore[brackets]",
316  "utf8snowman☃",
317  "quo'tes",
318  "injectionattack\" || \"a\" == \"b",
319  "injectionattack\" || \"a\" == \"b' || 'a' == 'b",
320  "diversion_brackets",
321  "[diversion_brackets]",
322  };
323 
324  assert_int_equal(amxd_dm_init(&dm), amxd_status_ok);
325  assert_int_equal(amxd_object_new(&root, amxd_object_singleton, "MyRoot"), amxd_status_ok);
326  assert_int_equal(amxd_object_new(&template, amxd_object_template, "MyTemplate"), amxd_status_ok);
327  assert_int_equal(amxd_param_new(&param, "Alias", AMXC_VAR_ID_CSTRING), 0);
329  amxd_param_set_attr(param, amxd_pattr_key, true);
330  assert_int_equal(amxd_object_add_param(template, param), 0);
331  assert_int_equal(amxd_dm_add_root_object(&dm, root), amxd_status_ok);
332  assert_int_equal(amxd_object_add_object(root, template), amxd_status_ok);
333 
334  for(size_t i = 0; i < sizeof(names) / sizeof(names)[0]; i++) {
335  amxd_object_t* instance = NULL;
336  // GIVEN an instance object with a name that has tricky characters
337  const char* name = names[i];
338  amxd_object_t* retrieved_instance = NULL;
339  amxd_status_t status = amxd_object_new_instance(&instance, template, name, 0, NULL);
341  // If a difficult name is refused, then we don't have to be able to fetch by that name.
342  continue;
343  }
344  assert_int_equal(status, amxd_status_ok);
345  assert_non_null(instance);
346  printf("Instance name = %s\n", name);
347 
348  // WHEN retrieving that instance object by its name
349  retrieved_instance = amxd_object_get_instance(template, name, 0);
350 
351  // THEN the instance object was retrieved successfully
352  assert_non_null(retrieved_instance);
353  assert_ptr_equal(retrieved_instance, instance);
354  }
355 
356  for(size_t i = 0; i < sizeof(names) / sizeof(names)[0]; i++) {
357  // GIVEN an instance object with a name that has tricky characters
358  const char* name = names[i];
359  amxd_object_t* retrieved_instance = NULL;
360  printf("Instance name = %s\n", name);
361 
362  // WHEN retrieving that instance object by its name
363  retrieved_instance = amxd_object_get_instance(template, name, 0);
364 
365  // THEN the instance object was retrieved successfully
366  assert_non_null(retrieved_instance);
367  assert_string_equal(amxd_object_get_name(retrieved_instance, AMXD_OBJECT_NAMED), name);
368  }
369 
370  for(size_t i = 0; i < sizeof(names) / sizeof(names)[0]; i++) {
371  // GIVEN an instance object with a name that has tricky characters
372  const char* name = names[i];
373  amxd_object_t* retrieved_instance = NULL;
374  printf("Instance name = %s\n", name);
375 
376  // WHEN retrieving that instance object by its alias
377  // This triggers a memory leak in libamxp expression parser
378  // the problem needs to be investigated, when fixed this test can be enabled again
379  retrieved_instance = amxd_dm_findf(&dm, "MyRoot.MyTemplate.[%s].", name);
380  if(retrieved_instance == NULL) {
381  retrieved_instance = amxd_dm_findf(&dm, "MyRoot.MyTemplate.[Alias == '%s'].", name);
382  }
383  if(retrieved_instance == NULL) {
384  retrieved_instance = amxd_dm_findf(&dm, "MyRoot.MyTemplate.[Alias == \"%s\"].", name);
385  }
386  // THEN the instance object was retrieved successfully
387  assert_non_null(retrieved_instance);
388  assert_string_equal(amxd_object_get_name(retrieved_instance, AMXD_OBJECT_NAMED), name);
389  }
390 
391  amxd_dm_clean(&dm);
392 }
amxd_object_t * amxd_dm_findf(amxd_dm_t *const dm, const char *abs_path,...) __attribute__((format(printf
amxd_status_t amxd_param_new(amxd_param_t **param, const char *name, const uint32_t type)
amxd_status_t amxd_param_set_attr(amxd_param_t *param, const amxd_pattr_id_t attr, const bool enable)
@ amxd_pattr_unique
Definition: amxd_types.h:363
@ amxd_pattr_key
Definition: amxd_types.h:362
enum _amxd_status amxd_status_t
@ amxd_status_invalid_name
Definition: amxd_types.h:86
@ amxd_status_ok
Definition: amxd_types.h:78
amxd_status_t amxd_object_add_param(amxd_object_t *const object, amxd_param_t *const param)
Adds a parameter definition to an object.
const char * amxd_object_get_name(const amxd_object_t *const object, const uint32_t flags)
Get the name of the object (or index as a string for instance objects)
Definition: amxd_object.c:239
static amxd_status_t status

◆ test_amxd_object_get_parent()

void test_amxd_object_get_parent ( UNUSED void **  state)

Definition at line 130 of file test_amxd_object_hierarchy.c.

130  {
131  amxd_object_t* parent = NULL;
132  amxd_object_t* child = NULL;
133  amxd_object_t* instance = NULL;
134  amxd_object_t* mib = NULL;
135 
136  assert_int_equal(amxd_dm_init(&dm), 0);
137 
138  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
139  assert_int_equal(amxd_object_new(&child, amxd_object_template, "child"), 0);
140  assert_int_equal(amxd_dm_add_root_object(&dm, parent), 0);
141  assert_int_equal(amxd_object_add_object(parent, child), 0);
142  assert_int_equal(amxd_object_new_instance(&instance, child, "test", 0, NULL), 0);
143 
144  assert_ptr_equal(amxd_object_get_parent(instance), child);
145  assert_ptr_equal(amxd_object_get_parent(child), parent);
146  assert_ptr_equal(amxd_object_get_parent(parent), amxd_dm_get_root(&dm));
147  assert_ptr_equal(amxd_object_get_parent(amxd_dm_get_root(&dm)), NULL);
148  assert_ptr_equal(amxd_object_findf(instance, "^"), child);
149  assert_ptr_equal(amxd_object_findf(instance, "^.^"), parent);
150  assert_ptr_equal(amxd_object_findf(instance, "^.^.^"), amxd_dm_get_root(&dm));
151  assert_ptr_equal(amxd_object_findf(instance, "^.^.^.parent"), parent);
152  assert_ptr_equal(amxd_object_findf(instance, "^.^.^.^"), NULL);
153  assert_ptr_equal(amxd_object_findf(instance, "^.^.^.^.parent"), NULL);
154 
155  assert_int_equal(amxd_object_new(&mib, amxd_object_mib, "test-mib"), 0);
156  assert_ptr_equal(amxd_object_get_parent(mib), NULL);
157  assert_ptr_equal(amxd_object_get_parent(NULL), NULL);
158  amxd_object_delete(&mib);
159 
160  amxd_dm_clean(&dm);
161 }

◆ test_amxd_object_get_path()

void test_amxd_object_get_path ( UNUSED void **  state)

Definition at line 501 of file test_amxd_object_hierarchy.c.

501  {
502  char* path = NULL;
503  amxd_object_t* parent = NULL;
504  amxd_object_t* child1 = NULL;
505  amxd_object_t* child2 = NULL;
506  amxd_object_t* instance_child2 = NULL;
507  amxd_object_t* instance = NULL;
508  amxc_llist_t paths;
509 
510  amxc_llist_init(&paths);
511 
512  assert_int_equal(amxd_dm_init(&dm), 0);
513 
514  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
515  assert_int_equal(amxd_object_new(&child1, amxd_object_template, "child"), 0);
516  assert_int_equal(amxd_object_new(&child2, amxd_object_template, "sub-child"), 0);
517  assert_int_equal(amxd_dm_add_root_object(&dm, parent), 0);
518  assert_int_equal(amxd_object_add_object(parent, child1), 0);
519  assert_int_equal(amxd_object_add_object(child1, child2), 0);
520  assert_int_equal(amxd_object_new_instance(&instance, child1, "sub-child", 0, NULL), 0);
521 
522  path = amxd_object_get_path(parent, AMXD_OBJECT_NAMED);
523  assert_string_equal(path, "parent");
524  free(path);
525 
526  path = amxd_object_get_path(child1, AMXD_OBJECT_NAMED);
527  assert_string_equal(path, "parent.child");
528  free(path);
529 
530  path = amxd_object_get_rel_path(child1, parent, AMXD_OBJECT_NAMED);
531  assert_string_equal(path, "child");
532  free(path);
533 
534  path = amxd_object_get_rel_path(child1, child1, AMXD_OBJECT_NAMED);
535  assert_null(path);
536  free(path);
537 
538  path = amxd_object_get_path(child2, AMXD_OBJECT_NAMED);
539  assert_string_equal(path, "parent.child.sub-child");
540  free(path);
541 
543  assert_string_equal(path, "parent.child.{i}");
544  free(path);
545 
547  assert_string_equal(path, "parent.child.{i}.");
548  free(path);
549 
551  assert_string_equal(path, "parent.child.{i}.");
552  free(path);
553 
555  assert_string_equal(path, "parent.child.sub-child.");
556  free(path);
557 
559  assert_string_equal(path, "parent.child.[sub-child]");
560  free(path);
562  assert_string_equal(path, "parent.child.[1]");
563  free(path);
564 
565  path = amxd_object_get_path(instance, AMXD_OBJECT_NAMED);
566  assert_string_equal(path, "parent.child.sub-child");
567  free(path);
568  path = amxd_object_get_path(instance, AMXD_OBJECT_INDEXED);
569  assert_string_equal(path, "parent.child.1");
570  free(path);
571 
573  assert_string_equal(path, "parent\\.child\\.sub-child");
574  free(path);
576  assert_string_equal(path, "parent\\.child\\.1");
577  free(path);
578 
580  assert_string_equal(path, "parent\\.child\\.\\[sub-child\\]");
581  free(path);
583  assert_string_equal(path, "parent\\.child\\.\\[1\\]");
584  free(path);
585 
587  assert_ptr_equal(path, NULL);
588  free(path);
589 
590  instance_child2 = amxd_object_findf(instance, "sub-child");
591  assert_ptr_not_equal(instance_child2, NULL);
592  assert_ptr_not_equal(instance_child2, child2);
593 
595  assert_string_equal(path, "parent.child.[sub-child].sub-child");
596  free(path);
597 
598  child2 = amxd_dm_findf(&dm, "parent.child.{i}.sub-child.");
599  assert_non_null(child2);
600  child2 = amxd_dm_findf(&dm, "parent.{i}.1.sub-child.");
601  assert_null(child2);
602 
603  child1 = amxd_dm_findf(&dm, "parent.child.");
604  assert_non_null(child1);
605  child2 = amxd_object_findf(child1, ".sub-child.");
606  assert_non_null(child2);
607  assert_int_equal(amxd_object_resolve_pathf(child1, &paths, ".sub2-child."), 0);
608 
609  assert_ptr_equal(amxd_object_get_path(NULL, 0), NULL);
610  amxc_llist_clean(&paths, amxc_string_list_it_free);
611 
612  amxd_dm_clean(&dm);
613 }
#define AMXD_OBJECT_SUPPORTED
Path format flag - adds {i} as placeholder for an instance object.
Definition: amxd_object.h:226
#define AMXD_OBJECT_REGEXP
Path format flag - create path that can be used as regular expression.
Definition: amxd_object.h:202
#define AMXD_OBJECT_TERMINATE
Path format flag - when set the object path is terminated with a dot.
Definition: amxd_object.h:214
char * amxd_object_get_rel_path(const amxd_object_t *child, const amxd_object_t *parent, const uint32_t flags)
Get the relative path of the object.
amxd_object_t amxd_status_t amxd_object_resolve_pathf(amxd_object_t *object, amxc_llist_t *paths, const char *rel_path,...) __attribute__((format(printf
Resolves a search path into a list of matching object paths.

◆ test_amxd_object_get_root()

void test_amxd_object_get_root ( UNUSED void **  state)

Definition at line 163 of file test_amxd_object_hierarchy.c.

163  {
164  amxd_object_t* parent = NULL;
165  amxd_object_t* child = NULL;
166  amxd_object_t* instance = NULL;
167  amxd_object_t* mib = NULL;
168 
169  assert_int_equal(amxd_dm_init(&dm), 0);
170 
171  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
172  assert_int_equal(amxd_object_new(&child, amxd_object_template, "child"), 0);
173  assert_int_equal(amxd_dm_add_root_object(&dm, parent), 0);
174  assert_int_equal(amxd_object_add_object(parent, child), 0);
175  assert_int_equal(amxd_object_new_instance(&instance, child, "test", 0, NULL), 0);
176 
177  assert_ptr_equal(amxd_object_get_root(instance), amxd_dm_get_root(&dm));
178  assert_ptr_equal(amxd_object_get_root(child), amxd_dm_get_root(&dm));
179  assert_ptr_equal(amxd_object_get_root(parent), amxd_dm_get_root(&dm));
180  assert_ptr_equal(amxd_object_get_root(amxd_dm_get_root(&dm)), NULL);
181 
182  assert_int_equal(amxd_object_new(&mib, amxd_object_mib, "test-mib"), 0);
183  assert_ptr_equal(amxd_object_get_root(mib), NULL);
184  assert_ptr_equal(amxd_object_get_root(NULL), NULL);
185  amxd_object_delete(&mib);
186 
187  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
188  assert_int_equal(amxd_object_new(&child, amxd_object_template, "child"), 0);
189  assert_int_equal(amxd_object_add_object(parent, child), 0);
190  assert_ptr_equal(amxd_object_get_root(child), NULL);
191  assert_ptr_equal(amxd_object_get_root(parent), NULL);
192  amxd_object_delete(&parent);
193 
194  amxd_dm_clean(&dm);
195 }
amxd_object_t * amxd_object_get_root(const amxd_object_t *const object)
Get the data model root.

◆ test_amxd_object_is_child_of()

void test_amxd_object_is_child_of ( UNUSED void **  state)

Definition at line 878 of file test_amxd_object_hierarchy.c.

878  {
879  amxd_object_t* parent = NULL;
880  amxd_object_t* child1 = NULL;
881  amxd_object_t* child2 = NULL;
882  amxd_object_t* instance = NULL;
883 
884  assert_int_equal(amxd_dm_init(&dm), 0);
885 
886  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
887  assert_int_equal(amxd_dm_add_root_object(&dm, parent), 0);
888 
889  assert_int_equal(amxd_object_new(&child1, amxd_object_singleton, "child_1"), 0);
890  assert_int_equal(amxd_object_add_object(parent, child1), 0);
891  assert_int_equal(amxd_object_new(&child2, amxd_object_template, "child_2"), 0);
892  assert_int_equal(amxd_object_add_object(parent, child2), 0);
893 
894  assert_int_equal(amxd_object_new_instance(&instance, child2, "instance_1", 0, NULL), 0);
895 
896  assert_true(amxd_object_is_child_of(instance, parent));
897  assert_true(amxd_object_is_child_of(child2, parent));
898  assert_true(amxd_object_is_child_of(child1, parent));
899  assert_false(amxd_object_is_child_of(child1, child2));
900  assert_false(amxd_object_is_child_of(child2, child1));
901  assert_false(amxd_object_is_child_of(parent, child2));
902  assert_true(amxd_object_is_child_of(instance, child2));
903  assert_false(amxd_object_is_child_of(instance, child1));
904 
905  assert_false(amxd_object_is_child_of(NULL, parent));
906  assert_false(amxd_object_is_child_of(child1, NULL));
907 
908  amxd_dm_clean(&dm);
909 }
bool amxd_object_is_child_of(const amxd_object_t *const child, const amxd_object_t *const parent)
Checks if the child object is in the hierarchical tree of the parent object.

◆ test_amxd_object_walk()

void test_amxd_object_walk ( UNUSED void **  state)

Definition at line 672 of file test_amxd_object_hierarchy.c.

672  {
673  amxd_object_t* parent = NULL;
674  amxd_object_t* child = NULL;
675  amxd_object_t* instance = NULL;
676 
677  assert_int_equal(amxd_dm_init(&dm), 0);
678 
679  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
680  assert_int_equal(amxd_dm_add_root_object(&dm, parent), 0);
681 
682  printf("Current parent = %s\n", parent->name);
683  assert_int_equal(amxd_object_new(&child, amxd_object_singleton, "child_1"), 0);
684  assert_int_equal(amxd_object_add_object(parent, child), 0);
685  assert_int_equal(amxd_object_new(&child, amxd_object_template, "child_2"), 0);
686  assert_int_equal(amxd_object_add_object(parent, child), 0);
687 
688  parent = child;
689  printf("Current parent = %s\n", parent->name);
690  assert_int_equal(amxd_object_new(&child, amxd_object_singleton, "child_2_1"), 0);
691  assert_int_equal(amxd_object_add_object(parent, child), 0);
692  assert_int_equal(amxd_object_new(&child, amxd_object_singleton, "child_2_2"), 0);
693  assert_int_equal(amxd_object_add_object(parent, child), 0);
694 
695  assert_int_equal(amxd_object_new_instance(&instance, parent, "instance_1", 0, NULL), 0);
696  assert_int_equal(amxd_object_new_instance(&instance, parent, "instance_2", 0, NULL), 0);
697 
698  pos = 0;
700  pos = 0;
701  amxd_object_hierarchy_walk(instance, amxd_direction_up, NULL, check_path_up, INT32_MAX, NULL);
702 
703  amxd_dm_clean(&dm);
704 }
@ amxd_direction_down
Definition: amxd_types.h:216
@ amxd_direction_up
Definition: amxd_types.h:215
void amxd_object_hierarchy_walk(amxd_object_t *const object, const amxd_direction_t direction, amxd_object_filter_fn_t filter, amxd_object_cb_fn_t cb, int32_t depth, void *priv)
Iterates over all objects in the data model tree.
char * name
Definition: amxd_types.h:238
static void check_path_up(amxd_object_t *const object, UNUSED int32_t depth, void *priv)
static void check_path_down(amxd_object_t *const object, UNUSED int32_t depth, void *priv)

◆ test_amxd_object_walk_depth()

void test_amxd_object_walk_depth ( UNUSED void **  state)

Definition at line 839 of file test_amxd_object_hierarchy.c.

839  {
840  amxd_object_t* parent = NULL;
841  amxd_object_t* child = NULL;
842  amxd_object_t* instance = NULL;
843 
844  assert_int_equal(amxd_dm_init(&dm), 0);
845 
846  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
847  assert_int_equal(amxd_dm_add_root_object(&dm, parent), 0);
848 
849  printf("Current parent = %s\n", parent->name);
850  assert_int_equal(amxd_object_new(&child, amxd_object_singleton, "child_1"), 0);
851  assert_int_equal(amxd_object_add_object(parent, child), 0);
852  assert_int_equal(amxd_object_new(&child, amxd_object_template, "child_2"), 0);
853  assert_int_equal(amxd_object_add_object(parent, child), 0);
854 
855  parent = child;
856  printf("Current parent = %s\n", parent->name);
857  assert_int_equal(amxd_object_new(&child, amxd_object_singleton, "child_2_1"), 0);
858  assert_int_equal(amxd_object_add_object(parent, child), 0);
859  assert_int_equal(amxd_object_new(&child, amxd_object_singleton, "child_2_2"), 0);
860  assert_int_equal(amxd_object_add_object(parent, child), 0);
861 
862  assert_int_equal(amxd_object_new_instance(&instance, parent, "instance_1", 0, NULL), 0);
863  assert_int_equal(amxd_object_new_instance(&instance, parent, "instance_2", 0, NULL), 0);
864 
865  pos = 0;
867  pos = 0;
869 
870  amxd_dm_clean(&dm);
871 }
static void check_path_down_depth(amxd_object_t *const object, UNUSED int32_t depth, void *priv)
static void check_path_up_depth(amxd_object_t *const object, UNUSED int32_t depth, void *priv)

◆ test_amxd_object_walk_filtered()

void test_amxd_object_walk_filtered ( UNUSED void **  state)

Definition at line 761 of file test_amxd_object_hierarchy.c.

761  {
762  amxd_object_t* parent = NULL;
763  amxd_object_t* child = NULL;
764  amxd_object_t* instance = NULL;
765 
766  assert_int_equal(amxd_dm_init(&dm), 0);
767 
768  assert_int_equal(amxd_object_new(&parent, amxd_object_singleton, "parent"), 0);
769  assert_int_equal(amxd_dm_add_root_object(&dm, parent), 0);
770 
771  printf("Current parent = %s\n", parent->name);
772  assert_int_equal(amxd_object_new(&child, amxd_object_singleton, "child_1"), 0);
773  assert_int_equal(amxd_object_add_object(parent, child), 0);
774  assert_int_equal(amxd_object_new(&child, amxd_object_template, "child_2"), 0);
775  assert_int_equal(amxd_object_add_object(parent, child), 0);
776 
777  parent = child;
778  printf("Current parent = %s\n", parent->name);
779  assert_int_equal(amxd_object_new(&child, amxd_object_singleton, "child_2_1"), 0);
780  assert_int_equal(amxd_object_add_object(parent, child), 0);
781  assert_int_equal(amxd_object_new(&child, amxd_object_singleton, "child_2_2"), 0);
782  assert_int_equal(amxd_object_add_object(parent, child), 0);
783 
784  assert_int_equal(amxd_object_new_instance(&instance, parent, "instance_1", 0, NULL), 0);
785  assert_int_equal(amxd_object_new_instance(&instance, parent, "instance_2", 0, NULL), 0);
786 
787  pos = 0;
789  pos = 0;
791 
792  amxd_dm_clean(&dm);
793 }
static bool no_root_objects(amxd_object_t *const object, UNUSED int32_t depth, void *priv)
static void check_path_down_filtered(amxd_object_t *const object, UNUSED int32_t depth, void *priv)
static bool no_tempate_child_objects(amxd_object_t *const object, UNUSED int32_t depth, void *priv)

◆ test_amxd_object_walk_invalid_args()

void test_amxd_object_walk_invalid_args ( UNUSED void **  state)

Definition at line 873 of file test_amxd_object_hierarchy.c.

873  {
874  amxd_object_hierarchy_walk(amxd_dm_get_root(&dm), amxd_direction_down, NULL, NULL, INT32_MAX, NULL);
876 }

Variable Documentation

◆ dm

amxd_dm_t dm
static

Definition at line 75 of file test_amxd_object_hierarchy.c.

◆ expected_paths_down

char* expected_paths_down[]
static
Initial value:
= {
NULL,
"parent",
"parent.child_1",
"parent.child_2",
"parent.child_2.child_2_1",
"parent.child_2.child_2_2",
"parent.child_2.[instance_1]",
"parent.child_2.[instance_1].child_2_1",
"parent.child_2.[instance_1].child_2_2",
"parent.child_2.[instance_2]",
"parent.child_2.[instance_2].child_2_1",
"parent.child_2.[instance_2].child_2_2",
}

Definition at line 616 of file test_amxd_object_hierarchy.c.

◆ expected_paths_down_depth

char* expected_paths_down_depth[]
static
Initial value:
= {
NULL,
"parent",
}

Definition at line 795 of file test_amxd_object_hierarchy.c.

◆ expected_paths_down_filtered

char* expected_paths_down_filtered[]
static
Initial value:
= {
NULL,
"parent",
"parent.child_1",
"parent.child_2",
"parent.child_2.instance_1",
"parent.child_2.instance_1.child_2_1",
"parent.child_2.instance_1.child_2_2",
"parent.child_2.instance_2",
"parent.child_2.instance_2.child_2_1",
"parent.child_2.instance_2.child_2_2",
}

Definition at line 706 of file test_amxd_object_hierarchy.c.

◆ expected_paths_up

char* expected_paths_up[]
static
Initial value:
= {
"parent.child_2.[instance_2]",
"parent.child_2",
"parent",
NULL,
}

Definition at line 648 of file test_amxd_object_hierarchy.c.

◆ expected_paths_up_depth

char* expected_paths_up_depth[]
static
Initial value:
= {
"parent.child_2.[2]",
"parent.child_2",
}

Definition at line 817 of file test_amxd_object_hierarchy.c.

◆ pos

int pos = 0
static

Definition at line 615 of file test_amxd_object_hierarchy.c.