[calls] Move plugin specific tests into dedicated directory



commit 11ba83c16e827984ab1b14f29bd23ccd6e008ee2
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Mon Jul 18 22:30:19 2022 +0200

    Move plugin specific tests into dedicated directory
    
    This will prove beneficial when we also add tests for the policy engine
    plugins. The increased locality is also nice to have.

 meson.build                                        |   2 +-
 plugins/meson.build                                |   2 +
 plugins/provider/dummy/meson.build                 |   2 +-
 plugins/provider/mm/meson.build                    |   2 +-
 plugins/provider/ofono/meson.build                 |   2 +-
 plugins/provider/sip/meson.build                   |   2 +-
 {tests => plugins/provider/tests}/common.h         |   0
 plugins/provider/tests/meson.build                 | 147 +++++++++++++++++++++
 {tests => plugins/provider/tests}/setup-call.c     |   0
 {tests => plugins/provider/tests}/setup-call.h     |   0
 {tests => plugins/provider/tests}/setup-origin.c   |   0
 {tests => plugins/provider/tests}/setup-origin.h   |   0
 {tests => plugins/provider/tests}/setup-provider.c |   0
 {tests => plugins/provider/tests}/setup-provider.h |   0
 {tests => plugins/provider/tests}/test-call.c      |   0
 {tests => plugins/provider/tests}/test-media.c     |   0
 {tests => plugins/provider/tests}/test-origin.c    |   0
 {tests => plugins/provider/tests}/test-provider.c  |   0
 .../provider/tests}/test-sdp-crypto.c              |   0
 {tests => plugins/provider/tests}/test-sip.c       |   0
 {tests => plugins/provider/tests}/test-srtp.c      |   0
 src/calls-manager.c                                |  13 +-
 tests/meson.build                                  |  98 --------------
 23 files changed, 163 insertions(+), 107 deletions(-)
