From 64c02cebbbecdae86b4cf5c605211a74c7883778 Mon Sep 17 00:00:00 2001 From: Amin Ben Romdhane Date: Thu, 20 Feb 2025 15:37:25 +0100 Subject: [PATCH] Fix pipeline --- .gitlab-ci.yml | 56 ++++++++++--------- bbfdmd/ubus/bbfdmd.c | 10 ++-- bbfdmd/ubus/cli.c | 6 +- bbfdmd/ubus/common.c | 8 ++- bbfdmd/ubus/get.c | 8 ++- bbfdmd/ubus/service.c | 8 ++- libbbfdm-api/legacy/dmbbf.c | 8 +-- test/cmocka/Makefile | 2 +- test/cmocka/functional_test_bbfd.c | 2 +- test/cmocka/unit_test_bbfd.c | 2 +- .../core}/X_IOPSYS_EU_Dropbear.json | 0 .../core}/X_IOPSYS_EU_JSON_TEST_V1.json | 0 .../core}/X_IOPSYS_EU_TEST.json | 0 .../core}/X_IOPSYS_EU_WiFi.json | 0 .../wifidmd}/x_iopsys_wifi_extension.json | 0 test/vendor_test/Makefile | 4 +- 16 files changed, 66 insertions(+), 48 deletions(-) rename test/files/usr/share/bbfdm/{plugins => micro_services/core}/X_IOPSYS_EU_Dropbear.json (100%) rename test/files/usr/share/bbfdm/{plugins => micro_services/core}/X_IOPSYS_EU_JSON_TEST_V1.json (100%) rename test/files/usr/share/bbfdm/{plugins => micro_services/core}/X_IOPSYS_EU_TEST.json (100%) rename test/files/usr/share/bbfdm/{plugins => micro_services/core}/X_IOPSYS_EU_WiFi.json (100%) rename test/files/usr/share/bbfdm/{plugins => micro_services/wifidmd}/x_iopsys_wifi_extension.json (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6fe503b9..f1de44ce 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/bbfdmd/ubus/bbfdmd.c b/bbfdmd/ubus/bbfdmd.c index eaeb530a..1d3b9037 100644 --- a/bbfdmd/ubus/bbfdmd.c +++ b/bbfdmd/ubus/bbfdmd.c @@ -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) { diff --git a/bbfdmd/ubus/cli.c b/bbfdmd/ubus/cli.c index d33c91bb..8fad9ee2 100644 --- a/bbfdmd/ubus/cli.c +++ b/bbfdmd/ubus/cli.c @@ -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; diff --git a/bbfdmd/ubus/common.c b/bbfdmd/ubus/common.c index 0e0494f9..deae68cd 100644 --- a/bbfdmd/ubus/common.c +++ b/bbfdmd/ubus/common.c @@ -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); diff --git a/bbfdmd/ubus/get.c b/bbfdmd/ubus/get.c index 0f8087d9..07c88347 100644 --- a/bbfdmd/ubus/get.c +++ b/bbfdmd/ubus/get.c @@ -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); diff --git a/bbfdmd/ubus/service.c b/bbfdmd/ubus/service.c index 33f30b42..2a2b5e7d 100644 --- a/bbfdmd/ubus/service.c +++ b/bbfdmd/ubus/service.c @@ -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); diff --git a/libbbfdm-api/legacy/dmbbf.c b/libbbfdm-api/legacy/dmbbf.c index 21e7d707..cc382842 100644 --- a/libbbfdm-api/legacy/dmbbf.c +++ b/libbbfdm-api/legacy/dmbbf.c @@ -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) { diff --git a/test/cmocka/Makefile b/test/cmocka/Makefile index 35823e3f..9668d970 100644 --- a/test/cmocka/Makefile +++ b/test/cmocka/Makefile @@ -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 diff --git a/test/cmocka/functional_test_bbfd.c b/test/cmocka/functional_test_bbfd.c index 6b1aa4cd..8518c4b6 100644 --- a/test/cmocka/functional_test_bbfd.c +++ b/test/cmocka/functional_test_bbfd.c @@ -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; } diff --git a/test/cmocka/unit_test_bbfd.c b/test/cmocka/unit_test_bbfd.c index d8dcb83c..cef3ad25 100644 --- a/test/cmocka/unit_test_bbfd.c +++ b/test/cmocka/unit_test_bbfd.c @@ -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; } diff --git a/test/files/usr/share/bbfdm/plugins/X_IOPSYS_EU_Dropbear.json b/test/files/usr/share/bbfdm/micro_services/core/X_IOPSYS_EU_Dropbear.json similarity index 100% rename from test/files/usr/share/bbfdm/plugins/X_IOPSYS_EU_Dropbear.json rename to test/files/usr/share/bbfdm/micro_services/core/X_IOPSYS_EU_Dropbear.json diff --git a/test/files/usr/share/bbfdm/plugins/X_IOPSYS_EU_JSON_TEST_V1.json b/test/files/usr/share/bbfdm/micro_services/core/X_IOPSYS_EU_JSON_TEST_V1.json similarity index 100% rename from test/files/usr/share/bbfdm/plugins/X_IOPSYS_EU_JSON_TEST_V1.json rename to test/files/usr/share/bbfdm/micro_services/core/X_IOPSYS_EU_JSON_TEST_V1.json diff --git a/test/files/usr/share/bbfdm/plugins/X_IOPSYS_EU_TEST.json b/test/files/usr/share/bbfdm/micro_services/core/X_IOPSYS_EU_TEST.json similarity index 100% rename from test/files/usr/share/bbfdm/plugins/X_IOPSYS_EU_TEST.json rename to test/files/usr/share/bbfdm/micro_services/core/X_IOPSYS_EU_TEST.json diff --git a/test/files/usr/share/bbfdm/plugins/X_IOPSYS_EU_WiFi.json b/test/files/usr/share/bbfdm/micro_services/core/X_IOPSYS_EU_WiFi.json similarity index 100% rename from test/files/usr/share/bbfdm/plugins/X_IOPSYS_EU_WiFi.json rename to test/files/usr/share/bbfdm/micro_services/core/X_IOPSYS_EU_WiFi.json diff --git a/test/files/usr/share/bbfdm/plugins/x_iopsys_wifi_extension.json b/test/files/usr/share/bbfdm/micro_services/wifidmd/x_iopsys_wifi_extension.json similarity index 100% rename from test/files/usr/share/bbfdm/plugins/x_iopsys_wifi_extension.json rename to test/files/usr/share/bbfdm/micro_services/wifidmd/x_iopsys_wifi_extension.json diff --git a/test/vendor_test/Makefile b/test/vendor_test/Makefile index e02de4cf..9d567309 100644 --- a/test/vendor_test/Makefile +++ b/test/vendor_test/Makefile @@ -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)