Amxb_Ubus  3.3.1
Ambiorix Ubus API
test_amxb_ubus_list.c File Reference
#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_list.h"

Go to the source code of this file.

Functions

static const char * test_amxb_ubus_get_socket (void)
 
int test_amxb_ubus_list_setup (UNUSED void **state)
 
int test_amxb_ubus_list_teardown (UNUSED void **state)
 
static void test_list_cb (UNUSED const amxb_bus_ctx_t *bus_ctx, UNUSED const amxc_var_t *const data, UNUSED void *priv)
 
void test_ubus_can_list_amx_object (UNUSED void **state)
 

Variables

static amxb_bus_ctx_t * bus_ctx = NULL
 

Function Documentation

◆ test_amxb_ubus_get_socket()

static const char* test_amxb_ubus_get_socket ( void  )
static

Definition at line 78 of file test_amxb_ubus_list.c.

78  {
79  struct stat sb;
80  if(stat("/var/run/ubus.sock", &sb) == 0) {
81  return "ubus:/var/run/ubus.sock";
82  }
83  if(stat("/var/run/ubus/ubus.sock", &sb) == 0) {
84  return "ubus:/var/run/ubus/ubus.sock";
85  }
86  return NULL;
87 }
Here is the caller graph for this function:

◆ test_amxb_ubus_list_setup()

int test_amxb_ubus_list_setup ( UNUSED void **  state)

Definition at line 89 of file test_amxb_ubus_list.c.

89  {
90  amxc_string_t txt;
91  const char* ubus_sock = test_amxb_ubus_get_socket();
92  printf("Ubus socket = %s\n", ubus_sock);
93 
94  amxc_string_init(&txt, 0);
95 
96  amxc_string_reset(&txt);
97  amxc_string_setf(&txt, "amxrt -u ubus: -B ../mod-amxb-test-ubus.so -A ../test_data/test_nemo.odl &");
98  system(amxc_string_get(&txt, 0));
99 
100  // for some reason launching a native ubus application using the ubus
101  // lua bingdings causes a segfault in the gitlab-ci pipeline test job.
102  // so disable this for now
103  //amxc_string_setf(&txt, "lua5.1 ../test_data/publisher.lua > test.txt &");
104  //system(amxc_string_get(&txt, 0));
105 
106  amxc_string_clean(&txt);
107 
108  assert_int_equal(amxb_be_load("../mod-amxb-test-ubus.so"), 0);
109  assert_int_equal(amxb_connect(&bus_ctx, ubus_sock), 0);
110 
111  sleep(1);
112 
113  return 0;
114 }
static const char * test_amxb_ubus_get_socket(void)
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_list_teardown()

int test_amxb_ubus_list_teardown ( UNUSED void **  state)

Definition at line 116 of file test_amxb_ubus_list.c.

116  {
117  amxb_disconnect(bus_ctx);
118  amxb_free(&bus_ctx);
119 
120  system("killall amxrt");
121  system("killall lua5.1");
122 
123  amxb_be_remove_all();
124  unlink("test_config.odl");
125 
126  return 0;
127 }
Here is the caller graph for this function:

◆ test_list_cb()

static void test_list_cb ( UNUSED const amxb_bus_ctx_t *  bus_ctx,
UNUSED const amxc_var_t *const  data,
UNUSED void *  priv 
)
static

Definition at line 129 of file test_amxb_ubus_list.c.

131  {
132 }
Here is the caller graph for this function:

◆ test_ubus_can_list_amx_object()

void test_ubus_can_list_amx_object ( UNUSED void **  state)

Definition at line 134 of file test_amxb_ubus_list.c.

134  {
135  int all_flags = AMXB_FLAG_FUNCTIONS | AMXB_FLAG_PARAMETERS | AMXB_FLAG_OBJECTS | AMXB_FLAG_INSTANCES;
136  assert_int_equal(amxb_list(bus_ctx, "NeMo.Intf.", all_flags, test_list_cb, NULL), AMXB_STATUS_OK);
137  assert_int_equal(amxb_list(bus_ctx, "NeMo.Intf", all_flags, test_list_cb, NULL), AMXB_STATUS_OK);
138  assert_int_equal(amxb_list(bus_ctx, "NeMo.Intf.", all_flags | AMXB_FLAG_FIRST_LVL, test_list_cb, NULL), AMXB_STATUS_OK);
139  assert_int_equal(amxb_list(bus_ctx, NULL, all_flags, test_list_cb, NULL), AMXB_STATUS_OK);
140  assert_int_equal(amxb_list(bus_ctx, "", all_flags, test_list_cb, NULL), AMXB_STATUS_OK);
141 
142  // enable this two lines as soon as the problem with native ubus app using lua bindings is solved
143  //assert_int_equal(amxb_list(bus_ctx, "com.", all_flags | AMXB_FLAG_FIRST_LVL, test_list_cb, NULL), AMXB_STATUS_OK);
144  //assert_int_equal(amxb_list(bus_ctx, "com.broadcom.gpon_md", all_flags | AMXB_FLAG_FIRST_LVL, test_list_cb, NULL), AMXB_STATUS_OK);
145 }
static void test_list_cb(UNUSED const amxb_bus_ctx_t *bus_ctx, UNUSED const amxc_var_t *const data, UNUSED void *priv)
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ bus_ctx

amxb_bus_ctx_t* bus_ctx = NULL
static

Definition at line 76 of file test_amxb_ubus_list.c.