Skip to content

Commit

Permalink
[GCOV] Fix test failure of ml-agent test on RPI
Browse files Browse the repository at this point in the history
 - Let's use system bus when we run installed tests on the tizen device.
 - If gcov is activated, pass the tests from gbs.

Signed-off-by: gichan2-jang <[email protected]>
  • Loading branch information
gichan-jang authored and myungjoo committed Aug 31, 2023
1 parent 9e65380 commit 8d080c8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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'])

Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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')
9 changes: 8 additions & 1 deletion packaging/machine-learning-api.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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} .
Expand Down Expand Up @@ -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}
Expand All @@ -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
Expand Down
12 changes: 9 additions & 3 deletions tests/capi/unittest_capi_service_agent_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class MLServiceAgentTest : public ::testing::Test
{
protected:
GTestDBus *dbus;
GBusType bus_type;

public:
/**
Expand All @@ -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
}

/**
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 8d080c8

Please sign in to comment.