Tests: Revise the unittests package
authorWook Song <wook16.song@samsung.com>
Thu, 18 May 2023 04:32:23 +0000 (13:32 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 18 May 2023 07:41:12 +0000 (16:41 +0900)
This patch revised the meson build script and Tizen's rpm spec file to
include files which are required by the test daemon,
machine-learning-agent-test.

Signed-off-by: Wook Song <wook16.song@samsung.com>
daemon/meson.build
packaging/machine-learning-api.spec
tests/capi/unittest_capi_service_agent_client.cc
tests/daemon/unittest_gdbus_util.cc
tests/meson.build
tests/mock/meson.build
tests/services/meson.build

index 71c6b84..f9cfacf 100644 (file)
@@ -83,7 +83,8 @@ ml_agentd_test_both_lib = both_libraries('ml-agentd-test',
   ml_agentd_lib_service_db_srcs,
   dependencies: ml_agentd_deps,
   include_directories: ml_agentd_incs,
-  install: false,
+  install: get_option('install-test'),
+  install_dir: api_install_libdir,
   cpp_args: ['-DDB_PATH="."', daemon_cpp_db_key_prefix_arg],
   objects: ml_agentd_lib_common_objs,
   version: api_version,
index d246977..cd02f89 100644 (file)
@@ -533,6 +533,9 @@ install -m 0755 packaging/run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests
 %files -n capi-machine-learning-unittests
 %manifest capi-machine-learning-inference.manifest
 %{_bindir}/unittest-ml
+%{_libdir}/libml-agentd-test.a
+%{_libdir}/libml-agentd-test.so*
+%{_libdir}/libunittest_mock.so*
 %if 0%{?gcov:1}
 %{_bindir}/tizen-unittests/%{name}/run-unittest.sh
 %endif
index 235594f..1b55a86 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <gtest/gtest.h>
+#include <gdbus-util.h>
 #include <gio/gio.h>
 #include <ml-api-inference-pipeline-internal.h>
 #include <ml-api-internal.h>
@@ -1258,6 +1259,14 @@ TEST (MLServiceAgentTestDbusUnconnected, pipeline_n)
 {
   int status;
 
+  /**
+   * FIXME: The following line blocks this test from running
+   * with the ml-agent daemon, not the test daemon.
+   */
+  if (!gdbus_get_system_connection (false)) {
+    return;
+  }
+
   status = ml_service_set_pipeline ("test", "test");
   EXPECT_EQ (ML_ERROR_IO_ERROR, status);
 
@@ -1305,6 +1314,14 @@ TEST (MLServiceAgentTestDbusUnconnected, model_n)
   const gchar *root_path = g_getenv ("MLAPI_SOURCE_ROOT_PATH");
   unsigned int version;
 
+  /**
+   * FIXME: The following line blocks this test from running
+   * with the ml-agent daemon, not the test daemon.
+   */
+  if (!gdbus_get_system_connection (false)) {
+    return;
+  }
+
   /* ml_service_model_register() requires absolute path to model, ignore this case. */
   if (root_path == NULL)
     return;
index 1a9996a..a855aa9 100644 (file)
@@ -37,6 +37,13 @@ TEST (gdbusInstanceNotInitialized, get_system_connection_n)
   gboolean is_session = true;
   int ret;
 
+  /**
+   * FIXME: The following line blocks this test from running
+   * with the ml-agent daemon, not the test daemon.
+   */
+  if (!gdbus_get_system_connection (!is_session)) {
+    return;
+  }
   ret = gdbus_get_system_connection (is_session);
   EXPECT_EQ (-ENOSYS, ret);
 
index 3ce05ab..8884bad 100644 (file)
@@ -28,6 +28,8 @@ if get_option('enable-ml-service')
   executable('machine-learning-agent-test',
     test_dbus_impl_srcs,
     dependencies: [lib_ml_agentd_test_dep, gdbus_gen_test_dep],
+    install: get_option('install-test'),
+    install_dir: unittest_base_dir,
     link_with: lib_unittest_mock,
     objects: ml_agentd_main_objs,
   )
index 414f3a7..05e992c 100644 (file)
@@ -1,5 +1,7 @@
 lib_unittest_mock = shared_library('unittest_mock',
     files('mock_package_manager.c'),
     dependencies: glib_dep,
+    install: get_option('install-test'),
+    install_dir: api_install_libdir,
     include_directories: nns_capi_include
 )
index 8a3d1fd..1875220 100644 (file)
@@ -7,3 +7,19 @@ configure_file(
   output: test_dbus_service_file,
   configuration: builddir_cdata
 )
+
+if get_option('install-test')
+  installed_builddir_cdata = configuration_data()
+  installed_builddir_cdata.set('build_dir', unittest_base_dir)
+  test_service_file = configure_file(
+    input: test_dbus_service_file + '.in',
+    output: test_dbus_service_file + '.install',
+    configuration: installed_builddir_cdata
+  )
+  install_data(
+    test_service_file,
+    install_dir: join_paths(unittest_install_dir, 'services'),
+    install_mode: 'rw-r--r--',
+    rename: test_dbus_service_file,
+  )
+endif