Tests/Meson: Revise meson build scripts in tests
authorWook Song <wook16.song@samsung.com>
Wed, 19 Apr 2023 04:16:09 +0000 (13:16 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Wed, 19 Apr 2023 08:21:39 +0000 (17:21 +0900)
This patch revises the meson build scripts related to the test
sub-directory.

Signed-off-by: Wook Song <wook16.song@samsung.com>
meson.build
tests/capi/meson.build
tests/meson.build

index 729ae1c..10f668e 100644 (file)
@@ -182,5 +182,10 @@ endif
 
 # Run unittest
 if get_option('enable-test')
-  subdir('tests')
+  gtest_dep = dependency('gtest', required: false)
+  if gtest_dep.found()
+    subdir('tests')
+  else
+    warning('The enable-test option requires google-test.')
+  endif
 endif
index ef89998..d36a417 100644 (file)
@@ -1,9 +1,3 @@
-unittest_util_static = static_library('unittest_util',
-  files('unittest_util.c'),
-  dependencies: [glib_dep],
-  install: false,
-)
-
 unittest_capi_inference_single = executable('unittest_capi_inference_single',
   'unittest_capi_inference_single.cc',
   dependencies: [nns_capi_single_dep, gtest_dep],
@@ -13,13 +7,6 @@ unittest_capi_inference_single = executable('unittest_capi_inference_single',
 )
 test('unittest_capi_inference_single', unittest_capi_inference_single, env: testenv, timeout: 100)
 
-unittest_common_dep = declare_dependency(
-  link_with: [unittest_util_static],
-  dependencies: [nns_capi_dep, gtest_dep],
-  compile_args: ['-DFAKEDLOG=1'],
-  include_directories: nns_capi_include,
-)
-
 unittest_capi_inference = executable('unittest_capi_inference',
   'unittest_capi_inference.cc',
   dependencies: [unittest_common_dep],
index a200703..670c19b 100644 (file)
@@ -7,48 +7,55 @@ testenv = environment()
 testenv.set('MLAPI_SOURCE_ROOT_PATH', meson.source_root())
 testenv.set('MLAPI_BUILD_ROOT_PATH', meson.build_root())
 
-gtest_dep = dependency('gtest', required: false)
-if gtest_dep.found()
-  if get_option('enable-ml-service')
-    gdbus_gen_test_src = custom_target('gdbus-gencode-test',
-      input: test_dbus_input,
-      output: ['test-dbus.h', 'test-dbus.c'],
-      command: [gdbus_prog, '--interface-prefix', 'org.tizen',
-                '--generate-c-code', 'test-dbus',
-                '--output-directory', meson.current_build_dir(),
-                '@INPUT@'])
-
-    gdbus_gen_header_test_dep = declare_dependency(sources: gdbus_gen_test_src,
-      dependencies: gdbus_gen_header_dep)
-
-    nns_ml_agent_common_objs = nns_ml_agent_executable.extract_objects(nns_ml_agent_common_srcs)
-    executable('machine-learning-agent-test',
-      [nns_ml_agent_service_db_srcs, files('daemon/test-dbus-impl.c')],
-      dependencies: [ai_service_daemon_deps, gdbus_gen_header_test_dep],
-      include_directories: nns_ml_agent_incs,
-      objects: [nns_ml_agent_common_objs],
-      cpp_args: [daemon_cpp_db_key_prefix_arg, '-DDB_PATH="."']
-    )
-
-    test_db_config_args = declare_dependency(
-      compile_args: ['-DDB_PATH="."', daemon_cpp_db_key_prefix_arg])
-
-    service_db_dep_for_test = declare_dependency(
-      sources: files('../daemon/service-db.cc'),
-      dependencies: [glib_dep, sqlite_dep, test_db_config_args],
-      include_directories: nns_ml_agent_incs
-    )
-  endif
-
-  subdir('capi')
-  if get_option('enable-ml-service')
-    subdir('services')
-    subdir('daemon')
-  endif
-else
-  warning('You should install google-test on your machine.')
+unittest_util_static = static_library('unittest_util',
+  files('capi/unittest_util.c'),
+  dependencies: [glib_dep],
+  install: false,
+)
+
+unittest_common_dep = declare_dependency(
+  link_with: [unittest_util_static],
+  dependencies: [nns_capi_dep, gtest_dep],
+  compile_args: ['-DFAKEDLOG=1'],
+  include_directories: nns_capi_include,
+)
+
+if get_option('enable-ml-service')
+  gdbus_gen_test_src = custom_target('gdbus-gencode-test',
+    input: test_dbus_input,
+    output: ['test-dbus.h', 'test-dbus.c'],
+    command: [gdbus_prog, '--interface-prefix', 'org.tizen',
+              '--generate-c-code', 'test-dbus',
+              '--output-directory', meson.current_build_dir(),
+              '@INPUT@'])
+
+  gdbus_gen_header_test_dep = declare_dependency(sources: gdbus_gen_test_src,
+    dependencies: gdbus_gen_header_dep)
+
+  nns_ml_agent_common_objs = nns_ml_agent_executable.extract_objects(nns_ml_agent_common_srcs)
+  executable('machine-learning-agent-test',
+    [nns_ml_agent_service_db_srcs, files('daemon/test-dbus-impl.c')],
+    dependencies: [ai_service_daemon_deps, gdbus_gen_header_test_dep],
+    include_directories: nns_ml_agent_incs,
+    objects: [nns_ml_agent_common_objs],
+    cpp_args: [daemon_cpp_db_key_prefix_arg, '-DDB_PATH="."']
+  )
+
+  test_db_config_args = declare_dependency(
+    compile_args: ['-DDB_PATH="."', daemon_cpp_db_key_prefix_arg])
+
+  service_db_dep_for_test = declare_dependency(
+    sources: files('../daemon/service-db.cc'),
+    dependencies: [glib_dep, sqlite_dep, test_db_config_args],
+    include_directories: nns_ml_agent_incs
+  )
+
+  subdir('services')
+  subdir('daemon')
 endif
 
+subdir('capi')
+
 if get_option('install-test')
   install_subdir('test_models', install_dir: unittest_install_dir)
 endif