diff --git a/c/src/meson.build b/c/src/meson.build index 62746ee0..d2932798 100644 --- a/c/src/meson.build +++ b/c/src/meson.build @@ -102,28 +102,29 @@ nns_capi_dep = declare_dependency(link_with: nns_capi_lib, # Service API if get_option('enable-ml-service') - ml_service_deps = [nns_capi_dep, ml_agent_deps] + ml_service_deps = [nns_capi_dep, ml_agent_dep, gio_dep, json_glib_dep] if support_remote_service ml_service_deps += [nnstreamer_edge_dep, curl_dep] endif + if get_option('enable-tizen') + ml_service_deps += dependency('capi-appfw-app-common') + endif nns_capi_service_shared_lib = shared_library ('capi-ml-service', nns_capi_service_srcs, dependencies: ml_service_deps, - include_directories: [nns_capi_include, ml_agent_incs], + include_directories: nns_capi_include, install: true, install_dir: api_install_libdir, - link_with: ml_agent_lib, - version: api_version, + version: api_version ) nns_capi_service_static_lib = static_library ('capi-ml-service', nns_capi_service_srcs, dependencies: ml_service_deps, - include_directories: [nns_capi_include, ml_agent_incs], + include_directories: nns_capi_include, install: true, - link_with: ml_agent_lib, - install_dir: api_install_libdir, + install_dir: api_install_libdir ) nns_capi_service_lib = nns_capi_service_shared_lib diff --git a/c/src/ml-api-service-private.h b/c/src/ml-api-service-private.h index 174db19c..efa63e3b 100644 --- a/c/src/ml-api-service-private.h +++ b/c/src/ml-api-service-private.h @@ -17,11 +17,6 @@ #include <ml-api-service.h> #include <ml-api-inference-internal.h> -#include "pipeline-dbus.h" -#include "model-dbus.h" -#include "resource-dbus.h" -#include "nnstreamer-tizen-internal.h" - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ diff --git a/c/src/ml-api-service-remote.c b/c/src/ml-api-service-remote.c index 18d9c704..c5c40ece 100644 --- a/c/src/ml-api-service-remote.c +++ b/c/src/ml-api-service-remote.c @@ -12,6 +12,7 @@ #include <glib.h> #include <glib/gstdio.h> +#include <gio/gio.h> #include <gst/gst.h> #include <gst/gstbuffer.h> #include <gst/app/app.h> @@ -23,6 +24,9 @@ #include "ml-api-service.h" #include "ml-api-service-private.h" +/** @todo remove this header after ACR for ml-remote API is done. */ +#include "nnstreamer-tizen-internal.h" + #define MAX_PORT_NUM_LEN 6U /** @@ -64,7 +68,7 @@ typedef struct ml_service_event_cb event_cb; void *user_data; - gchar *path; /** A path to save the received model file */ + gchar *path; /**< A path to save the received model file */ } _ml_remote_service_s; /** @@ -207,15 +211,9 @@ _mlrs_get_service_type (gchar * service_str) * @brief Get ml remote service activation type. */ static gboolean -_mlrs_parse_activate (gchar * activate) +_mlrs_parse_activate (const gchar * activate) { - gboolean ret = TRUE; - - if (g_ascii_strcasecmp (activate, "false") == 0) { - ret = FALSE; - } - - return ret; + return (activate && g_ascii_strcasecmp (activate, "true") == 0); } /** @@ -559,10 +557,10 @@ ml_service_remote_release_internal (void *priv) return ML_ERROR_INVALID_PARAMETER; nns_edge_release_handle (mlrs->edge_h); - g_free (mlrs->path); - /** Wait some time until release the edge handle. */ + /* Wait some time until release the edge handle. */ g_usleep (1000000); + g_free (mlrs->path); g_free (mlrs); return ML_ERROR_NONE; @@ -635,12 +633,12 @@ ml_service_remote_create (ml_option_h option, ml_service_event_cb cb, _mlrs_release_edge_info (edge_info); - return ret; + return ML_ERROR_NONE; } /** - * @brief Register new information, such as neural network models or pipeline descriptions, on a remote server. -*/ + * @brief Register new information, such as neural network models or pipeline descriptions, on a remote server. + */ int ml_service_remote_register (ml_service_h handle, ml_option_h option, void *data, size_t data_len) diff --git a/daemon/meson.build b/daemon/meson.build index 9e11e254..e9332646 100644 --- a/daemon/meson.build +++ b/daemon/meson.build @@ -84,9 +84,14 @@ ml_agent_static_lib = static_library('ml-agent', ml_agent_lib = ml_agent_shared_lib if get_option('default_library') == 'static' - ml_agent_lib = ml_agent_static_lib + ml_agent_lib = ml_agent_static_lib endif +ml_agent_dep = declare_dependency(link_with: ml_agent_lib, + dependencies: ml_agent_deps, + include_directories: ml_agent_incs +) + ml_agent_lib_common_objs = ml_agent_shared_lib.extract_objects(ml_agent_lib_common_srcs) ml_agent_test_both_lib = both_libraries('ml-agent-test', ml_agent_lib_service_db_srcs, @@ -102,7 +107,7 @@ ml_agent_test_both_lib = both_libraries('ml-agent-test', ml_agent_test_lib = ml_agent_test_both_lib.get_shared_lib() if get_option('default_library') == 'static' - ml_agent_test_lib = ml_agent_test_both_lib.get_static_lib() + ml_agent_test_lib = ml_agent_test_both_lib.get_static_lib() endif lib_ml_agent_test_dep = declare_dependency( diff --git a/meson.build b/meson.build index 0223fad7..ffba8edf 100644 --- a/meson.build +++ b/meson.build @@ -113,7 +113,7 @@ if get_option('enable-tizen') endif if get_option('enable-gcov') - add_project_arguments('-DENABLE_GCOV=1', language: ['c', 'cpp']) + add_project_arguments('-DENABLE_GCOV=1', language: ['c', 'cpp']) endif serviceDBPath = get_option('service-db-path') diff --git a/tests/capi/meson.build b/tests/capi/meson.build index 4df9451c..d6aecba9 100644 --- a/tests/capi/meson.build +++ b/tests/capi/meson.build @@ -2,8 +2,7 @@ unittest_capi_inference_single = executable('unittest_capi_inference_single', 'unittest_capi_inference_single.cc', dependencies: [nns_capi_single_dep, gtest_dep], install: get_option('install-test'), - install_dir: unittest_install_dir, - include_directories: nns_capi_include, + install_dir: unittest_install_dir ) test('unittest_capi_inference_single', unittest_capi_inference_single, env: testenv, timeout: 100) @@ -36,8 +35,7 @@ if get_option('enable-ml-service') 'unittest_capi_service_agent_client.cc', dependencies: [unittest_common_dep, nns_capi_service_dep, gdbus_gen_test_dep, lib_ml_agent_test_dep], install: get_option('install-test'), - install_dir: unittest_install_dir, - include_directories: nns_capi_include, + install_dir: unittest_install_dir ) test('unittest_capi_service_agent_client', unittest_capi_service_agent_client, env: testenv, timeout: 100) @@ -46,8 +44,7 @@ if get_option('enable-ml-service') 'unittest_capi_remote_service.cc', dependencies: [unittest_common_dep, nns_capi_service_dep, gdbus_gen_test_dep, lib_ml_agent_test_dep], install: get_option('install-test'), - install_dir: unittest_install_dir, - include_directories: nns_capi_include, + install_dir: unittest_install_dir ) test('unittest_capi_remote_service', unittest_capi_remote_service, env: testenv, timeout: 100) endif diff --git a/tests/capi/unittest_capi_remote_service.cc b/tests/capi/unittest_capi_remote_service.cc index 8bcc7a4a..e2d3e5c2 100644 --- a/tests/capi/unittest_capi_remote_service.cc +++ b/tests/capi/unittest_capi_remote_service.cc @@ -8,7 +8,6 @@ */ #include <gtest/gtest.h> -#include <gdbus-util.h> #include <gio/gio.h> #include <glib/gstdio.h> #include <ml-api-inference-pipeline-internal.h> @@ -19,6 +18,9 @@ #include <netinet/in.h> #include <netinet/tcp.h> +/** @todo remove this header after ACR for ml-remote API is done. */ +#include "nnstreamer-tizen-internal.h" + /** * @brief Test base class for Database of ML Service API. */ diff --git a/tests/capi/unittest_capi_service_agent_client.cc b/tests/capi/unittest_capi_service_agent_client.cc index a2ee547e..e7587701 100644 --- a/tests/capi/unittest_capi_service_agent_client.cc +++ b/tests/capi/unittest_capi_service_agent_client.cc @@ -8,7 +8,6 @@ */ #include <gtest/gtest.h> -#include <gdbus-util.h> #include <gio/gio.h> #include <ml-api-inference-pipeline-internal.h> #include <ml-api-internal.h> @@ -18,7 +17,8 @@ #include <netinet/in.h> #include <netinet/tcp.h> -#include "dbus-interface.h" +/** @todo remove below header after deleting ml-agent from api repo. */ +#include "gdbus-util.h" /** * @brief Test base class for Database of ML Service API. @@ -1280,112 +1280,6 @@ TEST_F (MLServiceAgentTest, model_scenario) g_free (test_model2); } -/** - * @brief Negative testcase of pipeline gdbus call. - */ -TEST_F (MLServiceAgentTest, pipeline_gdbus_call_n) -{ - int ret; - GError *error = NULL; - - MachinelearningServicePipeline *proxy_for_pipeline - = machinelearning_service_pipeline_proxy_new_for_bus_sync (bus_type, - G_DBUS_PROXY_FLAGS_NONE, DBUS_ML_BUS_NAME, DBUS_PIPELINE_PATH, NULL, &error); - - if (!proxy_for_pipeline || error) { - g_critical ("Failed to create proxy_for_pipeline for machinelearning service pipeline"); - if (error) { - g_critical ("Error Message : %s", error->message); - g_clear_error (&error); - } - ASSERT_TRUE (false); - } - - /* gdbus call with empty string */ - machinelearning_service_pipeline_call_set_pipeline_sync ( - proxy_for_pipeline, "", "", &ret, nullptr, nullptr); - EXPECT_EQ (ML_ERROR_INVALID_PARAMETER, ret); -} - -/** - * @brief Negative testcase of model gdbus call. - */ -TEST_F (MLServiceAgentTest, model_gdbus_call_n) -{ - int ret; - GError *error = NULL; - - MachinelearningServiceModel *proxy_for_model - = machinelearning_service_model_proxy_new_for_bus_sync (bus_type, - G_DBUS_PROXY_FLAGS_NONE, DBUS_ML_BUS_NAME, DBUS_MODEL_PATH, NULL, &error); - - if (!proxy_for_model || error) { - g_critical ("Failed to create proxy_for_model for machinelearning service model"); - if (error) { - g_critical ("Error Message : %s", error->message); - g_clear_error (&error); - } - ASSERT_TRUE (false); - } - - /* empty string */ - machinelearning_service_model_call_register_sync ( - proxy_for_model, "", "", false, "test", "", NULL, &ret, nullptr, nullptr); - EXPECT_EQ (ML_ERROR_INVALID_PARAMETER, ret); - - /* empty string */ - machinelearning_service_model_call_get_all_sync ( - proxy_for_model, "", NULL, &ret, nullptr, nullptr); - EXPECT_EQ (ML_ERROR_INVALID_PARAMETER, ret); - - g_object_unref (proxy_for_model); -} - -/** - * @brief Negative testcase of resource gdbus call. - */ -TEST_F (MLServiceAgentTest, resource_gdbus_call_n) -{ - int ret; - gchar *res_info = NULL; - GError *error = NULL; - - MachinelearningServiceResource *proxy_for_resource - = machinelearning_service_resource_proxy_new_for_bus_sync (bus_type, - G_DBUS_PROXY_FLAGS_NONE, DBUS_ML_BUS_NAME, DBUS_RESOURCE_PATH, NULL, &error); - - if (!proxy_for_resource || error) { - g_critical ("Failed to create proxy_for_resource for machinelearning service resource"); - if (error) { - g_critical ("Error Message : %s", error->message); - g_clear_error (&error); - } - ASSERT_TRUE (false); - } - - machinelearning_service_resource_call_add_sync ( - proxy_for_resource, "", "path", "description", "", &ret, nullptr, nullptr); - EXPECT_EQ (ML_ERROR_INVALID_PARAMETER, ret); - - machinelearning_service_resource_call_add_sync ( - proxy_for_resource, "name", "", "description", "", &ret, nullptr, nullptr); - EXPECT_EQ (ML_ERROR_INVALID_PARAMETER, ret); - - machinelearning_service_resource_call_get_sync ( - proxy_for_resource, "", &res_info, &ret, nullptr, nullptr); - EXPECT_EQ (ML_ERROR_INVALID_PARAMETER, ret); - - machinelearning_service_resource_call_get_sync ( - proxy_for_resource, "unknown", &res_info, &ret, nullptr, nullptr); - EXPECT_EQ (ML_ERROR_INVALID_PARAMETER, ret); - - machinelearning_service_resource_call_delete_sync ( - proxy_for_resource, "", &ret, nullptr, nullptr); - EXPECT_EQ (ML_ERROR_INVALID_PARAMETER, ret); - - g_object_unref (proxy_for_resource); -} - /** * @brief Test the usecase of ml_service for resource. */