[glib: 1/2] Enable GIO tests on Windows



commit ad3694b82a9e8ce5f3ce6ac050f441b5ede1af4d
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date:   Sun Sep 9 12:46:33 2018 +0000

    Enable GIO tests on Windows
    
    1) Remove the non-Windows-only condition for subdir('tests').
    2) Add libiphlpapi, libws2_32 and libsecur32 deps, needed for W32 tests.
    3) Remove the -no-undefined argument (gcc doesn't understand it,
       it *does* understand -Wl,-no-undefined; either way, the test
       compiles without this argument just fine; maybe meson adds it
       by itself - you can hardly build shared modules without it).
    4) Add or fix a number of includes
    5) Disable gdbus-objectmanager tests when building with MSVC
       (right now these tests don't work on Windows anyway, so the fact
        that MSVC can't even build them properly is irrelevant;
        most likely gdbus-codegen needs changes to put _GLIB_EXTERN
        before each function)

 gio/meson.build                   |  5 +----
 gio/tests/g-file-info.c           |  5 +++--
 gio/tests/gdbus-serialization.c   |  2 ++
 gio/tests/gdbus-tests.c           |  2 ++
 gio/tests/meson.build             | 44 +++++++++++++++++++++------------------
 gio/tests/modules/test-module-a.c |  2 ++
 gio/tests/modules/test-module-b.c |  2 ++
 gio/tests/readwrite.c             |  3 +++
 8 files changed, 39 insertions(+), 26 deletions(-)
---
diff --git a/gio/meson.build b/gio/meson.build
index b83d8f5f3..04581b1cc 100644
--- a/gio/meson.build
+++ b/gio/meson.build
@@ -979,7 +979,4 @@ if enable_systemtap
 endif
 
 subdir('fam')
-
-if host_system != 'windows'
-  subdir('tests')
-endif
+subdir('tests')
diff --git a/gio/tests/g-file-info.c b/gio/tests/g-file-info.c
index 112502606..28a2426a8 100644
--- a/gio/tests/g-file-info.c
+++ b/gio/tests/g-file-info.c
@@ -29,8 +29,9 @@
 #ifdef G_OS_WIN32
 #include <stdio.h>
 #include <glib/gstdio.h>
-#include <Windows.h>
-#include <Shlobj.h>
+#include <windows.h>
+#include <shlobj.h>
+#include <io.h> /* for _get_osfhandle */
 #endif
 
 #define TEST_NAME                      "Prilis zlutoucky kun"
diff --git a/gio/tests/gdbus-serialization.c b/gio/tests/gdbus-serialization.c
index d2f0a6ce7..2ab856c48 100644
--- a/gio/tests/gdbus-serialization.c
+++ b/gio/tests/gdbus-serialization.c
@@ -22,7 +22,9 @@
 #include <gio/gio.h>
 
 #include <string.h>
+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
 #include <dbus/dbus.h>
 
 /* ---------------------------------------------------------------------------------------------------- */
diff --git a/gio/tests/gdbus-tests.c b/gio/tests/gdbus-tests.c
index 0655f1be4..35e379bd2 100644
--- a/gio/tests/gdbus-tests.c
+++ b/gio/tests/gdbus-tests.c
@@ -19,7 +19,9 @@
  */
 
 #include <gio/gio.h>
+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
 
 #include "gdbus-tests.h"
 
diff --git a/gio/tests/meson.build b/gio/tests/meson.build
index 2b9eada24..e16f53466 100644
--- a/gio/tests/meson.build
+++ b/gio/tests/meson.build
@@ -5,6 +5,10 @@ common_gio_tests_deps = [
   libgio_dep,
 ]
 
+if host_machine.system() == 'windows'
+  common_gio_tests_deps += [iphlpapi_dep, winsock2, cc.find_library ('secur32')]
+endif
+
 subdir('gdbus-object-manager-example')
 
 gengiotypefuncs_prog = find_program('gengiotypefuncs.py')
@@ -321,22 +325,27 @@ test_extra_programs += [{
     'extra_sources' : ['gtlsconsoleinteraction.c'],
     'install' : false,
   },
-  # These three are manual-run tests because they need a session bus but don't bring one up themselves
-  # FIXME: these build but don't seem to work!
-  'gdbus-example-objectmanager-client' : {
-    'dependencies' : [libgdbus_example_objectmanager_dep],
-    'install' : false,
-  },
-  'gdbus-example-objectmanager-server' : {
-    'dependencies' : [libgdbus_example_objectmanager_dep],
-    'install' : false,
-  },
-  'gdbus-test-fixture' : {
-    'dependencies' : [libgdbus_example_objectmanager_dep],
-    'install' : false,
-  },
 }]
 
+if cc.get_id() != 'msvc'
+  test_extra_programs += [{
+    # These three are manual-run tests because they need a session bus but don't bring one up themselves
+    # FIXME: these build but don't seem to work!
+    'gdbus-example-objectmanager-client' : {
+      'dependencies' : [libgdbus_example_objectmanager_dep],
+      'install' : false,
+    },
+    'gdbus-example-objectmanager-server' : {
+      'dependencies' : [libgdbus_example_objectmanager_dep],
+      'install' : false,
+    },
+    'gdbus-test-fixture' : {
+      'dependencies' : [libgdbus_example_objectmanager_dep],
+      'install' : false,
+    },
+  }]
+endif
+
 if host_machine.system() != 'windows'
   test_extra_programs += [{
     'gdbus-example-unix-fd-client' : {
@@ -357,13 +366,8 @@ if not meson.is_cross_build() or meson.has_exe_wrapper()
                '--c-name', '_g_plugin',
                '@INPUT@'])
 
-  if host_system == 'windows'
-    resource_plugin_platform_link_args = ['-no-undefined']
-  else
-    resource_plugin_platform_link_args = []
-  endif
   shared_module ('resourceplugin', 'resourceplugin.c', plugin_resources_c,
-    link_args : export_dynamic_ldflags + resource_plugin_platform_link_args,
+    link_args : export_dynamic_ldflags,
     dependencies : common_gio_tests_deps)
 
   test_gresource = custom_target('test.gresource',
diff --git a/gio/tests/modules/test-module-a.c b/gio/tests/modules/test-module-a.c
index 6ac065d8a..0a64ea60a 100644
--- a/gio/tests/modules/test-module-a.c
+++ b/gio/tests/modules/test-module-a.c
@@ -20,6 +20,8 @@
  * if advised of the possibility of such damage.
  */
 
+#include "config.h" /* for _GLIB_EXTERN */
+
 #include <gio/gio.h>
 
 #include "symbol-visibility.h"
diff --git a/gio/tests/modules/test-module-b.c b/gio/tests/modules/test-module-b.c
index 21932287f..8d3527e43 100644
--- a/gio/tests/modules/test-module-b.c
+++ b/gio/tests/modules/test-module-b.c
@@ -20,6 +20,8 @@
  * if advised of the possibility of such damage.
  */
 
+#include "config.h" /* for _GLIB_EXTERN */
+
 #include <gio/gio.h>
 
 #include "symbol-visibility.h"
diff --git a/gio/tests/readwrite.c b/gio/tests/readwrite.c
index 9f674c39d..2aa925b30 100644
--- a/gio/tests/readwrite.c
+++ b/gio/tests/readwrite.c
@@ -6,6 +6,9 @@
 #ifdef G_OS_UNIX
 #include <unistd.h>
 #endif
+#ifdef G_OS_WIN32
+#include <io.h> /* for close() */
+#endif
 
 static const char *original_data = "This is some test data that we can put in a file...";
 static const char *new_data = "new data..";


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