Fix pipeline

This commit is contained in:
Amin Ben Romdhane 2025-02-20 15:37:25 +01:00
parent 89cc2bce1d
commit 64c02cebbb
16 changed files with 66 additions and 48 deletions

View file

@ -16,23 +16,24 @@ include:
stages:
- static_code_analysis
# - unit_test
- unit_test
- functional_test
- deploy
#run_unit_test:
# stage: unit_test
# image: ${COMMON_IMAGE}
# allow_failure: false
# script:
# - "./gitlab-ci/pipeline_setup.sh"
# - "./gitlab-ci/install-dependencies.sh ms"
# - "./gitlab-ci/setup.sh ms"
# - "./gitlab-ci/unit-test.sh"
# artifacts:
# when: always
# paths:
# - unit-test-coverage.xml
run_unit_test:
stage: unit_test
image: ${COMMON_IMAGE}
allow_failure: false
script:
- "./gitlab-ci/pipeline_setup.sh"
- "./gitlab-ci/install-dependencies.sh ms"
- "./gitlab-ci/setup.sh ms"
- "./gitlab-ci/unit-test.sh"
artifacts:
when: always
paths:
- unit-test-coverage.xml
#run_tools_test:
# stage: unit_test
@ -49,6 +50,7 @@ stages:
# - "./gitlab-ci/setup.sh ms"
# - "./gitlab-ci/tools-test.sh"
# - "./gitlab-ci/generate_supported_dm.sh"
# artifacts:
# when: always
# paths:
@ -71,20 +73,20 @@ run_libbbfdm_api_functional_test:
paths:
- functional-api-test-coverage.xml
#run_libbbfdm_functional_test:
# stage: functional_test
# image: ${COMMON_IMAGE}
# allow_failure: false
# script:
# - "./gitlab-ci/pipeline_setup.sh"
# - "./gitlab-ci/install-dependencies.sh ms"
# - "./gitlab-ci/setup.sh ms"
# - "./gitlab-ci/functional-test.sh"
run_libbbfdm_functional_test:
stage: functional_test
image: ${COMMON_IMAGE}
allow_failure: false
script:
- "./gitlab-ci/pipeline_setup.sh"
- "./gitlab-ci/install-dependencies.sh ms"
- "./gitlab-ci/setup.sh ms"
- "./gitlab-ci/functional-test.sh"
# artifacts:
# when: always
# paths:
# - functional-test-coverage.xml
artifacts:
when: always
paths:
- functional-test-coverage.xml
run_libbbfdm_memory_test:
stage: functional_test

View file

