[glib/glib-2-62: 2/3] gmodule: write test for shared libraries



commit e9ba9bf80fb31b02928efe76464159822c8f03d5
Author: Tom Schoonjans <Tom Schoonjans diamond ac uk>
Date:   Fri Sep 6 19:03:31 2019 +0100

    gmodule: write test for shared libraries

 tests/meson.build   | 28 +++++++++++++++++++++++++---
 tests/module-test.c |  4 ++--
 2 files changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/tests/meson.build b/tests/meson.build
index ce3044258..e4ea22692 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -44,9 +44,17 @@ tests = {
   'type-test' : {},
   'unicode-caseconv' : {},
   'unicode-encoding' : {},
-  'module-test' : {
+  'module-test-library' : {
     'dependencies' : [libgmodule_dep],
     'export_dynamic' : true,
+    'source': 'module-test.c',
+    'c_args': ['-DMODULE_TYPE="library"'],
+  },
+  'module-test-plugin' : {
+    'dependencies' : [libgmodule_dep],
+    'export_dynamic' : true,
+    'source': 'module-test.c',
+    'c_args': ['-DMODULE_TYPE="plugin"'],
   },
   'cxx-test' : {
     'source' : 'cxx-test.cpp',
@@ -87,11 +95,25 @@ if installed_tests_enabled
   )
 endif
 
+module_suffix = []
+# Keep the autotools convention for shared module suffix because GModule
+# depends on it: https://gitlab.gnome.org/GNOME/glib/issues/520
+if ['darwin', 'ios'].contains(host_machine.system())
+  module_suffix = 'so'
+endif
+
 foreach module : ['moduletestplugin_a', 'moduletestplugin_b']
-  shared_module(module, 'lib@0@.c'.format(module),
+  shared_module(module + '_plugin', 'lib@0@.c'.format(module),
+    dependencies : [libglib_dep, libgmodule_dep],
+    install_dir : installed_tests_execdir,
+    install : installed_tests_enabled,
+    name_suffix : module_suffix
+  )
+  shared_library(module + '_library', 'lib@0@.c'.format(module),
     dependencies : [libglib_dep, libgmodule_dep],
     install_dir : installed_tests_execdir,
-    install : installed_tests_enabled
+    install : installed_tests_enabled,
+    name_suffix : module_suffix
   )
 endforeach
 
diff --git a/tests/module-test.c b/tests/module-test.c
index 8047b74ec..e0e6423f6 100644
--- a/tests/module-test.c
+++ b/tests/module-test.c
@@ -90,8 +90,8 @@ main (int    argc,
   if (!g_module_supported ())
     g_error ("dynamic modules not supported");
 
-  plugin_a = g_test_build_filename (G_TEST_BUILT, MODULE_FILENAME_PREFIX "moduletestplugin_a", NULL);
-  plugin_b = g_test_build_filename (G_TEST_BUILT, MODULE_FILENAME_PREFIX "moduletestplugin_b", NULL);
+  plugin_a = g_test_build_filename (G_TEST_BUILT, MODULE_FILENAME_PREFIX "moduletestplugin_a_" MODULE_TYPE, 
NULL);
+  plugin_b = g_test_build_filename (G_TEST_BUILT, MODULE_FILENAME_PREFIX "moduletestplugin_b_" MODULE_TYPE, 
NULL);
 
   /* module handles */
   


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