Amxb_Ubus  3.3.1
Ambiorix Ubus API
test_amxb_ubus_register.h File Reference
#include <amxc/amxc_macros.h>

Go to the source code of this file.

Functions

int test_amxb_ubus_register_setup (UNUSED void **state)
 
int test_amxb_ubus_register_teardown (UNUSED void **state)
 
void test_ubus_can_register_dm (UNUSED void **state)
 
void test_ubus_new_objects_are_registered (UNUSED void **state)
 
void test_ubus_new_root_objects_are_registered (UNUSED void **state)
 
void test_ubus_removed_objects_are_unregistered (UNUSED void **state)
 

Function Documentation

◆ test_amxb_ubus_register_setup()

int test_amxb_ubus_register_setup ( UNUSED void **  state)

Definition at line 103 of file test_amxb_ubus_register.c.

103  {
104  const char* ubus_sock = test_amxb_ubus_get_socket();
105  printf("Ubus socket = %s\n", ubus_sock);
106 
107  assert_int_equal(amxd_dm_init(&dm), 0);
108  assert_int_equal(amxo_parser_init(&parser), 0);
109 
110  assert_int_equal(amxb_be_load("../mod-amxb-test-ubus.so"), 0);
111  assert_int_equal(amxb_connect(&bus_ctx, ubus_sock), 0);
112 
113  amxo_parser_parse_file(&parser, "../test_data/test_nemo.odl", amxd_dm_get_root(&dm));
114 
115  return 0;
116 }
static amxd_dm_t dm
static const char * test_amxb_ubus_get_socket(void)
static amxo_parser_t parser
static amxb_bus_ctx_t * bus_ctx
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_amxb_ubus_register_teardown()

int test_amxb_ubus_register_teardown ( UNUSED void **  state)

Definition at line 118 of file test_amxb_ubus_register.c.

118  {
119  amxd_dm_clean(&dm);
120  amxo_parser_clean(&parser);
121 
122  amxb_disconnect(bus_ctx);
123  amxb_free(&bus_ctx);
124 
125  amxb_be_remove_all();
126 
127  return 0;
128 }
Here is the caller graph for this function:

◆ test_ubus_can_register_dm()

void test_ubus_can_register_dm ( UNUSED void **  state)

Definition at line 130 of file test_amxb_ubus_register.c.

130  {
131  assert_int_equal(amxb_register(bus_ctx, &dm), 0);
132 }
Here is the caller graph for this function:

◆ test_ubus_new_objects_are_registered()

void test_ubus_new_objects_are_registered ( UNUSED void **  state)

Definition at line 134 of file test_amxb_ubus_register.c.

134  {
135  amxd_trans_t transaction;
136 
137  assert_int_equal(amxd_trans_init(&transaction), 0);
138  assert_int_equal(amxd_trans_select_pathf(&transaction, "NeMo.Intf."), 0);
139  assert_int_equal(amxd_trans_add_inst(&transaction, 99, "Inst1"), 0);
140  assert_int_equal(amxd_trans_apply(&transaction, &dm), 0);
141 
142  handle_events();
143 
144  assert_int_equal(system("ubus list NeMo.Intf.99"), 0);
145 
146  amxd_trans_clean(&transaction);
147 }
static void handle_events(void)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_ubus_new_root_objects_are_registered()

void test_ubus_new_root_objects_are_registered ( UNUSED void **  state)

Definition at line 149 of file test_amxb_ubus_register.c.

149  {
150  amxd_object_t* object = NULL;
151 
152  assert_int_equal(amxd_object_new(&object, amxd_object_singleton, "test_object"), 0);
153  assert_ptr_not_equal(object, NULL);
154  assert_int_equal(amxd_dm_add_root_object(&dm, object), 0);
155 
156  handle_events();
157 
158  assert_int_equal(system("ubus list test_object"), 0);
159 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_ubus_removed_objects_are_unregistered()

void test_ubus_removed_objects_are_unregistered ( UNUSED void **  state)

Definition at line 161 of file test_amxb_ubus_register.c.

161  {
162  amxd_trans_t transaction;
163 
164  assert_int_equal(amxd_trans_init(&transaction), 0);
165  assert_int_equal(amxd_trans_select_pathf(&transaction, "NeMo.Intf."), 0);
166  assert_int_equal(amxd_trans_del_inst(&transaction, 99, "Inst1"), 0);
167  assert_int_equal(amxd_trans_apply(&transaction, &dm), 0);
168 
169  handle_events();
170 
171  assert_int_not_equal(system("ubus list NeMo.Intf.99"), 0);
172 
173  amxd_trans_clean(&transaction);
174 }
Here is the call graph for this function:
Here is the caller graph for this function: