#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <signal.h>
#include <amxc/amxc.h>
#include <amxp/amxp.h>
#include <amxd/amxd_dm.h>
#include <amxb/amxb.h>
#include "test_amxb_ubus_subscribe.h"
Go to the source code of this file.
|
static amxb_bus_ctx_t * | bus_ctx = NULL |
|
◆ handle_events()
static void handle_events |
( |
void |
| ) |
|
|
static |
Definition at line 89 of file test_amxb_ubus_subscribe.c.
90 printf(
"Handling events \n");
94 while(amxp_signal_read() == 0) {
101 while(amxp_signal_read() == 0) {
static amxb_bus_ctx_t * bus_ctx
◆ test_amxb_ubus_get_socket()
static const char* test_amxb_ubus_get_socket |
( |
void |
| ) |
|
|
static |
Definition at line 78 of file test_amxb_ubus_subscribe.c.
80 if(stat(
"/var/run/ubus.sock", &sb) == 0) {
81 return "ubus:/var/run/ubus.sock";
83 if(stat(
"/var/run/ubus/ubus.sock", &sb) == 0) {
84 return "ubus:/var/run/ubus/ubus.sock";
◆ test_amxb_ubus_subscribe_setup()
int test_amxb_ubus_subscribe_setup |
( |
UNUSED void ** |
state | ) |
|
Definition at line 108 of file test_amxb_ubus_subscribe.c.
112 printf(
"Ubus socket = %s\n", ubus_sock);
115 sigaddset(&mask, SIGALRM);
117 sigprocmask(SIG_BLOCK, &mask, NULL);
120 amxc_string_init(&txt, 0);
122 amxp_sigmngr_add_signal(NULL,
"config:changed");
124 amxc_string_reset(&txt);
125 amxc_string_setf(&txt,
"amxrt -u ubus: -B ../mod-amxb-test-ubus.so -A ../test_data/test_nemo.odl &");
126 system(amxc_string_get(&txt, 0));
128 amxc_string_clean(&txt);
130 assert_int_equal(amxb_be_load(
"../mod-amxb-test-ubus.so"), 0);
131 assert_int_equal(amxb_connect(&
bus_ctx, ubus_sock), 0);
static const char * test_amxb_ubus_get_socket(void)
◆ test_amxb_ubus_subscribe_teardown()
int test_amxb_ubus_subscribe_teardown |
( |
UNUSED void ** |
state | ) |
|
◆ test_event_cb()
static void test_event_cb |
( |
UNUSED const char *const |
sig_name, |
|
|
UNUSED const amxc_var_t *const |
data, |
|
|
UNUSED void *const |
priv |
|
) |
| |
|
static |
◆ test_ubus_can_reactivate_subscriptions()
void test_ubus_can_reactivate_subscriptions |
( |
UNUSED void ** |
state | ) |
|
Definition at line 199 of file test_amxb_ubus_subscribe.c.
201 amxc_var_t* ubus_config = NULL;
206 amxc_var_init(&config);
207 amxc_var_set_type(&config, AMXC_VAR_ID_HTABLE);
208 ubus_config = amxc_var_add_key(amxc_htable_t, &config,
"ubus", NULL);
209 amxc_var_add_key(
bool, ubus_config,
"watch-ubus-events",
true);
210 amxb_set_config(&config);
211 amxp_sigmngr_trigger_signal(NULL,
"config:changed", NULL);
214 assert_int_equal(amxb_subscribe(
bus_ctx,
"NeMo.Intf.", NULL,
test_event_cb, NULL), AMXB_STATUS_OK);
216 system(
"killall amxrt");
218 amxp_timers_calculate();
221 system(
"amxrt -u ubus: -B ../mod-amxb-test-ubus.so -A ../test_data/test_nemo.odl &");
224 amxp_timers_calculate();
226 assert_int_equal(amxb_add(
bus_ctx,
"NeMo.Intf.", 7, NULL, NULL, &ret, 5), AMXB_STATUS_OK);
229 amxp_timers_calculate();
232 assert_int_equal(amxb_add(
bus_ctx,
"NeMo.Intf.", 8, NULL, NULL, &ret, 5), AMXB_STATUS_OK);
235 amxb_set_config(NULL);
236 amxc_var_clean(&config);
237 amxc_var_clean(&ret);
static void test_event_cb(UNUSED const char *const sig_name, UNUSED const amxc_var_t *const data, UNUSED void *const priv)
static void handle_events(void)
◆ test_ubus_can_subscribe()
void test_ubus_can_subscribe |
( |
UNUSED void ** |
state | ) |
|
Definition at line 155 of file test_amxb_ubus_subscribe.c.
162 assert_int_equal(amxb_subscribe(
bus_ctx,
"NeMo.Intf.", NULL,
test_event_cb, NULL), AMXB_STATUS_OK);
163 assert_int_equal(amxb_add(
bus_ctx,
"NeMo.Intf.", 5, NULL, NULL, &ret, 5), AMXB_STATUS_OK);
167 amxc_var_clean(&ret);
◆ test_ubus_can_unsubscribe()
void test_ubus_can_unsubscribe |
( |
UNUSED void ** |
state | ) |
|
◆ test_ubus_can_wait_for_object()
void test_ubus_can_wait_for_object |
( |
UNUSED void ** |
state | ) |
|
Definition at line 185 of file test_amxb_ubus_subscribe.c.
186 system(
"killall amxrt");
188 amxp_sigmngr_add_signal(NULL,
"wait:done");
189 amxp_slot_connect(NULL,
"wait:done", NULL,
test_event_cb, NULL);
190 assert_int_equal(amxb_wait_for_object(
"NeMo."), AMXB_STATUS_OK);
191 system(
"amxrt -u ubus: -B ../mod-amxb-test-ubus.so -A ../test_data/test_nemo.odl &");
◆ bus_ctx
amxb_bus_ctx_t* bus_ctx = NULL |
|
static |