@ -25,6 +25,7 @@
#include "cli.h"
extern struct list_head registered_services;
extern int g_log_level;
static const struct blobmsg_policy bbfdm_policy[] = {
[BBFDM_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING },
@ -189,7 +190,6 @@ int main(int argc, char **argv)
{
struct ubus_context ubus_ctx = {0};
char *cli_argv[4] = {0};
int log_level = LOG_ERR;
int err = 0, ch, cli_argc = 0, i;
while ((ch = getopt(argc, argv, "hc:l:")) != -1) {
@ -202,9 +202,9 @@ int main(int argc, char **argv)
break;
case 'l':
if (optarg) {
log_level = (int)strtod(optarg, NULL);
if (log_level < 0 || log_level > 7)
log_level = 3;
g_log_level = (int)strtod(optarg, NULL);
if (g_log_level < 0 || g_log_level > 7)
g_log_level = 3;
}
break;
case 'h':
@ -221,7 +221,7 @@ int main(int argc, char **argv)
openlog(BBFDM_UBUS_OBJECT, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
setlogmask(LOG_UPTO(log_level));
setlogmask(LOG_UPTO(g_log_level));
err = ubus_connect_ctx(&ubus_ctx, NULL);
if (err != UBUS_STATUS_OK) {

View file

@ -140,10 +140,8 @@ static void __ubus_callback(struct ubus_request *req, int msgtype __attribute__(
} else if (strcmp(cli_data->cmd, "instances") == 0) {
printf("%s\n", name);
} else if (strcmp(cli_data->cmd, "schema") == 0) {
//char *type = tb[2] ? blobmsg_get_string(tb[2]) : "";
//int cmd = get_dm_type(type);
//printf("%s %s %s\n", name, type, (cmd != DMT_EVENT && cmd != DMT_COMMAND) ? data : "0"); //TODO
char *type = tb[2] ? blobmsg_get_string(tb[2]) : "xsd:string";
printf("%s %s\n", name, type);
}
cli_data->ubus_status = true;

View file

@ -14,6 +14,8 @@
#include "common.h"
int g_log_level = LOG_ERR;
unsigned int get_proto_type(const char *proto)
{
int type = BBFDMD_BOTH;
@ -126,7 +128,11 @@ void run_sync_call(const char *ubus_obj, const char *ubus_method, struct blob_at
}
}
//BBFDM_DEBUG("### ubus call %s %s '%s' ###", ubus_obj, ubus_method, blobmsg_format_json_indent(req_buf.head, true, -1));
if (g_log_level == LOG_DEBUG) {
char *json_str = blobmsg_format_json_indent(req_buf.head, true, -1);
BBFDM_DEBUG("### ubus call %s %s '%s' ###", ubus_obj, ubus_method, json_str);
BBFDM_FREE(json_str);
}
BBFDM_UBUS_INVOKE_SYNC(ubus_obj, ubus_method, req_buf.head, 2000, sync_callback, bb_response);

View file

@ -16,6 +16,8 @@
#include "service.h"
#include "get.h"
extern int g_log_level;
static void add_linker_entry(struct async_request_context *ctx, const char *linker_path, const char *linker_value)
{
struct linker_args *linker = calloc(1, sizeof(struct linker_args));
@ -297,7 +299,11 @@ void run_async_call(struct async_request_context *ctx, const char *ubus_obj, str
tracker->timeout.cb = handle_request_timeout;
uloop_timeout_set(&tracker->timeout, SERVICE_CALL_TIMEOUT);
//BBFDM_DEBUG("### ubus call %s %s '%s' ###", ubus_obj, ctx->ubus_method, blobmsg_format_json_indent(req_buf.head, true, -1));
if (g_log_level == LOG_DEBUG) {
char *json_str = blobmsg_format_json_indent(req_buf.head, true, -1);
BBFDM_DEBUG("### ubus call %s %s '%s' ###", ubus_obj, ctx->ubus_method, json_str);
BBFDM_FREE(json_str);
}
if (ubus_invoke_async(ctx->ubus_ctx, id, ctx->ubus_method, req_buf.head, &tracker->async_request)) {
BBFDM_ERR("Failed to invoke async method for object: %s", tracker->request_name);

View file

@ -22,6 +22,8 @@
LIST_HEAD(registered_services);
extern int g_log_level;
static void add_service_to_list(const char *name, int service_proto, service_object_t *objects, size_t count, bool is_unified)
{
service_entry_t *service = NULL;
@ -303,7 +305,11 @@ char *get_reference_data(const char *path, const char *method_name)
blobmsg_add_string(&req_buf, "path", path);
//BBFDM_DEBUG("### ubus call %s %s '%s' ###", ubus_obj, method_name, blobmsg_format_json_indent(req_buf.head, true, -1));
if (g_log_level == LOG_DEBUG) {
char *json_str = blobmsg_format_json_indent(req_buf.head, true, -1);
BBFDM_DEBUG("### ubus call %s %s '%s' ###", ubus_obj, method_name, json_str);
BBFDM_FREE(json_str);
}
BBFDM_UBUS_INVOKE_SYNC(ubus_obj, method_name, req_buf.head, 2000, reference_data_callback, &reference_value);

View file

@ -187,7 +187,7 @@ static int plugin_leaf_onlyobj_match(DMOBJECT_ARGS)
static int plugin_obj_nextlevel_match(DMOBJECT_ARGS)
{
if (strcmp(dmctx->in_param, "Device") == 0 && strcmp(dmctx->in_value, "core") != 0)
if (DM_STRCMP(dmctx->in_param, "Device") == 0 && DM_STRCMP(dmctx->in_value, "core") != 0)
return FAULT_9005;
unsigned int current_object_dot_num = count_occurrences(node->current_object, '.');
@ -268,7 +268,7 @@ static int plugin_leaf_wildcard_match(DMOBJECT_ARGS)
static int plugin_obj_wildcard_nextlevel_match(DMOBJECT_ARGS)
{
if (strcmp(dmctx->in_param, "Device") == 0 && strcmp(dmctx->in_value, "core") != 0)
if (DM_STRCMP(dmctx->in_param, "Device") == 0 && DM_STRCMP(dmctx->in_value, "core") != 0)
return FAULT_9005;
unsigned int current_object_dot_num = count_occurrences(node->current_object, '.');
@ -1117,7 +1117,7 @@ static int mobj_get_name(DMOBJECT_ARGS)
char *refparam = node->current_object;
char *perm = permission->val;
if (strcmp(node->current_object, ROOT_NODE) == 0 && strcmp(dmctx->in_value, "core") != 0)
if (DM_STRCMP(node->current_object, ROOT_NODE) == 0 && DM_STRCMP(dmctx->in_value, "core") != 0)
return 0;
if (permission->get_permission != NULL)
@ -1201,7 +1201,7 @@ static int mobj_get_name_in_obj(DMOBJECT_ARGS)
if (!node->matched)
return FAULT_9005;
if (strcmp(node->current_object, ROOT_NODE) == 0 && strcmp(dmctx->in_value, "core") != 0)
if (DM_STRCMP(node->current_object, ROOT_NODE) == 0 && DM_STRCMP(dmctx->in_value, "core") != 0)
return 0;
if (dmctx->iswildcard) {

View file

@ -1,6 +1,6 @@
CC = gcc
CFLAGS = -g -Wall
LDFLAGS = -lcmocka -lbbfdm-api -lbbfdm -lubox -lblobmsg_json -ljson-c -lssl -lcrypto --coverage
LDFLAGS = -lcmocka -lbbfdm-api -lcore -lubox -lblobmsg_json -ljson-c -lssl -lcrypto --coverage
UNIT_TESTS = unit_test_bbfd
FUNCTIONAL_TESTS = functional_test_bbfd
FUNCTIONAL_API_TESTS = functional_api_test_bbfd

View file

@ -42,7 +42,7 @@ static int teardown_commit(void **state)
static int group_init(void **state)
{
bbf_global_init(TR181_ROOT_TREE, "/usr/share/bbfdm/plugins");
bbf_global_init(TR181_ROOT_TREE, "/usr/share/bbfdm/micro_services/core");
return 0;
}

View file

@ -54,7 +54,7 @@ static int teardown_revert(void **state)
static int group_init(void **state)
{
bbf_global_init(TR181_ROOT_TREE, "/usr/share/bbfdm/plugins");
bbf_global_init(TR181_ROOT_TREE, "/usr/share/bbfdm/micro_services/core");
return 0;
}

View file

@ -13,8 +13,8 @@ $(LIB): $(LIB_OBJS)
$(CC) $(LIB_CFLAGS) $(LIB_LDFLAGS) -shared -o $@ $^
install:
cp -f $(LIB) /usr/share/bbfdm/plugins/
cp -f *.json /usr/share/bbfdm/plugins
cp -f $(LIB) /usr/share/bbfdm/micro_services/core/
cp -f *.json /usr/share/bbfdm/micro_services/core/
clean:
rm -fv *.o $(LIB)