diff --git a/meson.build b/meson.build index cb1b2313..7362bb66 100644 --- a/meson.build +++ b/meson.build @@ -105,6 +105,10 @@ if get_option('enable-tizen') endif endif +if get_option('enable-gcov') + add_project_arguments('-DENABLE_GCOV=1', language: ['c', 'cpp']) +endif + serviceDBPath = get_option('service-db-path') add_project_arguments('-DSYS_DB_DIR="' + serviceDBPath + '"', language: ['c', 'cpp']) diff --git a/meson_options.txt b/meson_options.txt index 9f134b9b..49b2901b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -9,3 +9,4 @@ option('enable-ml-service', type: 'boolean', value: false) option('java-home', type: 'string', value: '') option('service-db-path', type: 'string', value: '.') option('service-db-key-prefix', type: 'string', value: '') +option('enable-gcov', type: 'boolean', value: false, description: 'Generate gcov package') diff --git a/packaging/machine-learning-api.spec b/packaging/machine-learning-api.spec index 87cce50a..1174693f 100644 --- a/packaging/machine-learning-api.spec +++ b/packaging/machine-learning-api.spec @@ -308,6 +308,7 @@ HTML pages of lcov results of ML API generated during rpm build %define enable_ml_service_check -Denable-ml-service=false %define service_db_path "" %define service_db_key_prefix %{nil} +%define enable_gcov -Denable-gcov=false # To set prefix, use this line ### define service_db_key_prefix -Dservice-db-key-prefix='some-prefix' @@ -329,6 +330,10 @@ HTML pages of lcov results of ML API generated during rpm build %endif %endif # tizen +%if 0%{?gcov} +%define enable_gcov -Denable-gcov=true +%endif + %prep %setup -q cp %{SOURCE1001} . @@ -375,6 +380,7 @@ meson --buildtype=plain --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} --libdir %{enable_test} %{install_test} %{enable_test_coverage} \ %{enable_tizen} %{enable_tizen_privilege_check} %{enable_tizen_feature_check} \ %{service_db_path} %{service_db_key_prefix} %{enable_ml_service_check} \ + %{enable_gcov} \ build ninja -C build %{?_smp_mflags} @@ -383,7 +389,8 @@ export MLAPI_SOURCE_ROOT_PATH=$(pwd) export MLAPI_BUILD_ROOT_PATH=$(pwd)/%{builddir} # Run test -%if 0%{?unit_test} +# If gcov package generation is enabled, pass the test from GBS. +%if 0%{?unit_test} && !0%{?gcov} bash %{test_script} ./tests/capi/unittest_capi_inference_single bash %{test_script} ./tests/capi/unittest_capi_inference bash %{test_script} ./tests/capi/unittest_capi_datatype_consistency diff --git a/tests/capi/unittest_capi_service_agent_client.cc b/tests/capi/unittest_capi_service_agent_client.cc index 86d3f495..b1e0865d 100644 --- a/tests/capi/unittest_capi_service_agent_client.cc +++ b/tests/capi/unittest_capi_service_agent_client.cc @@ -27,6 +27,7 @@ class MLServiceAgentTest : public ::testing::Test { protected: GTestDBus *dbus; + GBusType bus_type; public: /** @@ -44,6 +45,11 @@ class MLServiceAgentTest : public ::testing::Test g_free (services_dir); g_test_dbus_up (dbus); +#if defined(ENABLE_GCOV) + bus_type = G_BUS_TYPE_SYSTEM; +#else + bus_type = G_BUS_TYPE_SESSION; +#endif } /** @@ -1283,7 +1289,7 @@ TEST_F (MLServiceAgentTest, pipeline_gdbus_call_n) GError *error = NULL; MachinelearningServicePipeline *proxy_for_pipeline - = machinelearning_service_pipeline_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, + = machinelearning_service_pipeline_proxy_new_for_bus_sync (bus_type, G_DBUS_PROXY_FLAGS_NONE, DBUS_ML_BUS_NAME, DBUS_PIPELINE_PATH, NULL, &error); if (!proxy_for_pipeline || error) { @@ -1310,7 +1316,7 @@ TEST_F (MLServiceAgentTest, model_gdbus_call_n) GError *error = NULL; MachinelearningServiceModel *proxy_for_model - = machinelearning_service_model_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, + = machinelearning_service_model_proxy_new_for_bus_sync (bus_type, G_DBUS_PROXY_FLAGS_NONE, DBUS_ML_BUS_NAME, DBUS_MODEL_PATH, NULL, &error); if (!proxy_for_model || error) { @@ -1345,7 +1351,7 @@ TEST_F (MLServiceAgentTest, resource_gdbus_call_n) GError *error = NULL; MachinelearningServiceResource *proxy_for_resource - = machinelearning_service_resource_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, + = machinelearning_service_resource_proxy_new_for_bus_sync (bus_type, G_DBUS_PROXY_FLAGS_NONE, DBUS_ML_BUS_NAME, DBUS_RESOURCE_PATH, NULL, &error); if (!proxy_for_resource || error) {