---
diff --git a/meson.build b/meson.build
index e6845d9e..a978d7d7 100644
--- a/meson.build
+++ b/meson.build
@@ -132,9 +132,9 @@ add_project_arguments(
 
 subdir('po')
 subdir('src')
+subdir('tests')
 subdir('plugins')
 subdir('doc')
 subdir('data')
-subdir('tests')
 
 meson.add_install_script('build-aux/meson/postinstall.py')
diff --git a/plugins/meson.build b/plugins/meson.build
index 214ad1fe..bb89607c 100644
--- a/plugins/meson.build
+++ b/plugins/meson.build
@@ -1,4 +1,6 @@
+calls_provider_plugin_libdir = join_paths(full_calls_plugin_libdir, 'providers')
 subdir('provider/mm')
 subdir('provider/dummy')
 subdir('provider/ofono')
 subdir('provider/sip')
+subdir('provider/tests')
diff --git a/plugins/provider/dummy/meson.build b/plugins/provider/dummy/meson.build
index 10c44823..5ff94fdb 100644
--- a/plugins/provider/dummy/meson.build
+++ b/plugins/provider/dummy/meson.build
@@ -23,7 +23,7 @@
 
 dummy_include = include_directories('.')
 
-dummy_install_dir = join_paths(full_calls_plugin_libdir, 'dummy')
+dummy_install_dir = join_paths(calls_provider_plugin_libdir, 'dummy')
 
 dummy_plugin = configure_file(
   input: 'dummy.plugin.in',
diff --git a/plugins/provider/mm/meson.build b/plugins/provider/mm/meson.build
index 843dbce0..193e2638 100644
--- a/plugins/provider/mm/meson.build
+++ b/plugins/provider/mm/meson.build
@@ -21,7 +21,7 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 #
 
-mm_install_dir = join_paths(full_calls_plugin_libdir, 'mm')
+mm_install_dir = join_paths(calls_provider_plugin_libdir, 'mm')
 
 mm_plugin = configure_file(
   input: 'mm.plugin.in',
diff --git a/plugins/provider/ofono/meson.build b/plugins/provider/ofono/meson.build
index 2a85ba36..337b3aac 100644
--- a/plugins/provider/ofono/meson.build
+++ b/plugins/provider/ofono/meson.build
@@ -23,7 +23,7 @@
 
 subdir('libgdbofono')
 
-ofono_install_dir = join_paths(full_calls_plugin_libdir, 'ofono')
+ofono_install_dir = join_paths(calls_provider_plugin_libdir, 'ofono')
 
 ofono_plugin = configure_file(
   input: 'ofono.plugin.in',
diff --git a/plugins/provider/sip/meson.build b/plugins/provider/sip/meson.build
index 65959c9a..ca24ae75 100644
--- a/plugins/provider/sip/meson.build
+++ b/plugins/provider/sip/meson.build
@@ -23,7 +23,7 @@
 
 sip_include = include_directories('.')
 
-sip_install_dir = join_paths(full_calls_plugin_libdir, 'sip')
+sip_install_dir = join_paths(calls_provider_plugin_libdir, 'sip')
 
 sip_plugin = configure_file(
   input: 'sip.plugin.in',
diff --git a/tests/common.h b/plugins/provider/tests/common.h
similarity index 100%
rename from tests/common.h
rename to plugins/provider/tests/common.h
diff --git a/plugins/provider/tests/meson.build b/plugins/provider/tests/meson.build
new file mode 100644
index 00000000..7a61397a
--- /dev/null
+++ b/plugins/provider/tests/meson.build
@@ -0,0 +1,147 @@
+#
+# Copyright (C) 2022 Purism SPC
+#
+# This file is part of Calls.
+#
+# Calls is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Calls is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Calls.  If not, see <http://www.gnu.org/licenses/>.
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+
+
+if get_option('tests')
+
+test_env = [
+  'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
+  'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+  'G_DEBUG=gc-friendly,fatal-warnings',
+  'GSETTINGS_BACKEND=memory',
+  'PYTHONDONTWRITEBYTECODE=yes',
+  'MALLOC_CHECK_=2',
+  'NO_AT_BRIDGE=1',
+  'CALLS_SIP_TEST=1',
+  'CALLS_AUDIOSRC=audiotestsrc',
+  'CALLS_AUDIOSINK=fakesink',
+  'GSETTINGS_SCHEMA_DIR=@0@/data'.format(meson.project_build_root()),
+]
+
+test_cflags = [
+  '-DFOR_TESTING',
+  '-Wno-error=deprecated-declarations',
+  '-DPLUGIN_BUILDDIR="@0@"'.format(full_calls_plugin_builddir),
+]
+
+test_link_args = [
+  '-fPIC',
+]
+
+tests = [
+  [ 'provider', []                       ],
+  [ 'origin',   [ 'provider' ]           ],
+  [ 'call',     [ 'provider', 'origin' ] ],
+]
+
+foreach test : tests
+  name = test[0]
+
+  setup_bases = test[1]
+  setup_bases += name
+
+  test_sources = []
+  foreach base : setup_bases
+    test_sources += [ 'setup-' + base + '.c',
+                      'setup-' + base + '.h' ]
+  endforeach
+  test_sources += [ 'test-' + name + '.c',
+                    'common.h' ]
+
+  t = executable(name, test_sources,
+                 dummy_sources,
+                 c_args : test_cflags,
+                 link_args: test_link_args,
+                 pie: true,
+                 link_with : [calls_vala, libcalls],
+                 dependencies: calls_deps,
+                 include_directories : [
+                   calls_includes,
+                   dummy_include,
+                 ]
+                )
+  test(name, t, env: test_env)
+endforeach
+
+
+
+test_sources = [ 'test-media.c' ]
+test_sources += sip_sources
+t = executable('media', test_sources,
+               c_args : test_cflags,
+               link_args: test_link_args,
+               pie: true,
+               link_with : [calls_vala, libcalls],
+               dependencies: [calls_deps, sip_deps],
+               include_directories : [
+                   calls_includes,
+                   sip_include,
+                 ]
+               )
+test('media', t, env: test_env)
+
+test_sources = [ 'test-sip.c' ]
+test_sources += sip_sources
+t = executable('sip', test_sources,
+               c_args : test_cflags,
+               link_args: test_link_args,
+               pie: true,
+               link_with : [calls_vala, libcalls],
+               dependencies: [calls_deps, sip_deps],
+               include_directories : [
+                   calls_includes,
+                   sip_include,
+                 ]
+               )
+test('sip', t, env: test_env)
+
+test_sources = [ 'test-srtp.c' ]
+test_sources += sip_sources
+t = executable('srtp', test_sources,
+               c_args : test_cflags,
+               link_args: test_link_args,
+               pie: true,
+               link_with : [calls_vala, libcalls],
+               dependencies: [calls_deps, sip_deps],
+               include_directories : [
+                   calls_includes,
+                   sip_include,
+                 ]
+               )
+test('srtp', t, env: test_env)
+
+test_sources = [ 'test-sdp-crypto.c' ]
+test_sources += sip_sources
+t = executable('sdp-crypto', test_sources,
+               c_args : test_cflags,
+               link_args: test_link_args,
+               pie: true,
+               link_with : [calls_vala, libcalls],
+               dependencies: [calls_deps, sip_deps],
+               include_directories : [
+                   calls_includes,
+                   sip_include,
+                 ]
+               )
+test('sdp-crypto', t, env: test_env)
+
+
+endif
diff --git a/tests/setup-call.c b/plugins/provider/tests/setup-call.c
similarity index 100%
rename from tests/setup-call.c
rename to plugins/provider/tests/setup-call.c
diff --git a/tests/setup-call.h b/plugins/provider/tests/setup-call.h
similarity index 100%
rename from tests/setup-call.h
rename to plugins/provider/tests/setup-call.h
diff --git a/tests/setup-origin.c b/plugins/provider/tests/setup-origin.c
similarity index 100%
rename from tests/setup-origin.c
rename to plugins/provider/tests/setup-origin.c
diff --git a/tests/setup-origin.h b/plugins/provider/tests/setup-origin.h
similarity index 100%
rename from tests/setup-origin.h
rename to plugins/provider/tests/setup-origin.h
diff --git a/tests/setup-provider.c b/plugins/provider/tests/setup-provider.c
similarity index 100%
rename from tests/setup-provider.c
rename to plugins/provider/tests/setup-provider.c
diff --git a/tests/setup-provider.h b/plugins/provider/tests/setup-provider.h
similarity index 100%
rename from tests/setup-provider.h
rename to plugins/provider/tests/setup-provider.h
diff --git a/tests/test-call.c b/plugins/provider/tests/test-call.c
similarity index 100%
rename from tests/test-call.c
rename to plugins/provider/tests/test-call.c
diff --git a/tests/test-media.c b/plugins/provider/tests/test-media.c
similarity index 100%
rename from tests/test-media.c
rename to plugins/provider/tests/test-media.c
diff --git a/tests/test-origin.c b/plugins/provider/tests/test-origin.c
similarity index 100%
rename from tests/test-origin.c
rename to plugins/provider/tests/test-origin.c
diff --git a/tests/test-provider.c b/plugins/provider/tests/test-provider.c
similarity index 100%
rename from tests/test-provider.c
rename to plugins/provider/tests/test-provider.c
diff --git a/tests/test-sdp-crypto.c b/plugins/provider/tests/test-sdp-crypto.c
similarity index 100%
rename from tests/test-sdp-crypto.c
rename to plugins/provider/tests/test-sdp-crypto.c
diff --git a/tests/test-sip.c b/plugins/provider/tests/test-sip.c
similarity index 100%
rename from tests/test-sip.c
rename to plugins/provider/tests/test-sip.c
diff --git a/tests/test-srtp.c b/plugins/provider/tests/test-srtp.c
similarity index 100%
rename from tests/test-srtp.c
rename to plugins/provider/tests/test-srtp.c
diff --git a/src/calls-manager.c b/src/calls-manager.c
index 714996ec..a80b349e 100644
--- a/src/calls-manager.c
+++ b/src/calls-manager.c
@@ -742,6 +742,7 @@ calls_manager_init (CallsManager *self)
   GApplication *application;
   PeasEngine *peas;
   const gchar *dir;
+  g_autofree char *default_plugin_dir_provider = NULL;
 
   self->state_flags = CALLS_MANAGER_FLAGS_UNKNOWN;
   self->providers = g_hash_table_new_full (g_str_hash,
@@ -802,15 +803,19 @@ calls_manager_init (CallsManager *self)
 
   dir = g_getenv ("CALLS_PLUGIN_DIR");
   if (dir && dir[0] != '\0') {
+    g_autofree char *plugin_dir_provider = NULL;
     /** Add the directory to the search path. prepend_search_path() does not work
      * as expected. see https://gitlab.gnome.org/GNOME/libpeas/-/issues/19
      */
-    g_debug ("Adding %s to plugin search path", dir);
-    peas_engine_add_search_path (peas, dir, NULL);
+
+    plugin_dir_provider = g_build_filename (dir, "provider", NULL);
+    g_debug ("Adding %s to plugin search path", plugin_dir_provider);
+    peas_engine_add_search_path (peas, plugin_dir_provider, NULL);
   }
 
-  peas_engine_add_search_path (peas, PLUGIN_LIBDIR, NULL);
-  g_debug ("Scanning for plugins in `%s'", PLUGIN_LIBDIR);
+  default_plugin_dir_provider = g_build_filename(PLUGIN_LIBDIR, "provider", NULL);
+  peas_engine_add_search_path (peas, default_plugin_dir_provider, NULL);
+  g_debug ("Scanning for plugins in `%s'", default_plugin_dir_provider);
 }
 
 
diff --git a/tests/meson.build b/tests/meson.build
index fa45543d..26ece5c4 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -8,9 +8,6 @@ test_env = [
   'PYTHONDONTWRITEBYTECODE=yes',
   'MALLOC_CHECK_=2',
   'NO_AT_BRIDGE=1',
-  'CALLS_SIP_TEST=1',
-  'CALLS_AUDIOSRC=audiotestsrc',
-  'CALLS_AUDIOSINK=fakesink',
   'GSETTINGS_SCHEMA_DIR=@0@/data'.format(meson.project_build_root()),
 ]
 
@@ -29,41 +26,6 @@ mock_link_args = [ test_link_args,
                  ]
 
 
-tests = [
-  [ 'provider', []                       ],
-  [ 'origin',   [ 'provider' ]           ],
-  [ 'call',     [ 'provider', 'origin' ] ],
-]
-
-foreach test : tests
-  name = test[0]
-
-  setup_bases = test[1]
-  setup_bases += name
-
-  test_sources = []
-  foreach base : setup_bases
-    test_sources += [ 'setup-' + base + '.c',
-                      'setup-' + base + '.h' ]
-  endforeach
-  test_sources += [ 'test-' + name + '.c',
-                    'common.h' ]
-
-  t = executable(name, test_sources,
-                 dummy_sources,
-                 c_args : test_cflags,
-                 link_args: test_link_args,
-                 pie: true,
-                 link_with : [calls_vala, libcalls],
-                 dependencies: calls_deps,
-                 include_directories : [
-                   calls_includes,
-                   dummy_include,
-                 ]
-                )
-  test(name, t, env: test_env)
-endforeach
-
 test_sources = [ 'test-manager.c' ]
 
 t = executable('manager', test_sources,
@@ -93,66 +55,6 @@ t = executable('plugins', test_sources,
                 )
 test('plugins', t, env: test_env)
 
-test_sources = [ 'test-media.c' ]
-test_sources += sip_sources
-t = executable('media', test_sources,
-               c_args : test_cflags,
-               link_args: test_link_args,
-               pie: true,
-               link_with : [calls_vala, libcalls],
-               dependencies: [calls_deps, sip_deps],
-               include_directories : [
-                   calls_includes,
-                   sip_include,
-                 ]
-               )
-test('media', t, env: test_env)
-
-test_sources = [ 'test-sip.c' ]
-test_sources += sip_sources
-t = executable('sip', test_sources,
-               c_args : test_cflags,
-               link_args: test_link_args,
-               pie: true,
-               link_with : [calls_vala, libcalls],
-               dependencies: [calls_deps, sip_deps],
-               include_directories : [
-                   calls_includes,
-                   sip_include,
-                 ]
-               )
-test('sip', t, env: test_env)
-
-test_sources = [ 'test-srtp.c' ]
-test_sources += sip_sources
-t = executable('srtp', test_sources,
-               c_args : test_cflags,
-               link_args: test_link_args,
-               pie: true,
-               link_with : [calls_vala, libcalls],
-               dependencies: [calls_deps, sip_deps],
-               include_directories : [
-                   calls_includes,
-                   sip_include,
-                 ]
-               )
-test('srtp', t, env: test_env)
-
-test_sources = [ 'test-sdp-crypto.c' ]
-test_sources += sip_sources
-t = executable('sdp-crypto', test_sources,
-               c_args : test_cflags,
-               link_args: test_link_args,
-               pie: true,
-               link_with : [calls_vala, libcalls],
-               dependencies: [calls_deps, sip_deps],
-               include_directories : [
-                   calls_includes,
-                   sip_include,
-                 ]
-               )
-test('sdp-crypto', t, env: test_env)
-
 test_sources = [ 'test-util.c' ]
 t = executable('util', test_sources,
                c_args : test_cflags,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]