[Build/Pkg] Rename spec and manifest files
authorSangjung Woo <sangjung.woo@samsung.com>
Mon, 5 Feb 2024 08:53:32 +0000 (17:53 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Thu, 8 Feb 2024 07:20:48 +0000 (16:20 +0900)
This patch renames spec and manifest files to mlops-agent.spec and
mlops-agent.manifest. It also update the package name with the'mlops-agent'.
However, the name of D-Bus service is not changed since this channel is
also used as Service API.

Signed-off-by: Sangjung Woo <sangjung.woo@samsung.com>
23 files changed:
daemon/include/meson.build
daemon/include/ml-agent-interface.h [deleted file]
daemon/include/mlops-agent-interface.h [new file with mode: 0755]
daemon/meson.build
daemon/ml-agent-interface.c [deleted file]
daemon/ml-agent.pc.in [deleted file]
daemon/mlops-agent-interface.c [new file with mode: 0755]
daemon/mlops-agent.pc.in [new file with mode: 0755]
dbus/machine-learning-agent.conf.in [deleted file]
dbus/machine-learning-agent.service.in [deleted file]
dbus/meson.build
dbus/mlops-agent.conf.in [new file with mode: 0644]
dbus/mlops-agent.service.in [new file with mode: 0644]
dbus/org.tizen.machinelearning.service.service.in
packaging/machine-learning-agent.manifest [deleted file]
packaging/machine-learning-agent.spec [deleted file]
packaging/mlops-agent.manifest [new file with mode: 0644]
packaging/mlops-agent.spec [new file with mode: 0644]
tests/daemon/meson.build
tests/daemon/unittest_ml_agent.cc [deleted file]
tests/daemon/unittest_mlops_agent.cc [new file with mode: 0644]
tests/meson.build
tests/services/org.tizen.machinelearning.service.service.in

index 8f4738b25dd24b87eae8ec72c6cc0c81b054ecf7..5b34eb67f66e175b521c3cc829f2a0fe50fe684c 100755 (executable)
@@ -1,5 +1,5 @@
-ml_agent_headers = files('ml-agent-interface.h')
+ml_agent_headers = files('mlops-agent-interface.h')
 
 install_headers(ml_agent_headers,
-  subdir: 'ml-agent'
+  subdir: 'ml'
 )
diff --git a/daemon/include/ml-agent-interface.h b/daemon/include/ml-agent-interface.h
deleted file mode 100755 (executable)
index 035b003..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/* SPDX-License-Identifier: Apache-2.0 */
-/**
- * @file    ml-agent-interface.h
- * @date    5 April 2023
- * @brief   A set of exported ml-agent interfaces for managing pipelines, models, and other service.
- * @see     https://github.com/nnstreamer/deviceMLOps.MLAgent
- * @author  Wook Song <wook16.song@samsung.com>
- * @bug     No known bugs except for NYI items
- */
-
-#ifndef __ML_AGENT_INTERFACE_H__
-#define __ML_AGENT_INTERFACE_H__
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#include <glib.h>
-
-/**
- * @brief An interface exported for setting the description of a pipeline.
- * @param[in] name A name indicating the pipeline whose description would be set.
- * @param[in] pipeline_desc A stringified description of the pipeline.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_pipeline_set_description (const gchar *name, const gchar *pipeline_desc, GError **err);
-
-/**
- * @brief An interface exported for getting the pipeline's description corresponding to the given @a name.
- * @remarks If the function succeeds, @a pipeline_desc should be released using g_free().
- * @param[in] name A given name of the pipeline to get the description.
- * @param[out] pipeline_desc A stringified description of the pipeline.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_pipeline_get_description (const gchar *name, gchar **pipeline_desc, GError **err);
-
-/**
- * @brief An interface exported for deletion of the pipeline's description corresponding to the given @a name.
- * @param[in] name A given name of the pipeline to remove the description.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_pipeline_delete (const gchar *name, GError **err);
-
-/**
- * @brief An interface exported for launching the pipeline's description corresponding to the given @a name.
- * @param[in] name A given name of the pipeline to launch.
- * @param[out] id A pointer of integer identifier for the launched pipeline.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_pipeline_launch (const gchar *name, gint64 *id, GError **err);
-
-/**
- * @brief An interface exported for changing the pipeline's state of the given @a id to start.
- * @param[in] id An identifier of the launched pipeline whose state would be changed to start.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_pipeline_start (const gint64 id, GError **err);
-
-/**
- * @brief An interface exported for changing the pipeline's state of the given @a id to stop.
- * @param[in] id An identifier of the launched pipeline whose state would be changed to stop.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_pipeline_stop (const gint64 id, GError **err);
-
-/**
- * @brief An interface exported for destroying a launched pipeline corresponding to the given @a id.
- * @param[in] id An identifier of the launched pipeline that would be destroyed.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_pipeline_destroy (const gint64 id, GError **err);
-
-/**
- * @brief An interface exported for getting the pipeline's state of the given @a id.
- * @param[in] id An identifier of the launched pipeline that would be destroyed.
- * @param[out] state A pointer for the pipeline's state.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_pipeline_get_state (const gint64 id, gint *state, GError **err);
-
-/**
- * @brief An interface exported for registering a model.
- * @param[in] name A name indicating the model that would be registered.
- * @param[in] path A path that specifies the location of the model file.
- * @param[in] activate An initial activation state.
- * @param[in] description A stringified description of the given model.
- * @param[in] app_info Application-specific information from Tizen's RPK.
- * @param[out] version A pointer for the version of the given model registered.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_model_register(const gchar *name, const gchar *path, const gboolean activate, const gchar *description, const gchar *app_info, guint *version, GError **err);
-
-/**
- * @brief An interface exported for updating the description of the model with @a name and @a version.
- * @param[in] name A name indicating the model whose description would be updated.
- * @param[in] version A version for identifying the model whose description would be updated.
- * @param[in] description A new description to update the existing one.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_model_update_description (const gchar *name, const guint version, const gchar *description, GError **err);
-
-/**
- * @brief An interface exported for activating the model with @a name and @a version.
- * @param[in] name A name indicating a registered model.
- * @param[in] version A version of the given model, @a name.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_model_activate(const gchar *name, const guint version, GError **err);
-
-/**
- * @brief An interface exported for getting the information of the model with @a name and @a version.
- * @remarks If the function succeeds, @a model_info should be released using g_free().
- * @param[in] name A name indicating the model whose description would be get.
- * @param[in] version A version of the given model.
- * @param[out] model_info A pointer for the information of the given model of @a name and @a version.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_model_get(const gchar *name, const guint version, gchar **model_info, GError **err);
-
-/**
- * @brief An interface exported for getting the information of the activated model with @a name.
- * @remarks If the function succeeds, @a model_info should be released using g_free().
- * @param[in] name A name indicating the model whose description would be get.
- * @param[out] model_info A pointer for the information of an activated model of the given @a name.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_model_get_activated(const gchar *name, gchar **model_info, GError **err);
-
-/**
- * @brief An interface exported for getting the information of all the models corresponding to the given @a name.
- * @remarks If the function succeeds, @a model_info should be released using g_free().
- * @param[in] name A name indicating the models whose description would be get.
- * @param[out] model_info A pointer for the information of all the models corresponding to the given @a name.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_model_get_all(const gchar *name, gchar **model_info, GError **err);
-
-/**
- * @brief An interface exported for removing the model of @a name and @a version.
- * @details If version is 0, this function removes all registered model of @a name.
- * @param[in] name A name indicating the model that would be removed.
- * @param[in] version A version for identifying a specific model.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_model_delete(const gchar *name, const guint version, GError **err);
-
-/**
- * @brief An interface exported for adding the resource.
- * @param[in] name A name indicating the resource.
- * @param[in] path A path that specifies the location of the resource.
- * @param[in] description A stringified description of the resource.
- * @param[in] app_info Application-specific information from Tizen's RPK.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_resource_add (const gchar *name, const gchar *path, const gchar *description, const gchar *app_info, GError **err);
-
-/**
- * @brief An interface exported for removing the resource with @a name.
- * @param[in] name A name indicating the resource.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_resource_delete (const gchar *name, GError **err);
-
-/**
- * @brief An interface exported for getting the description of the resource with @a name.
- * @remarks If the function succeeds, @a res_info should be released using g_free().
- * @param[in] name A name indicating the resource.
- * @param[out] res_info A pointer for the information of the resource.
- * @param[out] err A pointer for error, or NULL.
- * @return 0 on success, a negative error value if failed.
- */
-gint ml_agent_resource_get (const gchar *name, gchar **res_info, GError **err);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* __ML_AGENT_INTERFACE_H__ */
diff --git a/daemon/include/mlops-agent-interface.h b/daemon/include/mlops-agent-interface.h
new file mode 100755 (executable)
index 0000000..a33a0ee
--- /dev/null
@@ -0,0 +1,193 @@
+/* SPDX-License-Identifier: Apache-2.0 */
+/**
+ * @file    mlops-agent-interface.h
+ * @date    5 April 2023
+ * @brief   A set of exported ml-agent interfaces for managing pipelines, models, and other service.
+ * @see     https://github.com/nnstreamer/deviceMLOps.MLAgent
+ * @author  Wook Song <wook16.song@samsung.com>
+ * @bug     No known bugs except for NYI items
+ */
+
+#ifndef __MLOPS_AGENT_INTERFACE_H__
+#define __MLOPS_AGENT_INTERFACE_H__
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <glib.h>
+
+/**
+ * @brief An interface exported for setting the description of a pipeline.
+ * @param[in] name A name indicating the pipeline whose description would be set.
+ * @param[in] pipeline_desc A stringified description of the pipeline.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_pipeline_set_description (const gchar *name, const gchar *pipeline_desc, GError **err);
+
+/**
+ * @brief An interface exported for getting the pipeline's description corresponding to the given @a name.
+ * @remarks If the function succeeds, @a pipeline_desc should be released using g_free().
+ * @param[in] name A given name of the pipeline to get the description.
+ * @param[out] pipeline_desc A stringified description of the pipeline.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_pipeline_get_description (const gchar *name, gchar **pipeline_desc, GError **err);
+
+/**
+ * @brief An interface exported for deletion of the pipeline's description corresponding to the given @a name.
+ * @param[in] name A given name of the pipeline to remove the description.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_pipeline_delete (const gchar *name, GError **err);
+
+/**
+ * @brief An interface exported for launching the pipeline's description corresponding to the given @a name.
+ * @param[in] name A given name of the pipeline to launch.
+ * @param[out] id A pointer of integer identifier for the launched pipeline.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_pipeline_launch (const gchar *name, gint64 *id, GError **err);
+
+/**
+ * @brief An interface exported for changing the pipeline's state of the given @a id to start.
+ * @param[in] id An identifier of the launched pipeline whose state would be changed to start.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_pipeline_start (const gint64 id, GError **err);
+
+/**
+ * @brief An interface exported for changing the pipeline's state of the given @a id to stop.
+ * @param[in] id An identifier of the launched pipeline whose state would be changed to stop.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_pipeline_stop (const gint64 id, GError **err);
+
+/**
+ * @brief An interface exported for destroying a launched pipeline corresponding to the given @a id.
+ * @param[in] id An identifier of the launched pipeline that would be destroyed.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_pipeline_destroy (const gint64 id, GError **err);
+
+/**
+ * @brief An interface exported for getting the pipeline's state of the given @a id.
+ * @param[in] id An identifier of the launched pipeline that would be destroyed.
+ * @param[out] state A pointer for the pipeline's state.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_pipeline_get_state (const gint64 id, gint *state, GError **err);
+
+/**
+ * @brief An interface exported for registering a model.
+ * @param[in] name A name indicating the model that would be registered.
+ * @param[in] path A path that specifies the location of the model file.
+ * @param[in] activate An initial activation state.
+ * @param[in] description A stringified description of the given model.
+ * @param[in] app_info Application-specific information from Tizen's RPK.
+ * @param[out] version A pointer for the version of the given model registered.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_model_register(const gchar *name, const gchar *path, const gboolean activate, const gchar *description, const gchar *app_info, guint *version, GError **err);
+
+/**
+ * @brief An interface exported for updating the description of the model with @a name and @a version.
+ * @param[in] name A name indicating the model whose description would be updated.
+ * @param[in] version A version for identifying the model whose description would be updated.
+ * @param[in] description A new description to update the existing one.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_model_update_description (const gchar *name, const guint version, const gchar *description, GError **err);
+
+/**
+ * @brief An interface exported for activating the model with @a name and @a version.
+ * @param[in] name A name indicating a registered model.
+ * @param[in] version A version of the given model, @a name.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_model_activate(const gchar *name, const guint version, GError **err);
+
+/**
+ * @brief An interface exported for getting the information of the model with @a name and @a version.
+ * @remarks If the function succeeds, @a model_info should be released using g_free().
+ * @param[in] name A name indicating the model whose description would be get.
+ * @param[in] version A version of the given model.
+ * @param[out] model_info A pointer for the information of the given model of @a name and @a version.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_model_get(const gchar *name, const guint version, gchar **model_info, GError **err);
+
+/**
+ * @brief An interface exported for getting the information of the activated model with @a name.
+ * @remarks If the function succeeds, @a model_info should be released using g_free().
+ * @param[in] name A name indicating the model whose description would be get.
+ * @param[out] model_info A pointer for the information of an activated model of the given @a name.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_model_get_activated(const gchar *name, gchar **model_info, GError **err);
+
+/**
+ * @brief An interface exported for getting the information of all the models corresponding to the given @a name.
+ * @remarks If the function succeeds, @a model_info should be released using g_free().
+ * @param[in] name A name indicating the models whose description would be get.
+ * @param[out] model_info A pointer for the information of all the models corresponding to the given @a name.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_model_get_all(const gchar *name, gchar **model_info, GError **err);
+
+/**
+ * @brief An interface exported for removing the model of @a name and @a version.
+ * @details If version is 0, this function removes all registered model of @a name.
+ * @param[in] name A name indicating the model that would be removed.
+ * @param[in] version A version for identifying a specific model.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_model_delete(const gchar *name, const guint version, GError **err);
+
+/**
+ * @brief An interface exported for adding the resource.
+ * @param[in] name A name indicating the resource.
+ * @param[in] path A path that specifies the location of the resource.
+ * @param[in] description A stringified description of the resource.
+ * @param[in] app_info Application-specific information from Tizen's RPK.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_resource_add (const gchar *name, const gchar *path, const gchar *description, const gchar *app_info, GError **err);
+
+/**
+ * @brief An interface exported for removing the resource with @a name.
+ * @param[in] name A name indicating the resource.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_resource_delete (const gchar *name, GError **err);
+
+/**
+ * @brief An interface exported for getting the description of the resource with @a name.
+ * @remarks If the function succeeds, @a res_info should be released using g_free().
+ * @param[in] name A name indicating the resource.
+ * @param[out] res_info A pointer for the information of the resource.
+ * @param[out] err A pointer for error, or NULL.
+ * @return 0 on success, a negative error value if failed.
+ */
+gint ml_agent_resource_get (const gchar *name, gchar **res_info, GError **err);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __MLOPS_AGENT_INTERFACE_H__ */
index 3b6db6a594293ba967150f888d7bbab05c5e8c49..632beb4d0dddb091088c310358475550c072ed70 100644 (file)
@@ -1,6 +1,6 @@
 # Machine Learning Agent
 ml_agent_incs = include_directories('.', 'include')
-ml_agent_lib_srcs = files('modules.c', 'gdbus-util.c', 'ml-agent-interface.c',
+ml_agent_lib_srcs = files('modules.c', 'gdbus-util.c', 'mlops-agent-interface.c',
   'pipeline-dbus-impl.cc', 'model-dbus-impl.cc', 'resource-dbus-impl.cc', 'service-db.cc')
 
 if (get_option('enable-tizen'))
@@ -31,7 +31,7 @@ ml_agent_db_path_arg = '-DDB_PATH="' + serviceDBPath + '"'
 serviceDBKeyPrefix = get_option('service-db-key-prefix')
 ml_agent_db_key_prefix_arg = '-DDB_KEY_PREFIX="' + serviceDBKeyPrefix + '"'
 
-ml_agent_shared_lib = shared_library ('ml-agent',
+ml_agent_shared_lib = shared_library ('mlops-agent',
   ml_agent_lib_srcs,
   dependencies: ml_agent_deps,
   include_directories: ml_agent_incs,
@@ -41,7 +41,7 @@ ml_agent_shared_lib = shared_library ('ml-agent',
   version: ml_agent_version,
 )
 
-ml_agent_static_lib = static_library('ml-agent',
+ml_agent_static_lib = static_library('mlops-agent',
   ml_agent_lib_srcs,
   dependencies: ml_agent_deps,
   include_directories: ml_agent_incs,
@@ -63,7 +63,7 @@ ml_agent_dep = declare_dependency(
 )
 
 ml_agent_main_file = files('main.c')
-ml_agent_executable = executable('machine-learning-agent',
+ml_agent_executable = executable('mlops-agent',
   ml_agent_main_file,
   dependencies: ml_agent_dep,
   install: true,
@@ -72,7 +72,7 @@ ml_agent_executable = executable('machine-learning-agent',
   pie: true
 )
 
-configure_file(input: 'ml-agent.pc.in', output: 'ml-agent.pc',
+configure_file(input: 'mlops-agent.pc.in', output: 'mlops-agent.pc',
   install_dir: join_paths(ml_agent_install_libdir, 'pkgconfig'),
   configuration: ml_agent_conf
 )
diff --git a/daemon/ml-agent-interface.c b/daemon/ml-agent-interface.c
deleted file mode 100755 (executable)
index 6507961..0000000
+++ /dev/null
@@ -1,588 +0,0 @@
-/* SPDX-License-Identifier: Apache-2.0 */
-/**
- * @file    ml-agent-interface.c
- * @date    5 April 2023
- * @brief   A set of exported ml-agent interfaces for managing pipelines, models, and other service.
- * @see     https://github.com/nnstreamer/deviceMLOps.MLAgent
- * @author  Wook Song <wook16.song@samsung.com>
- * @bug     No known bugs except for NYI items
- */
-
-#include <errno.h>
-#include <glib.h>
-
-#include "include/ml-agent-interface.h"
-#include "dbus-interface.h"
-#include "model-dbus.h"
-#include "pipeline-dbus.h"
-#include "resource-dbus.h"
-
-#define STR_IS_VALID(s) ((s) && (s)[0] != '\0')
-
-typedef enum
-{
-  ML_AGENT_SERVICE_PIPELINE = 0,
-  ML_AGENT_SERVICE_MODEL,
-  ML_AGENT_SERVICE_RESOURCE,
-  ML_AGENT_SERVICE_END
-} ml_agent_service_type_e;
-
-typedef gpointer ml_agent_proxy_h;
-
-/**
- * @brief An internal helper to get the dbus proxy
- */
-static ml_agent_proxy_h
-_get_proxy_new_for_bus_sync (ml_agent_service_type_e type, GError ** err)
-{
-  static const GBusType bus_types[] = { G_BUS_TYPE_SYSTEM, G_BUS_TYPE_SESSION };
-  static const size_t num_bus_types =
-      sizeof (bus_types) / sizeof (bus_types[0]);
-  ml_agent_proxy_h *proxy = NULL;
-  GError *_err = NULL;
-  size_t i;
-
-  switch (type) {
-    case ML_AGENT_SERVICE_PIPELINE:
-    {
-      MachinelearningServicePipeline *mlsp;
-
-      for (i = 0; i < num_bus_types; ++i) {
-        g_clear_error (&_err);
-
-        mlsp = machinelearning_service_pipeline_proxy_new_for_bus_sync
-            (bus_types[i], G_DBUS_PROXY_FLAGS_NONE, DBUS_ML_BUS_NAME,
-            DBUS_PIPELINE_PATH, NULL, &_err);
-        if (mlsp) {
-          break;
-        }
-      }
-      proxy = (ml_agent_proxy_h *) mlsp;
-      break;
-    }
-    case ML_AGENT_SERVICE_MODEL:
-    {
-      MachinelearningServiceModel *mlsm;
-
-      for (i = 0; i < num_bus_types; ++i) {
-        g_clear_error (&_err);
-
-        mlsm = machinelearning_service_model_proxy_new_for_bus_sync
-            (bus_types[i], G_DBUS_PROXY_FLAGS_NONE, DBUS_ML_BUS_NAME,
-            DBUS_MODEL_PATH, NULL, &_err);
-        if (mlsm)
-          break;
-      }
-      proxy = (ml_agent_proxy_h *) mlsm;
-      break;
-    }
-    case ML_AGENT_SERVICE_RESOURCE:
-    {
-      MachinelearningServiceResource *mlsr;
-
-      for (i = 0; i < num_bus_types; ++i) {
-        g_clear_error (&_err);
-
-        mlsr = machinelearning_service_resource_proxy_new_for_bus_sync
-            (bus_types[i], G_DBUS_PROXY_FLAGS_NONE, DBUS_ML_BUS_NAME,
-            DBUS_RESOURCE_PATH, NULL, &_err);
-        if (mlsr)
-          break;
-      }
-      proxy = (ml_agent_proxy_h *) mlsr;
-      break;
-    }
-    default:
-      break;
-  }
-
-  if (_err) {
-    *err = g_error_copy (_err);
-    g_clear_error (&_err);
-  }
-
-  return proxy;
-}
-
-/**
- * @brief An interface exported for setting the description of a pipeline.
- */
-gint
-ml_agent_pipeline_set_description (const gchar * name,
-    const gchar * pipeline_desc, GError ** err)
-{
-  MachinelearningServicePipeline *mlsp;
-  gboolean result;
-
-  if (!STR_IS_VALID (name) || !STR_IS_VALID (pipeline_desc)) {
-    g_return_val_if_reached (-EINVAL);
-  }
-
-  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
-  if (!mlsp) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_pipeline_call_set_pipeline_sync (mlsp,
-      name, pipeline_desc, NULL, NULL, err);
-  g_object_unref (mlsp);
-
-  g_return_val_if_fail (result, -EIO);
-  return 0;
-}
-
-/**
- * @brief An interface exported for getting the pipeline's description corresponding to the given @a name.
- */
-gint
-ml_agent_pipeline_get_description (const gchar * name,
-    gchar ** pipeline_desc, GError ** err)
-{
-  MachinelearningServicePipeline *mlsp;
-  gboolean result;
-  gint ret;
-
-  if (!STR_IS_VALID (name) || !pipeline_desc) {
-    g_return_val_if_reached (-EINVAL);
-  }
-
-  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
-  if (!mlsp) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_pipeline_call_get_pipeline_sync (mlsp,
-      name, &ret, pipeline_desc, NULL, err);
-  g_object_unref (mlsp);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for deletion of the pipeline's description corresponding to the given @a name.
- */
-gint
-ml_agent_pipeline_delete (const gchar * name, GError ** err)
-{
-  MachinelearningServicePipeline *mlsp;
-  gboolean result;
-  gint ret;
-
-  if (!STR_IS_VALID (name)) {
-    g_return_val_if_reached (-EINVAL);
-  }
-
-  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
-  if (!mlsp) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_pipeline_call_delete_pipeline_sync (mlsp,
-      name, &ret, NULL, err);
-  g_object_unref (mlsp);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for launching the pipeline's description corresponding to the given @a name.
- */
-gint
-ml_agent_pipeline_launch (const gchar * name, gint64 * id, GError ** err)
-{
-  MachinelearningServicePipeline *mlsp;
-  gboolean result;
-  gint ret;
-
-  if (!STR_IS_VALID (name) || !id) {
-    g_return_val_if_reached (-EINVAL);
-  }
-
-  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
-  if (!mlsp) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_pipeline_call_launch_pipeline_sync (mlsp,
-      name, &ret, id, NULL, err);
-  g_object_unref (mlsp);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for changing the pipeline's state of the given @a id to start.
- */
-gint
-ml_agent_pipeline_start (const gint64 id, GError ** err)
-{
-  MachinelearningServicePipeline *mlsp;
-  gboolean result;
-  gint ret;
-
-  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
-  if (!mlsp) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_pipeline_call_start_pipeline_sync (mlsp,
-      id, &ret, NULL, err);
-  g_object_unref (mlsp);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for changing the pipeline's state of the given @a id to stop.
- */
-gint
-ml_agent_pipeline_stop (const gint64 id, GError ** err)
-{
-  MachinelearningServicePipeline *mlsp;
-  gboolean result;
-  gint ret;
-
-  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
-  if (!mlsp) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_pipeline_call_stop_pipeline_sync (mlsp,
-      id, &ret, NULL, err);
-  g_object_unref (mlsp);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for destroying a launched pipeline corresponding to the given @a id.
- */
-gint
-ml_agent_pipeline_destroy (const gint64 id, GError ** err)
-{
-  MachinelearningServicePipeline *mlsp;
-  gboolean result;
-  gint ret;
-
-  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
-  if (!mlsp) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_pipeline_call_destroy_pipeline_sync (mlsp,
-      id, &ret, NULL, err);
-  g_object_unref (mlsp);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for getting the pipeline's state of the given @a id.
- */
-gint
-ml_agent_pipeline_get_state (const gint64 id, gint * state, GError ** err)
-{
-  MachinelearningServicePipeline *mlsp;
-  gboolean result;
-  gint ret;
-
-  if (!state) {
-    g_return_val_if_reached (-EINVAL);
-  }
-
-  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
-  if (!mlsp) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_pipeline_call_get_state_sync (mlsp,
-      id, &ret, state, NULL, err);
-  g_object_unref (mlsp);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for registering a model.
- */
-gint
-ml_agent_model_register (const gchar * name, const gchar * path,
-    const gboolean activate, const gchar * description, const gchar * app_info,
-    guint * version, GError ** err)
-{
-  MachinelearningServiceModel *mlsm;
-  gboolean result;
-  gint ret;
-
-  if (!STR_IS_VALID (name) || !STR_IS_VALID (path) || !version) {
-    g_return_val_if_reached (-EINVAL);
-  }
-
-  mlsm = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_MODEL, err);
-  if (!mlsm) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_model_call_register_sync (mlsm, name, path,
-      activate, description ? description : "", app_info ? app_info : "",
-      version, &ret, NULL, err);
-  g_object_unref (mlsm);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for updating the description of the model with @a name and @a version.
- */
-gint
-ml_agent_model_update_description (const gchar * name,
-    const guint version, const gchar * description, GError ** err)
-{
-  MachinelearningServiceModel *mlsm;
-  gboolean result;
-  gint ret;
-
-  if (!STR_IS_VALID (name) || !STR_IS_VALID (description) || version == 0U) {
-    g_return_val_if_reached (-EINVAL);
-  }
-
-  mlsm = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_MODEL, err);
-  if (!mlsm) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_model_call_update_description_sync (mlsm,
-      name, version, description, &ret, NULL, err);
-  g_object_unref (mlsm);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for activating the model with @a name and @a version.
- */
-gint
-ml_agent_model_activate (const gchar * name, const guint version, GError ** err)
-{
-  MachinelearningServiceModel *mlsm;
-  gboolean result;
-  gint ret;
-
-  if (!STR_IS_VALID (name) || version == 0U) {
-    g_return_val_if_reached (-EINVAL);
-  }
-
-  mlsm = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_MODEL, err);
-  if (!mlsm) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_model_call_activate_sync (mlsm,
-      name, version, &ret, NULL, err);
-  g_object_unref (mlsm);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for getting the information of the model with @a name and @a version.
- */
-gint
-ml_agent_model_get (const gchar * name, const guint version,
-    gchar ** model_info, GError ** err)
-{
-  MachinelearningServiceModel *mlsm;
-  gboolean result;
-  gint ret;
-
-  if (!STR_IS_VALID (name) || !model_info || version == 0U) {
-    g_return_val_if_reached (-EINVAL);
-  }
-
-  mlsm = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_MODEL, err);
-  if (!mlsm) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_model_call_get_sync (mlsm,
-      name, version, model_info, &ret, NULL, err);
-  g_object_unref (mlsm);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for getting the information of the activated model with @a name.
- */
-gint
-ml_agent_model_get_activated (const gchar * name,
-    gchar ** model_info, GError ** err)
-{
-  MachinelearningServiceModel *mlsm;
-  gboolean result;
-  gint ret;
-
-  if (!STR_IS_VALID (name) || !model_info) {
-    g_return_val_if_reached (-EINVAL);
-  }
-
-  mlsm = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_MODEL, err);
-  if (!mlsm) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_model_call_get_activated_sync (mlsm,
-      name, model_info, &ret, NULL, err);
-  g_object_unref (mlsm);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for getting the information of all the models corresponding to the given @a name.
- */
-gint
-ml_agent_model_get_all (const gchar * name, gchar ** model_info, GError ** err)
-{
-  MachinelearningServiceModel *mlsm;
-  gboolean result;
-  gint ret;
-
-  if (!STR_IS_VALID (name) || !model_info) {
-    g_return_val_if_reached (-EINVAL);
-  }
-
-  mlsm = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_MODEL, err);
-  if (!mlsm) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_model_call_get_all_sync (mlsm,
-      name, model_info, &ret, NULL, err);
-  g_object_unref (mlsm);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for removing the model of @a name and @a version.
- */
-gint
-ml_agent_model_delete (const gchar * name, const guint version, GError ** err)
-{
-  MachinelearningServiceModel *mlsm;
-  gboolean result;
-  gint ret;
-
-  if (!STR_IS_VALID (name)) {
-    g_return_val_if_reached (-EINVAL);
-  }
-
-  mlsm = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_MODEL, err);
-  if (!mlsm) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_model_call_delete_sync (mlsm,
-      name, version, &ret, NULL, err);
-  g_object_unref (mlsm);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for adding the resource.
- */
-gint
-ml_agent_resource_add (const gchar * name, const gchar * path,
-    const gchar * description, const gchar * app_info, GError ** err)
-{
-  MachinelearningServiceResource *mlsr;
-  gboolean result;
-  gint ret;
-
-  if (!STR_IS_VALID (name) || !STR_IS_VALID (path)) {
-    g_return_val_if_reached (-EINVAL);
-  }
-
-  mlsr = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_RESOURCE, err);
-  if (!mlsr) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_resource_call_add_sync (mlsr, name, path,
-      description ? description : "", app_info ? app_info : "",
-      &ret, NULL, err);
-  g_object_unref (mlsr);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for removing the resource with @a name.
- */
-gint
-ml_agent_resource_delete (const gchar * name, GError ** err)
-{
-  MachinelearningServiceResource *mlsr;
-  gboolean result;
-  gint ret;
-
-  if (!STR_IS_VALID (name)) {
-    g_return_val_if_reached (-EINVAL);
-  }
-
-  mlsr = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_RESOURCE, err);
-  if (!mlsr) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_resource_call_delete_sync (mlsr,
-      name, &ret, NULL, err);
-  g_object_unref (mlsr);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
-
-/**
- * @brief An interface exported for getting the description of the resource with @a name.
- */
-gint
-ml_agent_resource_get (const gchar * name, gchar ** res_info, GError ** err)
-{
-  MachinelearningServiceResource *mlsr;
-  gboolean result;
-  gint ret;
-
-  if (!STR_IS_VALID (name) || !res_info) {
-    g_return_val_if_reached (-EINVAL);
-  }
-
-  mlsr = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_RESOURCE, err);
-  if (!mlsr) {
-    g_return_val_if_reached (-EIO);
-  }
-
-  result = machinelearning_service_resource_call_get_sync (mlsr,
-      name, res_info, &ret, NULL, err);
-  g_object_unref (mlsr);
-
-  g_return_val_if_fail (ret == 0 && result, ret);
-  return 0;
-}
diff --git a/daemon/ml-agent.pc.in b/daemon/ml-agent.pc.in
deleted file mode 100755 (executable)
index 07901cd..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@PREFIX@
-exec_prefix=@EXEC_PREFIX@
-libdir=@LIB_INSTALL_DIR@
-includedir=@INCLUDE_INSTALL_DIR@
-
-Name: ml-agent
-Description: Development headers and libraries for interfaces provided by Machine Learning Agent
-Version: @VERSION@
-Libs: -L${libdir} -lml-agent
-Cflags: -I${includedir}/ml-agent
diff --git a/daemon/mlops-agent-interface.c b/daemon/mlops-agent-interface.c
new file mode 100755 (executable)
index 0000000..07d8134
--- /dev/null
@@ -0,0 +1,588 @@
+/* SPDX-License-Identifier: Apache-2.0 */
+/**
+ * @file    ml-agent-interface.c
+ * @date    5 April 2023
+ * @brief   A set of exported ml-agent interfaces for managing pipelines, models, and other service.
+ * @see     https://github.com/nnstreamer/deviceMLOps.MLAgent
+ * @author  Wook Song <wook16.song@samsung.com>
+ * @bug     No known bugs except for NYI items
+ */
+
+#include <errno.h>
+#include <glib.h>
+
+#include "include/mlops-agent-interface.h"
+#include "dbus-interface.h"
+#include "model-dbus.h"
+#include "pipeline-dbus.h"
+#include "resource-dbus.h"
+
+#define STR_IS_VALID(s) ((s) && (s)[0] != '\0')
+
+typedef enum
+{
+  ML_AGENT_SERVICE_PIPELINE = 0,
+  ML_AGENT_SERVICE_MODEL,
+  ML_AGENT_SERVICE_RESOURCE,
+  ML_AGENT_SERVICE_END
+} ml_agent_service_type_e;
+
+typedef gpointer ml_agent_proxy_h;
+
+/**
+ * @brief An internal helper to get the dbus proxy
+ */
+static ml_agent_proxy_h
+_get_proxy_new_for_bus_sync (ml_agent_service_type_e type, GError ** err)
+{
+  static const GBusType bus_types[] = { G_BUS_TYPE_SYSTEM, G_BUS_TYPE_SESSION };
+  static const size_t num_bus_types =
+      sizeof (bus_types) / sizeof (bus_types[0]);
+  ml_agent_proxy_h *proxy = NULL;
+  GError *_err = NULL;
+  size_t i;
+
+  switch (type) {
+    case ML_AGENT_SERVICE_PIPELINE:
+    {
+      MachinelearningServicePipeline *mlsp;
+
+      for (i = 0; i < num_bus_types; ++i) {
+        g_clear_error (&_err);
+
+        mlsp = machinelearning_service_pipeline_proxy_new_for_bus_sync
+            (bus_types[i], G_DBUS_PROXY_FLAGS_NONE, DBUS_ML_BUS_NAME,
+            DBUS_PIPELINE_PATH, NULL, &_err);
+        if (mlsp) {
+          break;
+        }
+      }
+      proxy = (ml_agent_proxy_h *) mlsp;
+      break;
+    }
+    case ML_AGENT_SERVICE_MODEL:
+    {
+      MachinelearningServiceModel *mlsm;
+
+      for (i = 0; i < num_bus_types; ++i) {
+        g_clear_error (&_err);
+
+        mlsm = machinelearning_service_model_proxy_new_for_bus_sync
+            (bus_types[i], G_DBUS_PROXY_FLAGS_NONE, DBUS_ML_BUS_NAME,
+            DBUS_MODEL_PATH, NULL, &_err);
+        if (mlsm)
+          break;
+      }
+      proxy = (ml_agent_proxy_h *) mlsm;
+      break;
+    }
+    case ML_AGENT_SERVICE_RESOURCE:
+    {
+      MachinelearningServiceResource *mlsr;
+
+      for (i = 0; i < num_bus_types; ++i) {
+        g_clear_error (&_err);
+
+        mlsr = machinelearning_service_resource_proxy_new_for_bus_sync
+            (bus_types[i], G_DBUS_PROXY_FLAGS_NONE, DBUS_ML_BUS_NAME,
+            DBUS_RESOURCE_PATH, NULL, &_err);
+        if (mlsr)
+          break;
+      }
+      proxy = (ml_agent_proxy_h *) mlsr;
+      break;
+    }
+    default:
+      break;
+  }
+
+  if (_err) {
+    *err = g_error_copy (_err);
+    g_clear_error (&_err);
+  }
+
+  return proxy;
+}
+
+/**
+ * @brief An interface exported for setting the description of a pipeline.
+ */
+gint
+ml_agent_pipeline_set_description (const gchar * name,
+    const gchar * pipeline_desc, GError ** err)
+{
+  MachinelearningServicePipeline *mlsp;
+  gboolean result;
+
+  if (!STR_IS_VALID (name) || !STR_IS_VALID (pipeline_desc)) {
+    g_return_val_if_reached (-EINVAL);
+  }
+
+  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
+  if (!mlsp) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_pipeline_call_set_pipeline_sync (mlsp,
+      name, pipeline_desc, NULL, NULL, err);
+  g_object_unref (mlsp);
+
+  g_return_val_if_fail (result, -EIO);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for getting the pipeline's description corresponding to the given @a name.
+ */
+gint
+ml_agent_pipeline_get_description (const gchar * name,
+    gchar ** pipeline_desc, GError ** err)
+{
+  MachinelearningServicePipeline *mlsp;
+  gboolean result;
+  gint ret;
+
+  if (!STR_IS_VALID (name) || !pipeline_desc) {
+    g_return_val_if_reached (-EINVAL);
+  }
+
+  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
+  if (!mlsp) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_pipeline_call_get_pipeline_sync (mlsp,
+      name, &ret, pipeline_desc, NULL, err);
+  g_object_unref (mlsp);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for deletion of the pipeline's description corresponding to the given @a name.
+ */
+gint
+ml_agent_pipeline_delete (const gchar * name, GError ** err)
+{
+  MachinelearningServicePipeline *mlsp;
+  gboolean result;
+  gint ret;
+
+  if (!STR_IS_VALID (name)) {
+    g_return_val_if_reached (-EINVAL);
+  }
+
+  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
+  if (!mlsp) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_pipeline_call_delete_pipeline_sync (mlsp,
+      name, &ret, NULL, err);
+  g_object_unref (mlsp);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for launching the pipeline's description corresponding to the given @a name.
+ */
+gint
+ml_agent_pipeline_launch (const gchar * name, gint64 * id, GError ** err)
+{
+  MachinelearningServicePipeline *mlsp;
+  gboolean result;
+  gint ret;
+
+  if (!STR_IS_VALID (name) || !id) {
+    g_return_val_if_reached (-EINVAL);
+  }
+
+  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
+  if (!mlsp) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_pipeline_call_launch_pipeline_sync (mlsp,
+      name, &ret, id, NULL, err);
+  g_object_unref (mlsp);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for changing the pipeline's state of the given @a id to start.
+ */
+gint
+ml_agent_pipeline_start (const gint64 id, GError ** err)
+{
+  MachinelearningServicePipeline *mlsp;
+  gboolean result;
+  gint ret;
+
+  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
+  if (!mlsp) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_pipeline_call_start_pipeline_sync (mlsp,
+      id, &ret, NULL, err);
+  g_object_unref (mlsp);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for changing the pipeline's state of the given @a id to stop.
+ */
+gint
+ml_agent_pipeline_stop (const gint64 id, GError ** err)
+{
+  MachinelearningServicePipeline *mlsp;
+  gboolean result;
+  gint ret;
+
+  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
+  if (!mlsp) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_pipeline_call_stop_pipeline_sync (mlsp,
+      id, &ret, NULL, err);
+  g_object_unref (mlsp);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for destroying a launched pipeline corresponding to the given @a id.
+ */
+gint
+ml_agent_pipeline_destroy (const gint64 id, GError ** err)
+{
+  MachinelearningServicePipeline *mlsp;
+  gboolean result;
+  gint ret;
+
+  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
+  if (!mlsp) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_pipeline_call_destroy_pipeline_sync (mlsp,
+      id, &ret, NULL, err);
+  g_object_unref (mlsp);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for getting the pipeline's state of the given @a id.
+ */
+gint
+ml_agent_pipeline_get_state (const gint64 id, gint * state, GError ** err)
+{
+  MachinelearningServicePipeline *mlsp;
+  gboolean result;
+  gint ret;
+
+  if (!state) {
+    g_return_val_if_reached (-EINVAL);
+  }
+
+  mlsp = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_PIPELINE, err);
+  if (!mlsp) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_pipeline_call_get_state_sync (mlsp,
+      id, &ret, state, NULL, err);
+  g_object_unref (mlsp);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for registering a model.
+ */
+gint
+ml_agent_model_register (const gchar * name, const gchar * path,
+    const gboolean activate, const gchar * description, const gchar * app_info,
+    guint * version, GError ** err)
+{
+  MachinelearningServiceModel *mlsm;
+  gboolean result;
+  gint ret;
+
+  if (!STR_IS_VALID (name) || !STR_IS_VALID (path) || !version) {
+    g_return_val_if_reached (-EINVAL);
+  }
+
+  mlsm = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_MODEL, err);
+  if (!mlsm) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_model_call_register_sync (mlsm, name, path,
+      activate, description ? description : "", app_info ? app_info : "",
+      version, &ret, NULL, err);
+  g_object_unref (mlsm);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for updating the description of the model with @a name and @a version.
+ */
+gint
+ml_agent_model_update_description (const gchar * name,
+    const guint version, const gchar * description, GError ** err)
+{
+  MachinelearningServiceModel *mlsm;
+  gboolean result;
+  gint ret;
+
+  if (!STR_IS_VALID (name) || !STR_IS_VALID (description) || version == 0U) {
+    g_return_val_if_reached (-EINVAL);
+  }
+
+  mlsm = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_MODEL, err);
+  if (!mlsm) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_model_call_update_description_sync (mlsm,
+      name, version, description, &ret, NULL, err);
+  g_object_unref (mlsm);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for activating the model with @a name and @a version.
+ */
+gint
+ml_agent_model_activate (const gchar * name, const guint version, GError ** err)
+{
+  MachinelearningServiceModel *mlsm;
+  gboolean result;
+  gint ret;
+
+  if (!STR_IS_VALID (name) || version == 0U) {
+    g_return_val_if_reached (-EINVAL);
+  }
+
+  mlsm = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_MODEL, err);
+  if (!mlsm) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_model_call_activate_sync (mlsm,
+      name, version, &ret, NULL, err);
+  g_object_unref (mlsm);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for getting the information of the model with @a name and @a version.
+ */
+gint
+ml_agent_model_get (const gchar * name, const guint version,
+    gchar ** model_info, GError ** err)
+{
+  MachinelearningServiceModel *mlsm;
+  gboolean result;
+  gint ret;
+
+  if (!STR_IS_VALID (name) || !model_info || version == 0U) {
+    g_return_val_if_reached (-EINVAL);
+  }
+
+  mlsm = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_MODEL, err);
+  if (!mlsm) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_model_call_get_sync (mlsm,
+      name, version, model_info, &ret, NULL, err);
+  g_object_unref (mlsm);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for getting the information of the activated model with @a name.
+ */
+gint
+ml_agent_model_get_activated (const gchar * name,
+    gchar ** model_info, GError ** err)
+{
+  MachinelearningServiceModel *mlsm;
+  gboolean result;
+  gint ret;
+
+  if (!STR_IS_VALID (name) || !model_info) {
+    g_return_val_if_reached (-EINVAL);
+  }
+
+  mlsm = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_MODEL, err);
+  if (!mlsm) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_model_call_get_activated_sync (mlsm,
+      name, model_info, &ret, NULL, err);
+  g_object_unref (mlsm);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for getting the information of all the models corresponding to the given @a name.
+ */
+gint
+ml_agent_model_get_all (const gchar * name, gchar ** model_info, GError ** err)
+{
+  MachinelearningServiceModel *mlsm;
+  gboolean result;
+  gint ret;
+
+  if (!STR_IS_VALID (name) || !model_info) {
+    g_return_val_if_reached (-EINVAL);
+  }
+
+  mlsm = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_MODEL, err);
+  if (!mlsm) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_model_call_get_all_sync (mlsm,
+      name, model_info, &ret, NULL, err);
+  g_object_unref (mlsm);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for removing the model of @a name and @a version.
+ */
+gint
+ml_agent_model_delete (const gchar * name, const guint version, GError ** err)
+{
+  MachinelearningServiceModel *mlsm;
+  gboolean result;
+  gint ret;
+
+  if (!STR_IS_VALID (name)) {
+    g_return_val_if_reached (-EINVAL);
+  }
+
+  mlsm = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_MODEL, err);
+  if (!mlsm) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_model_call_delete_sync (mlsm,
+      name, version, &ret, NULL, err);
+  g_object_unref (mlsm);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for adding the resource.
+ */
+gint
+ml_agent_resource_add (const gchar * name, const gchar * path,
+    const gchar * description, const gchar * app_info, GError ** err)
+{
+  MachinelearningServiceResource *mlsr;
+  gboolean result;
+  gint ret;
+
+  if (!STR_IS_VALID (name) || !STR_IS_VALID (path)) {
+    g_return_val_if_reached (-EINVAL);
+  }
+
+  mlsr = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_RESOURCE, err);
+  if (!mlsr) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_resource_call_add_sync (mlsr, name, path,
+      description ? description : "", app_info ? app_info : "",
+      &ret, NULL, err);
+  g_object_unref (mlsr);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for removing the resource with @a name.
+ */
+gint
+ml_agent_resource_delete (const gchar * name, GError ** err)
+{
+  MachinelearningServiceResource *mlsr;
+  gboolean result;
+  gint ret;
+
+  if (!STR_IS_VALID (name)) {
+    g_return_val_if_reached (-EINVAL);
+  }
+
+  mlsr = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_RESOURCE, err);
+  if (!mlsr) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_resource_call_delete_sync (mlsr,
+      name, &ret, NULL, err);
+  g_object_unref (mlsr);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
+
+/**
+ * @brief An interface exported for getting the description of the resource with @a name.
+ */
+gint
+ml_agent_resource_get (const gchar * name, gchar ** res_info, GError ** err)
+{
+  MachinelearningServiceResource *mlsr;
+  gboolean result;
+  gint ret;
+
+  if (!STR_IS_VALID (name) || !res_info) {
+    g_return_val_if_reached (-EINVAL);
+  }
+
+  mlsr = _get_proxy_new_for_bus_sync (ML_AGENT_SERVICE_RESOURCE, err);
+  if (!mlsr) {
+    g_return_val_if_reached (-EIO);
+  }
+
+  result = machinelearning_service_resource_call_get_sync (mlsr,
+      name, res_info, &ret, NULL, err);
+  g_object_unref (mlsr);
+
+  g_return_val_if_fail (ret == 0 && result, ret);
+  return 0;
+}
diff --git a/daemon/mlops-agent.pc.in b/daemon/mlops-agent.pc.in
new file mode 100755 (executable)
index 0000000..46f3356
--- /dev/null
@@ -0,0 +1,10 @@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
+
+Name: mlops-agent
+Description: Development headers and libraries for interfaces provided by MLOps Agent
+Version: @VERSION@
+Libs: -L${libdir} -lmlops-agent
+Cflags: -I${includedir}/mlops-agent
diff --git a/dbus/machine-learning-agent.conf.in b/dbus/machine-learning-agent.conf.in
deleted file mode 100644 (file)
index 9f442f4..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-<busconfig>
-    <policy user="root">
-        <allow send_destination="org.tizen.machinelearning.service"
-            send_interface="org.tizen.machinelearning.service.pipeline"/>
-    </policy>
-    <policy user="service_fw">
-        <allow own="org.tizen.machinelearning.service"/>
-    </policy>
-    <policy context="default">
-        <deny own="org.tizen.machinelearning.service"/>
-        <deny send_destination="org.tizen.machinelearning.service"/>
-        <allow send_destination="org.tizen.machinelearning.service"/>
-    </policy>
-</busconfig>
diff --git a/dbus/machine-learning-agent.service.in b/dbus/machine-learning-agent.service.in
deleted file mode 100644 (file)
index d315d4c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-[Unit]
-Description=Machine Learning Agent Daemon
-
-[Service]
-Type=dbus
-BusName=org.tizen.machinelearning.service
-SmackProcessLabel=System
-ExecStart=@EXEC_PREFIX@/machine-learning-agent
-User=service_fw
-Group=service_fw
index a250578cdedd71d0ec8bf011e75e5d17108781e5..0e5276d12b92a3aa7b41e21e832beb1d1519c1c8 100644 (file)
@@ -32,8 +32,8 @@ gdbus_gen_header_dep = declare_dependency(
   sources: [gdbus_gen_pipeline_src, gdbus_gen_model_src, gdbus_gen_resource_src])
 
 # DBus Policy configuration
-configure_file(input: 'machine-learning-agent.conf.in',
-  output: 'machine-learning-agent.conf',
+configure_file(input: 'mlops-agent.conf.in',
+  output: 'mlops-agent.conf',
   install_dir: dbus_policy_dir,
   configuration: ml_agent_conf
 )
@@ -46,8 +46,8 @@ configure_file(input: 'org.tizen.machinelearning.service.service.in',
 )
 
 # Systemd Service file
-configure_file(input: 'machine-learning-agent.service.in',
-  output: 'machine-learning-agent.service',
+configure_file(input: 'mlops-agent.service.in',
+  output: 'mlops-agent.service',
   install_dir: systemd_service_dir,
   configuration: ml_agent_conf
 )
diff --git a/dbus/mlops-agent.conf.in b/dbus/mlops-agent.conf.in
new file mode 100644 (file)
index 0000000..9f442f4
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+    <policy user="root">
+        <allow send_destination="org.tizen.machinelearning.service"
+            send_interface="org.tizen.machinelearning.service.pipeline"/>
+    </policy>
+    <policy user="service_fw">
+        <allow own="org.tizen.machinelearning.service"/>
+    </policy>
+    <policy context="default">
+        <deny own="org.tizen.machinelearning.service"/>
+        <deny send_destination="org.tizen.machinelearning.service"/>
+        <allow send_destination="org.tizen.machinelearning.service"/>
+    </policy>
+</busconfig>
diff --git a/dbus/mlops-agent.service.in b/dbus/mlops-agent.service.in
new file mode 100644 (file)
index 0000000..5ff84c3
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=MLOps Agent Daemon
+
+[Service]
+Type=dbus
+BusName=org.tizen.machinelearning.service
+SmackProcessLabel=System
+ExecStart=@EXEC_PREFIX@/mlops-agent
+User=service_fw
+Group=service_fw
index a3c700463fcc59e909543e2a18ca301afc6883a1..f34842b68de89e5c581118df845293307d84fb76 100644 (file)
@@ -1,4 +1,4 @@
 [D-BUS Service]
 Name=org.tizen.machinelearning.service
-Exec=@EXEC_PREFIX@/machine-learning-agent
-SystemdService=machine-learning-agent.service
+Exec=@EXEC_PREFIX@/mlops-agent
+SystemdService=mlops-agent.service
diff --git a/packaging/machine-learning-agent.manifest b/packaging/machine-learning-agent.manifest
deleted file mode 100644 (file)
index 017d22d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
- <request>
-    <domain name="_"/>
- </request>
-</manifest>
diff --git a/packaging/machine-learning-agent.spec b/packaging/machine-learning-agent.spec
deleted file mode 100644 (file)
index 8d8a0bc..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-###########################################################################
-# Default features for Tizen release
-# If you want to build RPM for other Linux distro, you may need to
-# touch these values for your needs.
-
-# Create an option to build without tizen (`--without tizen`), thus default
-# building with it
-# https://rpm-software-management.github.io/rpm/manual/conditionalbuilds.html
-%bcond_without tizen
-
-###########################################################################
-# Macros for building and testing option control
-%define                builddir build
-%define                source_root %{_builddir}/%{?buildsubdir}
-%define                test_script %{source_root}/packaging/run_unittests.sh
-%define                test_base_dir %{_bindir}/ml-agent-test
-
-# Note that debug packages generate an additional build and storage cost.
-# If you do not need debug packages, run '$ gbs build ... --define "_skip_debug_rpm 1"'.
-%if "%{?_skip_debug_rpm}" == "1"
-%global debug_package %{nil}
-%global __debug_install_post %{nil}
-%endif
-
-###########################################################################
-# Define build options
-
-# Below features are used for unittest.
-# Do not add neural network dependency to ML-Agent.
-%define enable_test -Denable-test=false
-%define install_test -Dinstall-test=false
-
-# To generage gcov package, --define "gcov 1"
-%if 0%{?gcov:1}
-%define                unit_test 1
-%define                release_test 1
-%define                testcoverage 1
-%endif
-
-# To set prefix, use this line
-### define service_db_key_prefix -Dservice-db-key-prefix='some-prefix'
-%define service_db_key_prefix %{nil}
-
-###########################################################################
-# Package / sub-package definitions
-Name:          machine-learning-agent
-Summary:       AI service agent for ML(Machine Learning) API and NNStreamer
-# Synchronize the version information for ML-Agent.
-# 1. Tizen   : ./packaging/machine-learning-agent.spec
-# 2. Meson   : ./meson.build
-Version:       1.8.5
-Release:       0
-Group:         Machine Learning/ML Framework
-Packager:      Sangjung Woo <sangjung.woo@samsung.com>
-License:       Apache-2.0
-Source0:       machine-learning-agent-%{version}.tar
-Source1001:    machine-learning-agent.manifest
-
-## Define runtime requirements ##
-Requires:      libmachine-learning-agent = %{version}-%{release}
-Requires:      dbus-1
-
-## Define build requirements ##
-BuildRequires: meson >= 0.50.0
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(gstreamer-1.0)
-BuildRequires: pkgconfig(libsystemd)
-BuildRequires: pkgconfig(sqlite3)
-BuildRequires: pkgconfig(json-glib-1.0)
-
-%if %{with tizen}
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(libtzplatform-config)
-BuildRequires: pkgconfig(capi-appfw-package-manager)
-BuildRequires: pkgconfig(capi-appfw-app-common)
-%endif # tizen
-
-# For test
-%if 0%{?unit_test}
-# g_test_dbus_up requires dbus
-BuildRequires: dbus-1
-BuildRequires: pkgconfig(gtest)
-
-%if 0%{?testcoverage}
-# to be compatible with gcc-9, lcov should have a higher version than 1.14.1
-BuildRequires: lcov
-%endif
-%endif # unit_test
-
-%description
-AI service agent for ML(Machine Learning) API and NNStreamer.
-
-%package -n libmachine-learning-agent
-Summary:       Library that exports interfaces provided by Machine Learning Agent
-Group:         Machine Learning/ML Framework = %{version}-%{release}
-%description -n libmachine-learning-agent
-Shared library to export interfaces provided by the Machine Learning Agent.
-
-%package -n libmachine-learning-agent-devel
-Summary:       Development headers and static library for interfaces provided by Machine Learning Agent
-Group:         Machine Learning/ML Framework
-Requires:      libmachine-learning-agent = %{version}-%{release}
-%description -n libmachine-learning-agent-devel
-Development headers and static library for interfaces provided by Machine Learning Agent.
-
-%package test
-Summary:       ML service agent for testing purposes
-Requires:      dbus
-%description test
-ML agent binary for the testing purposes
-This package provides the ML agent (daemon) to the other packages that
-require testing with the ML Agent service.
-
-%if 0%{?unit_test}
-%if 0%{?release_test}
-%package unittests
-Summary:       Unittests for Machine Learning Agent
-Group:         Machine Learning/ML Framework
-Requires:      machine-learning-agent = %{version}-%{release}
-%description unittests
-Unittests for Machine Learning Agent.
-%endif
-
-%if 0%{?gcov:1}
-%package gcov
-Summary:       Machine Learning Agent gcov objects
-Group:         Machine Learning/ML Framework
-%description gcov
-Machine Learning Agent gcov objects.
-%endif
-
-%if 0%{?testcoverage}
-%package unittest-coverage
-Summary:       Unittest coverage result for Machine Learning Agent
-%description unittest-coverage
-HTML pages of lcov results of Machine Learning Agent generated during rpm build.
-%endif
-%endif # unit_test
-
-%prep
-%setup -q
-cp %{SOURCE1001} .
-
-%build
-# Remove compiler flags for meson to decide the cpp version
-CXXFLAGS=`echo $CXXFLAGS | sed -e "s|-std=gnu++11||"`
-
-%if 0%{?unit_test}
-%define enable_test -Denable-test=true
-
-%if 0%{?release_test}
-%define install_test -Dinstall-test=true
-%endif # release_test
-
-%if 0%{?testcoverage}
-# To test coverage, disable optimizations (and should unset _FORTIFY_SOURCE to use -O0)
-CFLAGS=`echo $CFLAGS | sed -e "s|-O[1-9]|-O0|g"`
-CFLAGS=`echo $CFLAGS | sed -e "s|-Wp,-D_FORTIFY_SOURCE=[1-9]||g"`
-CXXFLAGS=`echo $CXXFLAGS | sed -e "s|-O[1-9]|-O0|g"`
-CXXFLAGS=`echo $CXXFLAGS | sed -e "s|-Wp,-D_FORTIFY_SOURCE=[1-9]||g"`
-# also, use the meson's base option, -Db_coverage, instead of --coverage/-fprofile-arcs and -ftest-coverage
-%endif # testcoverage
-%endif # unit_test
-
-rm -rf %{builddir}
-meson setup --buildtype=plain --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} --libdir=%{_libdir} \
-       --bindir=%{_bindir} --includedir=%{_includedir} \
-       %{enable_test} %{install_test} %{?testcoverage:-Db_coverage=true} \
-       %{?with_tizen:-Denable-tizen=true} \
-       -Dservice-db-path=%{?with_tizen:%{TZ_SYS_GLOBALUSER_DB}}%{!?with_tizen:%{expand:%{?service_db_path}}%{?!service_db_path:.}} \
-       %{service_db_key_prefix} \
-       %{builddir}
-
-meson compile -C %{builddir} %{?_smp_mflags}
-
-export MLAGENT_SOURCE_ROOT_PATH=$(pwd)
-export MLAGENT_BUILD_ROOT_PATH=$(pwd)/%{builddir}
-
-# Run test
-# If gcov package generation is enabled, pass the test from GBS.
-%if 0%{?unit_test} && !0%{?gcov}
-bash %{test_script} ./tests/daemon/unittest_ml_agent
-bash %{test_script} ./tests/daemon/unittest_service_db
-bash %{test_script} ./tests/daemon/unittest_gdbus_util
-%endif # unit_test
-
-%install
-meson install -C %{builddir} --destdir=%{buildroot}
-
-%if 0%{?unit_test}
-%if 0%{?testcoverage}
-# 'lcov' generates the date format with UTC time zone by default. Let's replace UTC with KST.
-# If you can get a root privilege, run ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
-TZ='Asia/Seoul'; export TZ
-
-# Get commit info
-VCS=`cat ${RPM_SOURCE_DIR}/machine-learning-agent.spec | grep "^VCS:" | sed "s|VCS:\\W*\\(.*\\)|\\1|"`
-
-# Create human readable coverage report web page.
-# Create null gcda files if gcov didn't create it because there is completely no unit test for them.
-find . -name "*.gcno" -exec sh -c 'touch -a "${1%.gcno}.gcda"' _ {} \;
-# Remove gcda for meaningless file (CMake's autogenerated)
-find . -name "CMakeCCompilerId*.gcda" -delete
-find . -name "CMakeCXXCompilerId*.gcda" -delete
-# Generate report
-# TODO: the --no-external option is removed to include machine-learning-agent related source files.
-# Restore this option when there is proper way to include those source files.
-pushd %{builddir}
-lcov -t 'ML-Agent unittest coverage' -o unittest.info -c -d . -b $(pwd)
-# Exclude generated files (e.g., Orc, Protobuf) and device-dependent files.
-# Exclude files which are generated by gdbus-codegen and external files in /usr/*.
-lcov -r unittest.info "*/tests/*" "*/meson*/*" "*/*@sha/*" "*/*.so.p/*" "*/*tizen*" "*/*-dbus.c" "/usr/*" -o unittest-filtered.info
-# Visualize the report
-genhtml -o result unittest-filtered.info -t "ML-Agent %{version}-%{release} ${VCS}" --ignore-errors source -p ${RPM_BUILD_DIR}
-
-mkdir -p %{buildroot}%{_datadir}/ml-agent/unittest/
-cp -r result %{buildroot}%{_datadir}/ml-agent/unittest/
-popd
-
-%if 0%{?gcov:1}
-builddir=$(basename $PWD)
-gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir"
-mkdir -p "$gcno_obj_dir"
-find . -name '*.gcno' ! -path "*/tests/*" ! -name "meson-generated*" ! -name "sanitycheck*" ! -path "*tizen*" -exec cp --parents '{}' "$gcno_obj_dir" ';'
-
-mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name}
-install -m 0755 packaging/run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}
-%endif
-
-%endif # test coverage
-%endif # unit_test
-
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
-
-%files
-%manifest machine-learning-agent.manifest
-%license LICENSE
-%attr(0755,root,root) %{_bindir}/machine-learning-agent
-%attr(0644,root,root) %{_unitdir}/machine-learning-agent.service
-%attr(0644,root,root) %config %{_sysconfdir}/dbus-1/system.d/machine-learning-agent.conf
-%attr(0644,root,root) %{_datadir}/dbus-1/system-services/org.tizen.machinelearning.service.service
-
-%files -n libmachine-learning-agent
-%manifest machine-learning-agent.manifest
-%license LICENSE
-%{_libdir}/libml-agent.so.*
-
-%files -n libmachine-learning-agent-devel
-%manifest machine-learning-agent.manifest
-%{_libdir}/libml-agent.so
-%{_libdir}/libml-agent.a
-%{_includedir}/ml-agent/ml-agent-interface.h
-%{_libdir}/pkgconfig/ml-agent.pc
-
-%files test
-%manifest machine-learning-agent.manifest
-%license LICENSE
-%attr(0755,root,root) %{test_base_dir}/machine-learning-agent-test
-%attr(0755,root,root) %{test_base_dir}/services/org.tizen.machinelearning.service.service
-%{_libdir}/libml-agent-test.*
-
-%if 0%{?unit_test}
-%if 0%{?release_test}
-%files unittests
-%manifest machine-learning-agent.manifest
-%{test_base_dir}/unittests
-%{_libdir}/libml-agent-test.a
-%{_libdir}/libml-agent-test.so*
-%if 0%{?gcov:1}
-%{_bindir}/tizen-unittests/%{name}/run-unittest.sh
-%endif # gcov
-%endif # release_test
-
-%if 0%{?gcov:1}
-%files gcov
-%{_datadir}/gcov/obj/*
-%endif # gcov
-
-%if 0%{?testcoverage}
-%files unittest-coverage
-%{_datadir}/ml-agent/unittest/*
-%endif # testcoverage
-%endif # unit_test
-
-%changelog
-* Mon Dec 11 2023 Sangjung Woo <sangjung.woo@samsung.com>
-- Started ML-Agent packaging for 1.8.5 (Initial version sync to ML API)
diff --git a/packaging/mlops-agent.manifest b/packaging/mlops-agent.manifest
new file mode 100644 (file)
index 0000000..017d22d
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+    <domain name="_"/>
+ </request>
+</manifest>
diff --git a/packaging/mlops-agent.spec b/packaging/mlops-agent.spec
new file mode 100644 (file)
index 0000000..c4c3667
--- /dev/null
@@ -0,0 +1,291 @@
+###########################################################################
+# Default features for Tizen release
+# If you want to build RPM for other Linux distro, you may need to
+# touch these values for your needs.
+
+# Create an option to build without tizen (`--without tizen`), thus default
+# building with it
+# https://rpm-software-management.github.io/rpm/manual/conditionalbuilds.html
+%bcond_without tizen
+
+###########################################################################
+# Macros for building and testing option control
+%define                builddir build
+%define                source_root %{_builddir}/%{?buildsubdir}
+%define                test_script %{source_root}/packaging/run_unittests.sh
+%define                test_base_dir %{_bindir}/ml-test
+
+# Note that debug packages generate an additional build and storage cost.
+# If you do not need debug packages, run '$ gbs build ... --define "_skip_debug_rpm 1"'.
+%if "%{?_skip_debug_rpm}" == "1"
+%global debug_package %{nil}
+%global __debug_install_post %{nil}
+%endif
+
+###########################################################################
+# Define build options
+
+# Below features are used for unittest.
+# Do not add neural network dependency to ML-Agent.
+%define enable_test -Denable-test=false
+%define install_test -Dinstall-test=false
+
+# To generage gcov package, --define "gcov 1"
+%if 0%{?gcov:1}
+%define                unit_test 1
+%define                release_test 1
+%define                testcoverage 1
+%endif
+
+# To set prefix, use this line
+### define service_db_key_prefix -Dservice-db-key-prefix='some-prefix'
+%define service_db_key_prefix %{nil}
+
+###########################################################################
+# Package / sub-package definitions
+Name:          mlops-agent
+Summary:       AI service agent for MLOps and ML(Machine Learning) API
+# Synchronize the version information for ML-Agent.
+# 1. Tizen   : ./packaging/mlops-agent.spec
+# 2. Meson   : ./meson.build
+Version:       1.8.5
+Release:       0
+Group:         Machine Learning/ML Framework
+Packager:      Sangjung Woo <sangjung.woo@samsung.com>
+License:       Apache-2.0
+Source0:       mlops-agent-%{version}.tar
+Source1001:    mlops-agent.manifest
+
+## Define runtime requirements ##
+Requires:      libmlops-agent = %{version}-%{release}
+Requires:      dbus-1
+
+## Define build requirements ##
+BuildRequires: meson >= 0.50.0
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(gstreamer-1.0)
+BuildRequires: pkgconfig(libsystemd)
+BuildRequires: pkgconfig(sqlite3)
+BuildRequires: pkgconfig(json-glib-1.0)
+
+%if %{with tizen}
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(capi-appfw-package-manager)
+BuildRequires: pkgconfig(capi-appfw-app-common)
+%endif # tizen
+
+# For test
+%if 0%{?unit_test}
+# g_test_dbus_up requires dbus
+BuildRequires: dbus-1
+BuildRequires: pkgconfig(gtest)
+
+%if 0%{?testcoverage}
+# to be compatible with gcc-9, lcov should have a higher version than 1.14.1
+BuildRequires: lcov
+%endif
+%endif # unit_test
+
+%description
+AI service agent for ML(Machine Learning) API and NNStreamer.
+
+%package -n libmlops-agent
+Summary:       Library that exports interfaces provided by Machine Learning Agent
+Group:         Machine Learning/ML Framework = %{version}-%{release}
+%description -n libmlops-agent
+Shared library to export interfaces provided by the Machine Learning Agent.
+
+%package -n libmlops-agent-devel
+Summary:       Development headers and static library for interfaces provided by Machine Learning Agent
+Group:         Machine Learning/ML Framework
+Requires:      libmlops-agent = %{version}-%{release}
+%description -n libmlops-agent-devel
+Development headers and static library for interfaces provided by Machine Learning Agent.
+
+%package test
+Summary:       ML service agent for testing purposes
+Requires:      dbus
+%description test
+ML agent binary for the testing purposes
+This package provides the ML agent (daemon) to the other packages that
+require testing with the ML Agent service.
+
+%if 0%{?unit_test}
+%if 0%{?release_test}
+%package unittests
+Summary:       Unittests for Machine Learning Agent
+Group:         Machine Learning/ML Framework
+Requires:      mlops-agent-test = %{version}-%{release}
+%description unittests
+Unittests for Machine Learning Agent.
+%endif
+
+%if 0%{?gcov:1}
+%package gcov
+Summary:       Machine Learning Agent gcov objects
+Group:         Machine Learning/ML Framework
+%description gcov
+Machine Learning Agent gcov objects.
+%endif
+
+%if 0%{?testcoverage}
+%package unittest-coverage
+Summary:       Unittest coverage result for Machine Learning Agent
+%description unittest-coverage
+HTML pages of lcov results of Machine Learning Agent generated during rpm build.
+%endif
+%endif # unit_test
+
+%prep
+%setup -q
+cp %{SOURCE1001} .
+
+%build
+# Remove compiler flags for meson to decide the cpp version
+CXXFLAGS=`echo $CXXFLAGS | sed -e "s|-std=gnu++11||"`
+
+%if 0%{?unit_test}
+%define enable_test -Denable-test=true
+
+%if 0%{?release_test}
+%define install_test -Dinstall-test=true
+%endif # release_test
+
+%if 0%{?testcoverage}
+# To test coverage, disable optimizations (and should unset _FORTIFY_SOURCE to use -O0)
+CFLAGS=`echo $CFLAGS | sed -e "s|-O[1-9]|-O0|g"`
+CFLAGS=`echo $CFLAGS | sed -e "s|-Wp,-D_FORTIFY_SOURCE=[1-9]||g"`
+CXXFLAGS=`echo $CXXFLAGS | sed -e "s|-O[1-9]|-O0|g"`
+CXXFLAGS=`echo $CXXFLAGS | sed -e "s|-Wp,-D_FORTIFY_SOURCE=[1-9]||g"`
+# also, use the meson's base option, -Db_coverage, instead of --coverage/-fprofile-arcs and -ftest-coverage
+%endif # testcoverage
+%endif # unit_test
+
+rm -rf %{builddir}
+meson setup --buildtype=plain --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} --libdir=%{_libdir} \
+       --bindir=%{_bindir} --includedir=%{_includedir} \
+       %{enable_test} %{install_test} %{?testcoverage:-Db_coverage=true} \
+       %{?with_tizen:-Denable-tizen=true} \
+       -Dservice-db-path=%{?with_tizen:%{TZ_SYS_GLOBALUSER_DB}}%{!?with_tizen:%{expand:%{?service_db_path}}%{?!service_db_path:.}} \
+       %{service_db_key_prefix} \
+       %{builddir}
+
+meson compile -C %{builddir} %{?_smp_mflags}
+
+export MLAGENT_SOURCE_ROOT_PATH=$(pwd)
+export MLAGENT_BUILD_ROOT_PATH=$(pwd)/%{builddir}
+
+# Run test
+# If gcov package generation is enabled, pass the test from GBS.
+%if 0%{?unit_test} && !0%{?gcov}
+bash %{test_script} ./tests/daemon/unittest_ml_agent
+bash %{test_script} ./tests/daemon/unittest_service_db
+bash %{test_script} ./tests/daemon/unittest_gdbus_util
+%endif # unit_test
+
+%install
+meson install -C %{builddir} --destdir=%{buildroot}
+
+%if 0%{?unit_test}
+%if 0%{?testcoverage}
+# 'lcov' generates the date format with UTC time zone by default. Let's replace UTC with KST.
+# If you can get a root privilege, run ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
+TZ='Asia/Seoul'; export TZ
+
+# Get commit info
+VCS=`cat ${RPM_SOURCE_DIR}/mlops-agent.spec | grep "^VCS:" | sed "s|VCS:\\W*\\(.*\\)|\\1|"`
+
+# Create human readable coverage report web page.
+# Create null gcda files if gcov didn't create it because there is completely no unit test for them.
+find . -name "*.gcno" -exec sh -c 'touch -a "${1%.gcno}.gcda"' _ {} \;
+# Remove gcda for meaningless file (CMake's autogenerated)
+find . -name "CMakeCCompilerId*.gcda" -delete
+find . -name "CMakeCXXCompilerId*.gcda" -delete
+# Generate report
+# TODO: the --no-external option is removed to include machine-learning-agent related source files.
+# Restore this option when there is proper way to include those source files.
+pushd %{builddir}
+lcov -t 'ML-Agent unittest coverage' -o unittest.info -c -d . -b $(pwd)
+# Exclude generated files (e.g., Orc, Protobuf) and device-dependent files.
+# Exclude files which are generated by gdbus-codegen and external files in /usr/*.
+lcov -r unittest.info "*/tests/*" "*/meson*/*" "*/*@sha/*" "*/*.so.p/*" "*/*tizen*" "*/*-dbus.c" "/usr/*" -o unittest-filtered.info
+# Visualize the report
+genhtml -o result unittest-filtered.info -t "ML-Agent %{version}-%{release} ${VCS}" --ignore-errors source -p ${RPM_BUILD_DIR}
+
+mkdir -p %{buildroot}%{_datadir}/ml-agent/unittest/
+cp -r result %{buildroot}%{_datadir}/ml-agent/unittest/
+popd
+
+%if 0%{?gcov:1}
+builddir=$(basename $PWD)
+gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir"
+mkdir -p "$gcno_obj_dir"
+find . -name '*.gcno' ! -path "*/tests/*" ! -name "meson-generated*" ! -name "sanitycheck*" ! -path "*tizen*" -exec cp --parents '{}' "$gcno_obj_dir" ';'
+
+mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name}
+install -m 0755 packaging/run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}
+%endif
+
+%endif # test coverage
+%endif # unit_test
+
+%post -p /sbin/ldconfig
+%postun -p /sbin/ldconfig
+
+%files
+%manifest mlops-agent.manifest
+%license LICENSE
+%attr(0755,root,root) %{_bindir}/mlops-agent
+%attr(0644,root,root) %{_unitdir}/mlops-agent.service
+%attr(0644,root,root) %config %{_sysconfdir}/dbus-1/system.d/mlops-agent.conf
+%attr(0644,root,root) %{_datadir}/dbus-1/system-services/org.tizen.machinelearning.service.service
+
+%files -n libmlops-agent
+%manifest mlops-agent.manifest
+%license LICENSE
+%{_libdir}/libmlops-agent.so.*
+
+%files -n libmlops-agent-devel
+%manifest mlops-agent.manifest
+%{_libdir}/libmlops-agent.so
+%{_libdir}/libmlops-agent.a
+%{_includedir}/ml/mlops-agent-interface.h
+%{_libdir}/pkgconfig/mlops-agent.pc
+
+%files test
+%manifest mlops-agent.manifest
+%license LICENSE
+%attr(0755,root,root) %{test_base_dir}/mlops-agent-test
+%attr(0755,root,root) %{test_base_dir}/services/org.tizen.machinelearning.service.service
+%{_libdir}/libmlops-agent-test.*
+
+%if 0%{?unit_test}
+%if 0%{?release_test}
+%files unittests
+%manifest mlops-agent.manifest
+%{test_base_dir}/unittests
+%{_libdir}/libmlops-agent-test.a
+%{_libdir}/libmlops-agent-test.so*
+%if 0%{?gcov:1}
+%{_bindir}/tizen-unittests/%{name}/run-unittest.sh
+%endif # gcov
+%endif # release_test
+
+%if 0%{?gcov:1}
+%files gcov
+%{_datadir}/gcov/obj/*
+%endif # gcov
+
+%if 0%{?testcoverage}
+%files unittest-coverage
+%{_datadir}/ml-agent/unittest/*
+%endif # testcoverage
+%endif # unit_test
+
+%changelog
+* Thu Feb 08 2024 Sangjung Woo <sangjung.woo@samsung.com>
+- Rename the package prefix to mlops-agent
+
+* Mon Dec 11 2023 Sangjung Woo <sangjung.woo@samsung.com>
+- Started ML-Agent packaging for 1.8.5 (Initial version sync to ML API)
index 25a87244b6c2bc9024ff648a0f989818be3fe788..8a836302d3545078010773632606e523ecfbd19a 100644 (file)
@@ -4,7 +4,7 @@ testenv.set('MLAGENT_SOURCE_ROOT_PATH', meson.source_root())
 testenv.set('MLAGENT_BUILD_ROOT_PATH', meson.build_root())
 
 unittest_ml_agent = executable('unittest_ml_agent',
-  'unittest_ml_agent.cc',
+  'unittest_mlops_agent.cc',
   dependencies: [gtest_dep, ml_agent_test_dep],
   install: get_option('install-test'),
   install_dir: unittest_install_dir
diff --git a/tests/daemon/unittest_ml_agent.cc b/tests/daemon/unittest_ml_agent.cc
deleted file mode 100644 (file)
index 1d79e6b..0000000
+++ /dev/null
@@ -1,614 +0,0 @@
-/**
- * @file        unittest_ml_agent.cc
- * @date        16 Jul 2022
- * @brief       Unit test for ML-Agent and its interface
- * @see         https://github.com/nnstreamer/deviceMLOps.MLAgent
- * @author      Sangjung Woo <sangjung.woo@samsung.com>
- * @bug         No known bugs
- */
-
-#include <gtest/gtest.h>
-#include <gio/gio.h>
-
-#include "log.h"
-#include "ml-agent-interface.h"
-
-/**
- * @brief Test base class for ML-Agent.
- */
-class MLAgentTest : public ::testing::Test
-{
-  protected:
-  GTestDBus *dbus;
-
-  public:
-  /**
-   * @brief Setup method for each test case.
-   */
-  void SetUp () override
-  {
-    g_autofree gchar *current_dir = g_get_current_dir ();
-    g_autofree gchar *services_dir
-        = g_build_filename (current_dir, "tests", "services", NULL);
-
-    dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
-    ASSERT_TRUE (dbus != nullptr);
-
-    g_test_dbus_add_service_dir (dbus, services_dir);
-    g_test_dbus_up (dbus);
-  }
-
-  /**
-   * @brief Teardown method for each test case.
-   */
-  void TearDown () override
-  {
-    if (dbus) {
-      g_test_dbus_down (dbus);
-      g_object_unref (dbus);
-      dbus = nullptr;
-    }
-  }
-};
-
-/**
- * @brief Testcase for ML-Agent interface - pipeline.
- */
-TEST_F (MLAgentTest, pipeline)
-{
-  const gchar pipeline_desc[] = "fakesrc ! fakesink";
-  gint ret;
-  gint state;
-  gint64 id;
-  gchar *desc = NULL;
-
-  ret = ml_agent_pipeline_set_description ("test-pipeline", pipeline_desc, NULL);
-  EXPECT_EQ (ret, 0);
-
-  ret = ml_agent_pipeline_get_description ("test-pipeline", &desc, NULL);
-  EXPECT_EQ (ret, 0);
-  EXPECT_STREQ (desc, pipeline_desc);
-  g_free (desc);
-
-  ret = ml_agent_pipeline_launch ("test-pipeline", &id, NULL);
-  EXPECT_EQ (ret, 0);
-
-  ret = ml_agent_pipeline_start (id, NULL);
-  EXPECT_EQ (ret, 0);
-  g_usleep (200000);
-
-  ret = ml_agent_pipeline_stop (id, NULL);
-  EXPECT_EQ (ret, 0);
-  g_usleep (200000);
-
-  ret = ml_agent_pipeline_get_state (id, &state, NULL);
-  EXPECT_EQ (ret, 0);
-  g_usleep (200000);
-
-  ret = ml_agent_pipeline_destroy (id, NULL);
-  EXPECT_EQ (ret, 0);
-  g_usleep (200000);
-
-  ret = ml_agent_pipeline_delete ("test-pipeline", NULL);
-  EXPECT_EQ (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - pipeline.
- */
-TEST_F (MLAgentTest, pipeline_set_description_01_n)
-{
-  gint ret;
-
-  ret = ml_agent_pipeline_set_description (NULL, "fakesrc ! fakesink", NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_pipeline_set_description ("", "fakesrc ! fakesink", NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_pipeline_set_description ("test-pipeline", NULL, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_pipeline_set_description ("test-pipeline", "", NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - pipeline.
- */
-TEST_F (MLAgentTest, pipeline_get_description_01_n)
-{
-  gint ret;
-  gchar *desc = NULL;
-
-  ret = ml_agent_pipeline_get_description (NULL, &desc, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_pipeline_get_description ("", &desc, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_pipeline_get_description ("test-pipeline", NULL, NULL);
-  EXPECT_NE (ret, 0);
-
-  /* no registered pipeline */
-  ret = ml_agent_pipeline_get_description ("test-pipeline", &desc, NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - pipeline.
- */
-TEST_F (MLAgentTest, pipeline_delete_01_n)
-{
-  gint ret;
-
-  ret = ml_agent_pipeline_delete (NULL, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_pipeline_delete ("", NULL);
-  EXPECT_NE (ret, 0);
-
-  /* no registered pipeline */
-  ret = ml_agent_pipeline_delete ("test-pipeline", NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - pipeline.
- */
-TEST_F (MLAgentTest, pipeline_launch_01_n)
-{
-  gint ret;
-  gint64 id;
-
-  ret = ml_agent_pipeline_launch (NULL, &id, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_pipeline_launch ("", &id, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_pipeline_launch ("test-pipeline", NULL, NULL);
-  EXPECT_NE (ret, 0);
-
-  /* no registered pipeline */
-  ret = ml_agent_pipeline_launch ("test-pipeline", &id, NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - pipeline.
- */
-TEST_F (MLAgentTest, pipeline_start_01_n)
-{
-  gint ret;
-
-  /* invalid id */
-  ret = ml_agent_pipeline_start (-1, NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - pipeline.
- */
-TEST_F (MLAgentTest, pipeline_stop_01_n)
-{
-  gint ret;
-
-  /* invalid id */
-  ret = ml_agent_pipeline_stop (-1, NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - pipeline.
- */
-TEST_F (MLAgentTest, pipeline_destroy_01_n)
-{
-  gint ret;
-
-  /* invalid id */
-  ret = ml_agent_pipeline_destroy (-1, NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - pipeline.
- */
-TEST_F (MLAgentTest, pipeline_get_state_01_n)
-{
-  gint ret;
-  gint state;
-  gint64 id;
-
-  ret = ml_agent_pipeline_set_description ("test-pipeline", "fakesrc ! fakesink", NULL);
-  EXPECT_EQ (ret, 0);
-
-  ret = ml_agent_pipeline_launch ("test-pipeline", &id, NULL);
-  EXPECT_EQ (ret, 0);
-  g_usleep (200000);
-
-  ret = ml_agent_pipeline_get_state (id, NULL, NULL);
-  EXPECT_NE (ret, 0);
-
-  /* invalid id */
-  ret = ml_agent_pipeline_get_state (-1, &state, NULL);
-  EXPECT_NE (ret, 0);
-
-  ret = ml_agent_pipeline_destroy (id, NULL);
-  EXPECT_EQ (ret, 0);
-  g_usleep (200000);
-
-  ret = ml_agent_pipeline_delete ("test-pipeline", NULL);
-  EXPECT_EQ (ret, 0);
-  g_usleep (200000);
-
-  /* no registered pipeline */
-  ret = ml_agent_pipeline_get_state (id, &state, NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - model.
- */
-TEST_F (MLAgentTest, model)
-{
-  gint ret;
-  guint ver1, ver2;
-  gchar *model_info = NULL;
-  gchar *str;
-
-  ret = ml_agent_model_register (
-      "test-model", "/path/model1.tflite", TRUE, NULL, NULL, &ver1, NULL);
-  EXPECT_EQ (ret, 0);
-  ret = ml_agent_model_register (
-      "test-model", "/path/model2.tflite", FALSE, NULL, NULL, &ver2, NULL);
-  EXPECT_EQ (ret, 0);
-
-  ret = ml_agent_model_update_description ("test-model", ver1, "model1desc", NULL);
-  EXPECT_EQ (ret, 0);
-
-  ret = ml_agent_model_get ("test-model", ver1, &model_info, NULL);
-  EXPECT_EQ (ret, 0);
-
-  str = (model_info != NULL) ? strstr (model_info, "/path/model1.tflite") : NULL;
-  EXPECT_TRUE (str != NULL);
-  str = (model_info != NULL) ? strstr (model_info, "model1desc") : NULL;
-  EXPECT_TRUE (str != NULL);
-  g_free (model_info);
-  model_info = NULL;
-
-  ret = ml_agent_model_activate ("test-model", ver2, NULL);
-  EXPECT_EQ (ret, 0);
-  ret = ml_agent_model_get_activated ("test-model", &model_info, NULL);
-  EXPECT_EQ (ret, 0);
-
-  str = (model_info != NULL) ? strstr (model_info, "/path/model2.tflite") : NULL;
-  EXPECT_TRUE (str != NULL);
-  g_free (model_info);
-  model_info = NULL;
-
-  ret = ml_agent_model_get_all ("test-model", &model_info, NULL);
-  EXPECT_EQ (ret, 0);
-
-  str = (model_info != NULL) ? strstr (model_info, "/path/model1.tflite") : NULL;
-  EXPECT_TRUE (str != NULL);
-  str = (model_info != NULL) ? strstr (model_info, "/path/model2.tflite") : NULL;
-  EXPECT_TRUE (str != NULL);
-  g_free (model_info);
-  model_info = NULL;
-
-  ret = ml_agent_model_delete ("test-model", 0U, NULL);
-  EXPECT_EQ (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - model.
- */
-TEST_F (MLAgentTest, model_register_01_n)
-{
-  gint ret;
-  guint ver;
-
-  ret = ml_agent_model_register (NULL, "/path/model.tflite", FALSE, NULL, NULL, &ver, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_register ("", "/path/model.tflite", FALSE, NULL, NULL, &ver, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_register ("test-model", NULL, FALSE, NULL, NULL, &ver, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_register ("test-model", "", FALSE, NULL, NULL, &ver, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_register (
-      "test-model", "/path/model.tflite", FALSE, NULL, NULL, NULL, NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - model.
- */
-TEST_F (MLAgentTest, model_update_description_01_n)
-{
-  gint ret;
-  guint ver;
-
-  ret = ml_agent_model_register (
-      "test-model", "/path/model.tflite", FALSE, NULL, NULL, &ver, NULL);
-  EXPECT_EQ (ret, 0);
-
-  ret = ml_agent_model_update_description (NULL, ver, "desc", NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_update_description ("", ver, "desc", NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_update_description ("test-model", 0U, "desc", NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_update_description ("test-model", ver, NULL, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_update_description ("test-model", ver, "", NULL);
-  EXPECT_NE (ret, 0);
-
-  /* invalid version */
-  ret = ml_agent_model_update_description ("test-model", (ver + 5U), "desc", NULL);
-  EXPECT_NE (ret, 0);
-
-  ret = ml_agent_model_delete ("test-model", 0U, NULL);
-  EXPECT_EQ (ret, 0);
-
-  /* no registered model */
-  ret = ml_agent_model_update_description ("test-model", ver, "desc", NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - model.
- */
-TEST_F (MLAgentTest, model_activate_01_n)
-{
-  gint ret;
-  guint ver;
-
-  ret = ml_agent_model_register (
-      "test-model", "/path/model.tflite", FALSE, NULL, NULL, &ver, NULL);
-  EXPECT_EQ (ret, 0);
-
-  ret = ml_agent_model_activate (NULL, ver, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_activate ("", ver, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_activate ("test-model", 0U, NULL);
-  EXPECT_NE (ret, 0);
-
-  /* invalid version */
-  ret = ml_agent_model_activate ("test-model", (ver + 5U), NULL);
-  EXPECT_NE (ret, 0);
-
-  ret = ml_agent_model_delete ("test-model", 0U, NULL);
-  EXPECT_EQ (ret, 0);
-
-  /* no registered model */
-  ret = ml_agent_model_activate ("test-model", ver, NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - model.
- */
-TEST_F (MLAgentTest, model_get_01_n)
-{
-  gint ret;
-  guint ver;
-  gchar *model_info = NULL;
-
-  ret = ml_agent_model_register (
-      "test-model", "/path/model.tflite", FALSE, NULL, NULL, &ver, NULL);
-  EXPECT_EQ (ret, 0);
-
-  ret = ml_agent_model_get (NULL, ver, &model_info, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_get ("", ver, &model_info, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_get ("test-model", 0U, &model_info, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_get ("test-model", ver, NULL, NULL);
-  EXPECT_NE (ret, 0);
-
-  /* invalid version */
-  ret = ml_agent_model_get ("test-model", (ver + 5U), &model_info, NULL);
-  EXPECT_NE (ret, 0);
-
-  ret = ml_agent_model_delete ("test-model", 0U, NULL);
-  EXPECT_EQ (ret, 0);
-
-  /* no registered model */
-  ret = ml_agent_model_get ("test-model", ver, &model_info, NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - model.
- */
-TEST_F (MLAgentTest, model_get_activated_01_n)
-{
-  gint ret;
-  guint ver;
-  gchar *model_info = NULL;
-
-  ret = ml_agent_model_register (
-      "test-model", "/path/model.tflite", FALSE, NULL, NULL, &ver, NULL);
-  EXPECT_EQ (ret, 0);
-
-  ret = ml_agent_model_get_activated (NULL, &model_info, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_get_activated ("", &model_info, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_get_activated ("test-model", NULL, NULL);
-  EXPECT_NE (ret, 0);
-
-  /* no activated model */
-  ret = ml_agent_model_get_activated ("test-model", &model_info, NULL);
-  EXPECT_NE (ret, 0);
-
-  ret = ml_agent_model_delete ("test-model", 0U, NULL);
-  EXPECT_EQ (ret, 0);
-
-  /* no registered model */
-  ret = ml_agent_model_get_activated ("test-model", &model_info, NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - model.
- */
-TEST_F (MLAgentTest, model_get_all_01_n)
-{
-  gint ret;
-  gchar *model_info = NULL;
-
-  ret = ml_agent_model_get_all (NULL, &model_info, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_get_all ("", &model_info, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_get_all ("test-model", NULL, NULL);
-  EXPECT_NE (ret, 0);
-
-  /* no registered model */
-  ret = ml_agent_model_get_all ("test-model", &model_info, NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - model.
- */
-TEST_F (MLAgentTest, model_delete_01_n)
-{
-  gint ret;
-  guint ver;
-
-  ret = ml_agent_model_register (
-      "test-model", "/path/model.tflite", FALSE, NULL, NULL, &ver, NULL);
-  EXPECT_EQ (ret, 0);
-
-  ret = ml_agent_model_delete (NULL, ver, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_model_delete ("", ver, NULL);
-  EXPECT_NE (ret, 0);
-
-  /* invalid version */
-  ret = ml_agent_model_delete ("test-model", (ver + 5U), NULL);
-  EXPECT_NE (ret, 0);
-
-  ret = ml_agent_model_delete ("test-model", 0U, NULL);
-  EXPECT_EQ (ret, 0);
-
-  /* no registered model */
-  ret = ml_agent_model_delete ("test-model", 0U, NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - resource.
- */
-TEST_F (MLAgentTest, resource)
-{
-  gint ret;
-  gchar *res_info = NULL;
-  gchar *str;
-
-  ret = ml_agent_resource_add ("test-res", "/path/res1.dat", NULL, NULL, NULL);
-  EXPECT_EQ (ret, 0);
-
-  ret = ml_agent_resource_get ("test-res", &res_info, NULL);
-  EXPECT_EQ (ret, 0);
-
-  str = (res_info != NULL) ? strstr (res_info, "/path/res1.dat") : NULL;
-  EXPECT_TRUE (str != NULL);
-  str = (res_info != NULL) ? strstr (res_info, "/path/res2.dat") : NULL;
-  EXPECT_FALSE (str != NULL);
-  g_free (res_info);
-  res_info = NULL;
-
-  ret = ml_agent_resource_add ("test-res", "/path/res2.dat", "res2desc", NULL, NULL);
-  EXPECT_EQ (ret, 0);
-
-  ret = ml_agent_resource_get ("test-res", &res_info, NULL);
-  EXPECT_EQ (ret, 0);
-
-  str = (res_info != NULL) ? strstr (res_info, "/path/res1.dat") : NULL;
-  EXPECT_TRUE (str != NULL);
-  str = (res_info != NULL) ? strstr (res_info, "/path/res2.dat") : NULL;
-  EXPECT_TRUE (str != NULL);
-  str = (res_info != NULL) ? strstr (res_info, "res2desc") : NULL;
-  EXPECT_TRUE (str != NULL);
-  g_free (res_info);
-  res_info = NULL;
-
-  ret = ml_agent_resource_delete ("test-res", NULL);
-  EXPECT_EQ (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - resource.
- */
-TEST_F (MLAgentTest, resource_add_01_n)
-{
-  gint ret;
-
-  ret = ml_agent_resource_add (NULL, "/path/res.dat", NULL, NULL, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_resource_add ("", "/path/res.dat", NULL, NULL, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_resource_add ("test-res", NULL, NULL, NULL, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_resource_add ("test-res", "", NULL, NULL, NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - resource.
- */
-TEST_F (MLAgentTest, resource_delete_01_n)
-{
-  gint ret;
-
-  ret = ml_agent_resource_delete (NULL, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_resource_delete ("", NULL);
-  EXPECT_NE (ret, 0);
-
-  /* no registered resource */
-  ret = ml_agent_resource_delete ("test-res", NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Testcase for ML-Agent interface - resource.
- */
-TEST_F (MLAgentTest, resource_get_01_n)
-{
-  gint ret;
-  gchar *res_info = NULL;
-
-  ret = ml_agent_resource_get (NULL, &res_info, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_resource_get ("", &res_info, NULL);
-  EXPECT_NE (ret, 0);
-  ret = ml_agent_resource_get ("test-res", NULL, NULL);
-  EXPECT_NE (ret, 0);
-
-  /* no registered resource */
-  ret = ml_agent_resource_get ("test-res", &res_info, NULL);
-  EXPECT_NE (ret, 0);
-}
-
-/**
- * @brief Main gtest
- */
-int
-main (int argc, char **argv)
-{
-  int result = -1;
-
-  try {
-    testing::InitGoogleTest (&argc, argv);
-  } catch (...) {
-    ml_logw ("catch 'testing::internal::<unnamed>::ClassUniqueToAlwaysTrue'");
-  }
-
-  try {
-    result = RUN_ALL_TESTS ();
-  } catch (...) {
-    ml_logw ("catch `testing::internal::GoogleTestFailureException`");
-  }
-
-  return result;
-}
diff --git a/tests/daemon/unittest_mlops_agent.cc b/tests/daemon/unittest_mlops_agent.cc
new file mode 100644 (file)
index 0000000..f2734e9
--- /dev/null
@@ -0,0 +1,614 @@
+/**
+ * @file        unittest_ml_agent.cc
+ * @date        16 Jul 2022
+ * @brief       Unit test for ML-Agent and its interface
+ * @see         https://github.com/nnstreamer/deviceMLOps.MLAgent
+ * @author      Sangjung Woo <sangjung.woo@samsung.com>
+ * @bug         No known bugs
+ */
+
+#include <gtest/gtest.h>
+#include <gio/gio.h>
+
+#include "log.h"
+#include "mlops-agent-interface.h"
+
+/**
+ * @brief Test base class for ML-Agent.
+ */
+class MLAgentTest : public ::testing::Test
+{
+  protected:
+  GTestDBus *dbus;
+
+  public:
+  /**
+   * @brief Setup method for each test case.
+   */
+  void SetUp () override
+  {
+    g_autofree gchar *current_dir = g_get_current_dir ();
+    g_autofree gchar *services_dir
+        = g_build_filename (current_dir, "tests", "services", NULL);
+
+    dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
+    ASSERT_TRUE (dbus != nullptr);
+
+    g_test_dbus_add_service_dir (dbus, services_dir);
+    g_test_dbus_up (dbus);
+  }
+
+  /**
+   * @brief Teardown method for each test case.
+   */
+  void TearDown () override
+  {
+    if (dbus) {
+      g_test_dbus_down (dbus);
+      g_object_unref (dbus);
+      dbus = nullptr;
+    }
+  }
+};
+
+/**
+ * @brief Testcase for ML-Agent interface - pipeline.
+ */
+TEST_F (MLAgentTest, pipeline)
+{
+  const gchar pipeline_desc[] = "fakesrc ! fakesink";
+  gint ret;
+  gint state;
+  gint64 id;
+  gchar *desc = NULL;
+
+  ret = ml_agent_pipeline_set_description ("test-pipeline", pipeline_desc, NULL);
+  EXPECT_EQ (ret, 0);
+
+  ret = ml_agent_pipeline_get_description ("test-pipeline", &desc, NULL);
+  EXPECT_EQ (ret, 0);
+  EXPECT_STREQ (desc, pipeline_desc);
+  g_free (desc);
+
+  ret = ml_agent_pipeline_launch ("test-pipeline", &id, NULL);
+  EXPECT_EQ (ret, 0);
+
+  ret = ml_agent_pipeline_start (id, NULL);
+  EXPECT_EQ (ret, 0);
+  g_usleep (200000);
+
+  ret = ml_agent_pipeline_stop (id, NULL);
+  EXPECT_EQ (ret, 0);
+  g_usleep (200000);
+
+  ret = ml_agent_pipeline_get_state (id, &state, NULL);
+  EXPECT_EQ (ret, 0);
+  g_usleep (200000);
+
+  ret = ml_agent_pipeline_destroy (id, NULL);
+  EXPECT_EQ (ret, 0);
+  g_usleep (200000);
+
+  ret = ml_agent_pipeline_delete ("test-pipeline", NULL);
+  EXPECT_EQ (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - pipeline.
+ */
+TEST_F (MLAgentTest, pipeline_set_description_01_n)
+{
+  gint ret;
+
+  ret = ml_agent_pipeline_set_description (NULL, "fakesrc ! fakesink", NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_pipeline_set_description ("", "fakesrc ! fakesink", NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_pipeline_set_description ("test-pipeline", NULL, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_pipeline_set_description ("test-pipeline", "", NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - pipeline.
+ */
+TEST_F (MLAgentTest, pipeline_get_description_01_n)
+{
+  gint ret;
+  gchar *desc = NULL;
+
+  ret = ml_agent_pipeline_get_description (NULL, &desc, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_pipeline_get_description ("", &desc, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_pipeline_get_description ("test-pipeline", NULL, NULL);
+  EXPECT_NE (ret, 0);
+
+  /* no registered pipeline */
+  ret = ml_agent_pipeline_get_description ("test-pipeline", &desc, NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - pipeline.
+ */
+TEST_F (MLAgentTest, pipeline_delete_01_n)
+{
+  gint ret;
+
+  ret = ml_agent_pipeline_delete (NULL, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_pipeline_delete ("", NULL);
+  EXPECT_NE (ret, 0);
+
+  /* no registered pipeline */
+  ret = ml_agent_pipeline_delete ("test-pipeline", NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - pipeline.
+ */
+TEST_F (MLAgentTest, pipeline_launch_01_n)
+{
+  gint ret;
+  gint64 id;
+
+  ret = ml_agent_pipeline_launch (NULL, &id, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_pipeline_launch ("", &id, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_pipeline_launch ("test-pipeline", NULL, NULL);
+  EXPECT_NE (ret, 0);
+
+  /* no registered pipeline */
+  ret = ml_agent_pipeline_launch ("test-pipeline", &id, NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - pipeline.
+ */
+TEST_F (MLAgentTest, pipeline_start_01_n)
+{
+  gint ret;
+
+  /* invalid id */
+  ret = ml_agent_pipeline_start (-1, NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - pipeline.
+ */
+TEST_F (MLAgentTest, pipeline_stop_01_n)
+{
+  gint ret;
+
+  /* invalid id */
+  ret = ml_agent_pipeline_stop (-1, NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - pipeline.
+ */
+TEST_F (MLAgentTest, pipeline_destroy_01_n)
+{
+  gint ret;
+
+  /* invalid id */
+  ret = ml_agent_pipeline_destroy (-1, NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - pipeline.
+ */
+TEST_F (MLAgentTest, pipeline_get_state_01_n)
+{
+  gint ret;
+  gint state;
+  gint64 id;
+
+  ret = ml_agent_pipeline_set_description ("test-pipeline", "fakesrc ! fakesink", NULL);
+  EXPECT_EQ (ret, 0);
+
+  ret = ml_agent_pipeline_launch ("test-pipeline", &id, NULL);
+  EXPECT_EQ (ret, 0);
+  g_usleep (200000);
+
+  ret = ml_agent_pipeline_get_state (id, NULL, NULL);
+  EXPECT_NE (ret, 0);
+
+  /* invalid id */
+  ret = ml_agent_pipeline_get_state (-1, &state, NULL);
+  EXPECT_NE (ret, 0);
+
+  ret = ml_agent_pipeline_destroy (id, NULL);
+  EXPECT_EQ (ret, 0);
+  g_usleep (200000);
+
+  ret = ml_agent_pipeline_delete ("test-pipeline", NULL);
+  EXPECT_EQ (ret, 0);
+  g_usleep (200000);
+
+  /* no registered pipeline */
+  ret = ml_agent_pipeline_get_state (id, &state, NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - model.
+ */
+TEST_F (MLAgentTest, model)
+{
+  gint ret;
+  guint ver1, ver2;
+  gchar *model_info = NULL;
+  gchar *str;
+
+  ret = ml_agent_model_register (
+      "test-model", "/path/model1.tflite", TRUE, NULL, NULL, &ver1, NULL);
+  EXPECT_EQ (ret, 0);
+  ret = ml_agent_model_register (
+      "test-model", "/path/model2.tflite", FALSE, NULL, NULL, &ver2, NULL);
+  EXPECT_EQ (ret, 0);
+
+  ret = ml_agent_model_update_description ("test-model", ver1, "model1desc", NULL);
+  EXPECT_EQ (ret, 0);
+
+  ret = ml_agent_model_get ("test-model", ver1, &model_info, NULL);
+  EXPECT_EQ (ret, 0);
+
+  str = (model_info != NULL) ? strstr (model_info, "/path/model1.tflite") : NULL;
+  EXPECT_TRUE (str != NULL);
+  str = (model_info != NULL) ? strstr (model_info, "model1desc") : NULL;
+  EXPECT_TRUE (str != NULL);
+  g_free (model_info);
+  model_info = NULL;
+
+  ret = ml_agent_model_activate ("test-model", ver2, NULL);
+  EXPECT_EQ (ret, 0);
+  ret = ml_agent_model_get_activated ("test-model", &model_info, NULL);
+  EXPECT_EQ (ret, 0);
+
+  str = (model_info != NULL) ? strstr (model_info, "/path/model2.tflite") : NULL;
+  EXPECT_TRUE (str != NULL);
+  g_free (model_info);
+  model_info = NULL;
+
+  ret = ml_agent_model_get_all ("test-model", &model_info, NULL);
+  EXPECT_EQ (ret, 0);
+
+  str = (model_info != NULL) ? strstr (model_info, "/path/model1.tflite") : NULL;
+  EXPECT_TRUE (str != NULL);
+  str = (model_info != NULL) ? strstr (model_info, "/path/model2.tflite") : NULL;
+  EXPECT_TRUE (str != NULL);
+  g_free (model_info);
+  model_info = NULL;
+
+  ret = ml_agent_model_delete ("test-model", 0U, NULL);
+  EXPECT_EQ (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - model.
+ */
+TEST_F (MLAgentTest, model_register_01_n)
+{
+  gint ret;
+  guint ver;
+
+  ret = ml_agent_model_register (NULL, "/path/model.tflite", FALSE, NULL, NULL, &ver, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_register ("", "/path/model.tflite", FALSE, NULL, NULL, &ver, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_register ("test-model", NULL, FALSE, NULL, NULL, &ver, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_register ("test-model", "", FALSE, NULL, NULL, &ver, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_register (
+      "test-model", "/path/model.tflite", FALSE, NULL, NULL, NULL, NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - model.
+ */
+TEST_F (MLAgentTest, model_update_description_01_n)
+{
+  gint ret;
+  guint ver;
+
+  ret = ml_agent_model_register (
+      "test-model", "/path/model.tflite", FALSE, NULL, NULL, &ver, NULL);
+  EXPECT_EQ (ret, 0);
+
+  ret = ml_agent_model_update_description (NULL, ver, "desc", NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_update_description ("", ver, "desc", NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_update_description ("test-model", 0U, "desc", NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_update_description ("test-model", ver, NULL, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_update_description ("test-model", ver, "", NULL);
+  EXPECT_NE (ret, 0);
+
+  /* invalid version */
+  ret = ml_agent_model_update_description ("test-model", (ver + 5U), "desc", NULL);
+  EXPECT_NE (ret, 0);
+
+  ret = ml_agent_model_delete ("test-model", 0U, NULL);
+  EXPECT_EQ (ret, 0);
+
+  /* no registered model */
+  ret = ml_agent_model_update_description ("test-model", ver, "desc", NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - model.
+ */
+TEST_F (MLAgentTest, model_activate_01_n)
+{
+  gint ret;
+  guint ver;
+
+  ret = ml_agent_model_register (
+      "test-model", "/path/model.tflite", FALSE, NULL, NULL, &ver, NULL);
+  EXPECT_EQ (ret, 0);
+
+  ret = ml_agent_model_activate (NULL, ver, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_activate ("", ver, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_activate ("test-model", 0U, NULL);
+  EXPECT_NE (ret, 0);
+
+  /* invalid version */
+  ret = ml_agent_model_activate ("test-model", (ver + 5U), NULL);
+  EXPECT_NE (ret, 0);
+
+  ret = ml_agent_model_delete ("test-model", 0U, NULL);
+  EXPECT_EQ (ret, 0);
+
+  /* no registered model */
+  ret = ml_agent_model_activate ("test-model", ver, NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - model.
+ */
+TEST_F (MLAgentTest, model_get_01_n)
+{
+  gint ret;
+  guint ver;
+  gchar *model_info = NULL;
+
+  ret = ml_agent_model_register (
+      "test-model", "/path/model.tflite", FALSE, NULL, NULL, &ver, NULL);
+  EXPECT_EQ (ret, 0);
+
+  ret = ml_agent_model_get (NULL, ver, &model_info, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_get ("", ver, &model_info, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_get ("test-model", 0U, &model_info, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_get ("test-model", ver, NULL, NULL);
+  EXPECT_NE (ret, 0);
+
+  /* invalid version */
+  ret = ml_agent_model_get ("test-model", (ver + 5U), &model_info, NULL);
+  EXPECT_NE (ret, 0);
+
+  ret = ml_agent_model_delete ("test-model", 0U, NULL);
+  EXPECT_EQ (ret, 0);
+
+  /* no registered model */
+  ret = ml_agent_model_get ("test-model", ver, &model_info, NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - model.
+ */
+TEST_F (MLAgentTest, model_get_activated_01_n)
+{
+  gint ret;
+  guint ver;
+  gchar *model_info = NULL;
+
+  ret = ml_agent_model_register (
+      "test-model", "/path/model.tflite", FALSE, NULL, NULL, &ver, NULL);
+  EXPECT_EQ (ret, 0);
+
+  ret = ml_agent_model_get_activated (NULL, &model_info, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_get_activated ("", &model_info, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_get_activated ("test-model", NULL, NULL);
+  EXPECT_NE (ret, 0);
+
+  /* no activated model */
+  ret = ml_agent_model_get_activated ("test-model", &model_info, NULL);
+  EXPECT_NE (ret, 0);
+
+  ret = ml_agent_model_delete ("test-model", 0U, NULL);
+  EXPECT_EQ (ret, 0);
+
+  /* no registered model */
+  ret = ml_agent_model_get_activated ("test-model", &model_info, NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - model.
+ */
+TEST_F (MLAgentTest, model_get_all_01_n)
+{
+  gint ret;
+  gchar *model_info = NULL;
+
+  ret = ml_agent_model_get_all (NULL, &model_info, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_get_all ("", &model_info, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_get_all ("test-model", NULL, NULL);
+  EXPECT_NE (ret, 0);
+
+  /* no registered model */
+  ret = ml_agent_model_get_all ("test-model", &model_info, NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - model.
+ */
+TEST_F (MLAgentTest, model_delete_01_n)
+{
+  gint ret;
+  guint ver;
+
+  ret = ml_agent_model_register (
+      "test-model", "/path/model.tflite", FALSE, NULL, NULL, &ver, NULL);
+  EXPECT_EQ (ret, 0);
+
+  ret = ml_agent_model_delete (NULL, ver, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_model_delete ("", ver, NULL);
+  EXPECT_NE (ret, 0);
+
+  /* invalid version */
+  ret = ml_agent_model_delete ("test-model", (ver + 5U), NULL);
+  EXPECT_NE (ret, 0);
+
+  ret = ml_agent_model_delete ("test-model", 0U, NULL);
+  EXPECT_EQ (ret, 0);
+
+  /* no registered model */
+  ret = ml_agent_model_delete ("test-model", 0U, NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - resource.
+ */
+TEST_F (MLAgentTest, resource)
+{
+  gint ret;
+  gchar *res_info = NULL;
+  gchar *str;
+
+  ret = ml_agent_resource_add ("test-res", "/path/res1.dat", NULL, NULL, NULL);
+  EXPECT_EQ (ret, 0);
+
+  ret = ml_agent_resource_get ("test-res", &res_info, NULL);
+  EXPECT_EQ (ret, 0);
+
+  str = (res_info != NULL) ? strstr (res_info, "/path/res1.dat") : NULL;
+  EXPECT_TRUE (str != NULL);
+  str = (res_info != NULL) ? strstr (res_info, "/path/res2.dat") : NULL;
+  EXPECT_FALSE (str != NULL);
+  g_free (res_info);
+  res_info = NULL;
+
+  ret = ml_agent_resource_add ("test-res", "/path/res2.dat", "res2desc", NULL, NULL);
+  EXPECT_EQ (ret, 0);
+
+  ret = ml_agent_resource_get ("test-res", &res_info, NULL);
+  EXPECT_EQ (ret, 0);
+
+  str = (res_info != NULL) ? strstr (res_info, "/path/res1.dat") : NULL;
+  EXPECT_TRUE (str != NULL);
+  str = (res_info != NULL) ? strstr (res_info, "/path/res2.dat") : NULL;
+  EXPECT_TRUE (str != NULL);
+  str = (res_info != NULL) ? strstr (res_info, "res2desc") : NULL;
+  EXPECT_TRUE (str != NULL);
+  g_free (res_info);
+  res_info = NULL;
+
+  ret = ml_agent_resource_delete ("test-res", NULL);
+  EXPECT_EQ (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - resource.
+ */
+TEST_F (MLAgentTest, resource_add_01_n)
+{
+  gint ret;
+
+  ret = ml_agent_resource_add (NULL, "/path/res.dat", NULL, NULL, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_resource_add ("", "/path/res.dat", NULL, NULL, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_resource_add ("test-res", NULL, NULL, NULL, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_resource_add ("test-res", "", NULL, NULL, NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - resource.
+ */
+TEST_F (MLAgentTest, resource_delete_01_n)
+{
+  gint ret;
+
+  ret = ml_agent_resource_delete (NULL, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_resource_delete ("", NULL);
+  EXPECT_NE (ret, 0);
+
+  /* no registered resource */
+  ret = ml_agent_resource_delete ("test-res", NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Testcase for ML-Agent interface - resource.
+ */
+TEST_F (MLAgentTest, resource_get_01_n)
+{
+  gint ret;
+  gchar *res_info = NULL;
+
+  ret = ml_agent_resource_get (NULL, &res_info, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_resource_get ("", &res_info, NULL);
+  EXPECT_NE (ret, 0);
+  ret = ml_agent_resource_get ("test-res", NULL, NULL);
+  EXPECT_NE (ret, 0);
+
+  /* no registered resource */
+  ret = ml_agent_resource_get ("test-res", &res_info, NULL);
+  EXPECT_NE (ret, 0);
+}
+
+/**
+ * @brief Main gtest
+ */
+int
+main (int argc, char **argv)
+{
+  int result = -1;
+
+  try {
+    testing::InitGoogleTest (&argc, argv);
+  } catch (...) {
+    ml_logw ("catch 'testing::internal::<unnamed>::ClassUniqueToAlwaysTrue'");
+  }
+
+  try {
+    result = RUN_ALL_TESTS ();
+  } catch (...) {
+    ml_logw ("catch `testing::internal::GoogleTestFailureException`");
+  }
+
+  return result;
+}
index 7cc34b640864516235499bdf6b36c76cf5509d0a..16af858a54428a89a0a7d1ff20d75e8a6cedc558 100644 (file)
@@ -1,9 +1,9 @@
 # Install path for unittest
-test_base_dir = join_paths(ml_agent_install_bindir, 'ml-agent-test')
+test_base_dir = join_paths(ml_agent_install_bindir, 'ml-test')
 unittest_install_dir = join_paths(test_base_dir, 'unittests')
 
 ml_agent_lib_objs = ml_agent_lib.extract_objects(ml_agent_lib_srcs)
-ml_agent_test_both_lib = both_libraries('ml-agent-test',
+ml_agent_test_both_lib = both_libraries('mlops-agent-test',
   dependencies: ml_agent_deps,
   include_directories: ml_agent_incs,
   install: true,
@@ -26,7 +26,7 @@ ml_agent_test_dep = declare_dependency(
 )
 
 ml_agent_main_objs = ml_agent_executable.extract_objects(ml_agent_main_file)
-executable('machine-learning-agent-test',
+executable('mlops-agent-test',
   dependencies: ml_agent_test_dep,
   install: true,
   install_dir: test_base_dir,
index e02d3341a007a1bab02ff75716b047ba4d066ad5..493811c84f2aa5e4f9b891d77d8f502a9cb5c17b 100644 (file)
@@ -1,3 +1,3 @@
 [D-BUS Service]
 Name=org.tizen.machinelearning.service
-Exec=@build_dir@/machine-learning-agent-test --session --path=.
+Exec=@build_dir@/mlops-agent-test --session --path=.