libamxd  6.4.1
Data Model Manager
test_amxd_action_param_destroy.c File Reference
#include <stdlib.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_common.h>
#include <amxd/amxd_dm.h>
#include <amxd/amxd_object.h>
#include <amxd/amxd_parameter.h>
#include <amxd/amxd_function.h>
#include <amxd/amxd_action.h>
#include <amxd_priv.h>
#include "test_amxd_action_param_destroy.h"
#include <amxc/amxc_macros.h>

Go to the source code of this file.

Functions

static amxd_object_ttest_build_dm (void)
 
void test_amxd_param_delete (UNUSED void **state)
 

Variables

static amxd_dm_t dm
 

Function Documentation

◆ test_amxd_param_delete()

void test_amxd_param_delete ( UNUSED void **  state)

Definition at line 115 of file test_amxd_action_param_destroy.c.

115  {
116  amxd_object_t* template = NULL;
117  amxd_object_t* instance = NULL;
118  amxd_object_t* object = NULL;
119  amxd_param_t* param = NULL;
120 
121  template = test_build_dm();
122  assert_int_equal(amxd_object_new_instance(&instance, template, NULL, 0, NULL), 0);
123 
124  param = amxd_object_get_param_def(template, "param");
125  assert_int_equal(amxd_action_param_destroy(NULL, param, action_param_destroy, NULL, NULL, NULL), 0);
126  param = amxd_object_get_param_def(template, "param");
127  assert_ptr_not_equal(param, NULL);
128  amxd_param_delete(&param);
129  param = amxd_object_get_param_def(template, "templ_param");
130  assert_int_equal(amxd_action_param_destroy(NULL, param, action_param_destroy, NULL, NULL, NULL), 0);
131  param = amxd_object_get_param_def(template, "templ_param");
132  assert_ptr_not_equal(param, NULL);
133  amxd_param_delete(&param);
134 
135  param = amxd_object_get_param_def(instance, "param");
136  assert_ptr_not_equal(param, NULL);
137 
138  assert_int_equal(amxd_action_param_destroy(NULL, NULL, action_param_destroy, NULL, NULL, NULL), 0);
139  assert_int_not_equal(amxd_action_param_destroy(NULL, param, action_object_list, NULL, NULL, NULL), 0);
140  assert_int_equal(amxd_action_param_destroy(NULL, param, action_param_destroy, NULL, NULL, NULL), 0);
141 
142  param = amxd_object_get_param_def(instance, "inst_param");
143  assert_ptr_not_equal(param, NULL);
145  assert_int_equal(amxd_param_counter_destroy(NULL, NULL, action_param_destroy, NULL, NULL, NULL), 0);
146  assert_int_not_equal(amxd_param_counter_destroy(NULL, param, action_object_list, NULL, NULL, NULL), 0);
147  assert_int_equal(amxd_param_counter_destroy(NULL, param, action_param_destroy, NULL, NULL, NULL), 0);
148 
149  object = amxd_dm_findf(&dm, "parent.child");
150  assert_ptr_not_equal(object, NULL);
151  param = amxd_object_get_param_def(object, "child_param");
152  assert_ptr_not_equal(param, NULL);
153  assert_int_equal(amxd_param_counter_destroy(NULL, NULL, action_param_destroy, NULL, NULL, NULL), 0);
154  assert_int_not_equal(amxd_param_counter_destroy(NULL, param, action_object_list, NULL, NULL, NULL), 0);
155  assert_int_equal(amxd_param_counter_destroy(NULL, param, action_param_destroy, NULL, NULL, NULL), 0);
156 
157  amxd_dm_clean(&dm);
158 }
amxd_object_t * amxd_dm_findf(amxd_dm_t *const dm, const char *abs_path,...) __attribute__((format(printf
amxd_status_t amxd_param_set_attr(amxd_param_t *param, const amxd_pattr_id_t attr, const bool enable)
amxd_status_t amxd_param_delete(amxd_param_t **param)
amxd_status_t PRIVATE amxd_param_counter_destroy(amxd_object_t *const object, amxd_param_t *const param, amxd_action_t reason, const amxc_var_t *const args, amxc_var_t *const retval, void *priv)
@ amxd_pattr_counter
Definition: amxd_types.h:361
@ action_param_destroy
Definition: amxd_types.h:116
@ action_object_list
Definition: amxd_types.h:120
void amxd_dm_clean(amxd_dm_t *dm)
Cleans a data model structure.
Definition: amxd_dm.c:365
amxd_param_t * amxd_object_get_param_def(const amxd_object_t *const object, const char *name)
Gets a parameter definition 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.
amxd_status_t amxd_action_param_destroy(amxd_object_t *object, amxd_param_t *param, amxd_action_t reason, const amxc_var_t *const args, amxc_var_t *const retval, void *priv)
Default parameter destroy action implementation.
static amxd_dm_t dm
static amxd_object_t * test_build_dm(void)

◆ test_build_dm()

static amxd_object_t* test_build_dm ( void  )
static

Definition at line 82 of file test_amxd_action_param_destroy.c.

82  {
83  amxd_object_t* object = NULL;
84  amxd_object_t* template = NULL;
85  amxd_param_t* param = NULL;
86 
87  assert_int_equal(amxd_dm_init(&dm), 0);
88 
89  assert_int_equal(amxd_object_new(&template, amxd_object_template, "parent"), 0);
90  assert_int_equal(amxd_dm_add_root_object(&dm, template), 0);
91  assert_int_equal(amxd_object_new(&object, amxd_object_singleton, "child"), 0);
92  assert_int_equal(amxd_object_add_object(template, object), 0);
93 
94  assert_int_equal(amxd_param_new(&param, "templ_param", AMXC_VAR_ID_CSTRING), 0);
96  assert_int_equal(amxd_object_add_param(template, param), 0);
97  assert_int_equal(amxd_param_new(&param, "inst_param", AMXC_VAR_ID_BOOL), 0);
98  assert_int_equal(amxd_object_add_param(template, param), 0);
99  assert_int_equal(amxd_param_new(&param, "param", AMXC_VAR_ID_UINT32), 0);
102  assert_int_equal(amxd_object_add_param(template, param), 0);
103 
104  assert_int_equal(amxd_param_new(&param, "child_param", AMXC_VAR_ID_CSTRING), 0);
106  assert_int_equal(amxd_object_add_param(object, param), 0);
107  assert_int_equal(amxd_param_new(&param, "child_param2", AMXC_VAR_ID_BOOL), 0);
108  assert_int_equal(amxd_object_add_param(object, param), 0);
109  assert_int_equal(amxd_param_new(&param, "child_param3", AMXC_VAR_ID_UINT64), 0);
110  assert_int_equal(amxd_object_add_param(object, param), 0);
111 
112  return template;
113 }
amxd_status_t amxd_param_new(amxd_param_t **param, const char *name, const uint32_t type)
@ amxd_pattr_template
Definition: amxd_types.h:355
@ amxd_pattr_private
Definition: amxd_types.h:357
@ amxd_pattr_instance
Definition: amxd_types.h:356
@ amxd_object_template
Definition: amxd_types.h:183
@ 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
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_add_param(amxd_object_t *const object, amxd_param_t *const param)
Adds a parameter definition to an object.
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

Variable Documentation

◆ dm

amxd_dm_t dm
static

Definition at line 80 of file test_amxd_action_param_destroy.c.