From 96fafcfe92d4c6936c5f328864eea51cdeea1df7 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 19 Sep 2018 11:53:07 -0400 Subject: [PATCH 01/10] Meson: Fix missing files when installing tests Closes #1527 --- .../gdbus-object-manager-example/meson.build | 5 ++- gio/tests/meson.build | 37 ++++++++++++++++--- gio/tests/modules/meson.build | 14 ++++--- glib/tests/meson.build | 15 ++++++++ 4 files changed, 57 insertions(+), 14 deletions(-) diff --git a/gio/tests/gdbus-object-manager-example/meson.build b/gio/tests/gdbus-object-manager-example/meson.build index 90dcc1f93..6b27576e8 100644 --- a/gio/tests/gdbus-object-manager-example/meson.build +++ b/gio/tests/gdbus-object-manager-example/meson.build @@ -14,11 +14,12 @@ gdbus_example_objectmanager_generated = custom_target('gdbus-example-objectmanag '--generate-docbook', 'gdbus-example-objectmanager-generated', '@INPUT@']) -libgdbus_example_objectmanager = library('libgdbus-example-objectmanager', +libgdbus_example_objectmanager = library('gdbus-example-objectmanager', gdbus_example_objectmanager_generated, c_args : gio_c_args, dependencies : [libglib_dep, libgmodule_dep, libgobject_dep, libgio_dep], - install : false) + install : installed_tests_enabled, + install_dir : installed_tests_execdir) libgdbus_example_objectmanager_dep = declare_dependency(sources : gdbus_example_objectmanager_generated, link_with : libgdbus_example_objectmanager) diff --git a/gio/tests/meson.build b/gio/tests/meson.build index 99065040e..913da26a0 100644 --- a/gio/tests/meson.build +++ b/gio/tests/meson.build @@ -80,6 +80,7 @@ gio_tests = [{ test_extra_programs = [{ 'gdbus-connection-flush-helper' : {}, 'gdbus-testserver' : {}, + 'gsubprocess-testprog' : {}, }] test_env = environment() @@ -254,9 +255,10 @@ if host_machine.system() != 'windows' # This test is currently unreliable executable('gdbus-overflow', 'gdbus-overflow.c', - install : false, c_args : test_c_args, - dependencies : common_gio_tests_deps) + dependencies : common_gio_tests_deps, + install_dir : installed_tests_execdir, + install : installed_tests_enabled) gio_tests += [{ 'gdbus-connection-flush' : { @@ -318,7 +320,6 @@ test_extra_programs += [{ 'gdbus-example-subtree' : {'install' : false}, 'gdbus-example-watch-name' : {'install' : false}, 'gdbus-example-watch-proxy' : {'install' : false}, - 'gsubprocess-testprog' : {'install' : false}, 'httpd' : {'install' : false}, 'proxy' : {'install' : false}, 'resolver' : {'install' : false}, @@ -357,6 +358,25 @@ if host_machine.system() != 'windows' }] endif +if installed_tests_enabled + install_data( + 'contexts.c', + 'g-icon.c', + 'appinfo-test-actions.desktop', + 'appinfo-test-gnome.desktop', + 'appinfo-test-notgnome.desktop', + 'appinfo-test.desktop', + 'appinfo-test2.desktop', + 'file.c', + 'org.gtk.test.dbusappinfo.desktop', + install_dir : installed_tests_execdir, + ) + install_subdir('x-content', install_dir : installed_tests_execdir) + install_subdir('desktop-files', install_dir : installed_tests_execdir) + install_subdir('thumbnails', install_dir : installed_tests_execdir) + install_subdir('cert-tests', install_dir : installed_tests_execdir) +endif + if not meson.is_cross_build() or meson.has_exe_wrapper() plugin_resources_c = custom_target('plugin-resources.c', @@ -369,9 +389,12 @@ if not meson.is_cross_build() or meson.has_exe_wrapper() '--c-name', '_g_plugin', '@INPUT@']) - shared_module ('resourceplugin', 'resourceplugin.c', plugin_resources_c, + shared_module('resourceplugin', 'resourceplugin.c', plugin_resources_c, link_args : export_dynamic_ldflags, - dependencies : common_gio_tests_deps) + dependencies : common_gio_tests_deps, + install_dir : installed_tests_execdir, + install : installed_tests_enabled + ) test_gresource = custom_target('test.gresource', input : 'test.gresource.xml', @@ -380,7 +403,9 @@ if not meson.is_cross_build() or meson.has_exe_wrapper() '--target=@OUTPUT@', '--sourcedir=' + meson.current_source_dir(), '--sourcedir=' + meson.current_build_dir(), - '@INPUT@']) + '@INPUT@'], + install_dir : installed_tests_execdir, + install : installed_tests_enabled) test_resources2_c = custom_target('test_resources2.c', input : 'test3.gresource.xml', diff --git a/gio/tests/modules/meson.build b/gio/tests/modules/meson.build index 5ae131ae7..fa981c4fa 100644 --- a/gio/tests/modules/meson.build +++ b/gio/tests/modules/meson.build @@ -1,11 +1,13 @@ -libtestmodulea = library('testmodulea', 'test-module-a.c', - install : false, +libtestmodulea = shared_module('testmodulea', 'test-module-a.c', dependencies : [libglib_dep, libgobject_dep, libgmodule_dep, libgio_dep], - c_args : [ ] + c_args : [ ], + install : installed_tests_enabled, + install_dir : join_paths(installed_tests_execdir, 'modules'), ) -libtestmoduleb = library('testmoduleb', 'test-module-b.c', - install : false, +libtestmoduleb = shared_module('testmoduleb', 'test-module-b.c', dependencies : [libglib_dep, libgobject_dep, libgmodule_dep, libgio_dep], - c_args : [ ] + c_args : [ ], + install : installed_tests_enabled, + install_dir : join_paths(installed_tests_execdir, 'modules'), ) diff --git a/glib/tests/meson.build b/glib/tests/meson.build index 0af71b072..e88d3a104 100644 --- a/glib/tests/meson.build +++ b/glib/tests/meson.build @@ -129,6 +129,21 @@ glib_tests = { }, } +if installed_tests_enabled + install_data( + 'keyfiletest.ini', + 'pages.ini', + 'keyfile.c', + 'empty', + '4096-random-bytes', + 'echo-script', + 'echo-script.bat', + install_dir : installed_tests_execdir, + ) + install_subdir('bookmarks', install_dir : installed_tests_execdir) + install_subdir('markups', install_dir : installed_tests_execdir) +endif + # Not entirely random of course, but at least it changes over time random_number = minor_version + meson.version().split('.').get(1).to_int() From 4b5bc3f459b7667bb2201858711805130c0cc8dc Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 19 Sep 2018 16:09:55 -0400 Subject: [PATCH 02/10] Meson: build and install remaining tests --- gthread/meson.build | 2 + tests/gobject/meson.build | 86 ++++++++++++++---------- tests/meson.build | 132 +++++++++++++++++++++++++++++++++++++ tests/refcount/meson.build | 77 +++++++++++++++------- 4 files changed, 240 insertions(+), 57 deletions(-) diff --git a/gthread/meson.build b/gthread/meson.build index 6b0748f15..515479ba1 100644 --- a/gthread/meson.build +++ b/gthread/meson.build @@ -30,3 +30,5 @@ pkg.generate(libraries : [libgthread, thread_dep], name : 'GThread', description : 'Thread support for GLib', ) + +libgthread_dep = declare_dependency(link_with : libgthread) diff --git a/tests/gobject/meson.build b/tests/gobject/meson.build index 494459921..4da5a7a94 100644 --- a/tests/gobject/meson.build +++ b/tests/gobject/meson.build @@ -1,16 +1,3 @@ -gobject_tests = [ - ['gvalue-test'], - ['paramspec-test'], - ['deftype'], - ['defaultiface', ['defaultiface.c', 'testmodule.c']], - ['dynamictype', ['dynamictype.c', 'testmodule.c']], - ['override'], - ['signals'], - ['singleton'], - ['references'], - ['testgobject'], -] - # We cannot use gnome.genmarshal() here testmarshal_h = custom_target('testmarshal_h', output : 'testmarshal.h', @@ -39,41 +26,74 @@ testmarshal_c = custom_target('testmarshal_c', ], ) -gobject_tests += [ - ['accumulator', ['accumulator.c', testmarshal_c, testmarshal_h]], -] +gobject_tests = { + 'gvalue-test' : {}, + 'paramspec-test' : {}, + 'deftype' : {}, + 'defaultiface' : { + 'extra_sources' : ['testmodule.c'], + }, + 'dynamictype' : { + 'extra_sources' : ['testmodule.c'], + }, + 'override' : {}, + 'signals' : {}, + 'singleton' : {}, + 'references' : {}, + 'testgobject' : {}, + 'accumulator' : { + 'extra_sources' : [testmarshal_c, testmarshal_h], + }, +} -foreach t : gobject_tests - test_name = t.get(0) - test_src = t.get(1, test_name + '.c') - test_extra_cargs = t.get(2, []) - test_timeout = t.get(3, 30) - test_suite = test_timeout == 30 ? ['gobject'] : ['gobject', 'slow'] +common_c_args = test_cargs + ['-DGLIB_DISABLE_DEPRECATION_WARNINGS'] +common_deps = [libm, thread_dep, libglib_dep, libgobject_dep] + +foreach test_name, extra_args : gobject_tests + source = extra_args.get('source', test_name + '.c') + extra_sources = extra_args.get('extra_sources', []) + install = installed_tests_enabled and extra_args.get('install', true) + + if install + test_conf = configuration_data() + test_conf.set('installed_tests_dir', installed_tests_execdir) + test_conf.set('program', test_name) + configure_file( + input: installed_tests_template, + output: test_name + '.test', + install_dir: installed_tests_metadir, + configuration: test_conf + ) + endif # FIXME? $(GLIB_DEBUG_FLAGS) - exe = executable(test_name + '-gobject', test_src, - c_args : test_cargs + test_extra_cargs + ['-DGLIB_DISABLE_DEPRECATION_WARNINGS'], - dependencies : [libm, thread_dep, libglib_dep, libgobject_dep], - install : false, + exe = executable(test_name, [source, extra_sources], + c_args : common_c_args + extra_args.get('c_args', []), + dependencies : common_deps + extra_args.get('dependencies', []), + install_dir: installed_tests_execdir, + install: install, ) + + suite = ['gobject'] + extra_args.get('suite', []) + timeout = suite.contains('slow') ? 120 : 30 # FIXME? TESTS_ENVIRONMENT = LIBCHARSET_ALIAS_DIR=$(top_builddir)/glib/libcharset - test(test_name, exe, env : test_env, timeout : test_timeout, suite : test_suite) + test(test_name, exe, env : test_env, timeout : timeout, suite : suite) endforeach # Don't install these ones, and keep them out of 'make check' because they take too long... executable('performance', 'performance.c', - c_args : test_cargs + test_extra_cargs + ['-DGLIB_DISABLE_DEPRECATION_WARNINGS'], - dependencies : [libm, thread_dep, libglib_dep, libgobject_dep], + c_args : common_c_args, + dependencies : common_deps, install : false) executable('performance-threaded', 'performance-threaded.c', - c_args : test_cargs + test_extra_cargs + ['-DGLIB_DISABLE_DEPRECATION_WARNINGS'], - dependencies : [libm, thread_dep, libglib_dep, libgobject_dep], + c_args : common_c_args, + dependencies : common_deps, install : false) if host_system != 'windows' and host_system != 'minix' executable('timeloop-closure', 'timeloop-closure.c', - c_args : test_cargs + test_extra_cargs + ['-DGLIB_DISABLE_DEPRECATION_WARNINGS'], - dependencies : [libm, thread_dep, libglib_dep, libgobject_dep], + c_args : common_c_args, + dependencies : common_deps, install : false) endif diff --git a/tests/meson.build b/tests/meson.build index 3beb4c68a..162051a15 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,12 +1,144 @@ # tests +# Not entirely random of course, but at least it changes over time +random_number = minor_version + meson.version().split('.').get(1).to_int() + test_env = environment() test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) test_env.set('G_DEBUG', 'gc-friendly') test_env.set('MALLOC_CHECK_', '2') +test_env.set('MALLOC_PERTURB_', '@0@'.format(random_number % 256)) test_cargs = ['-DG_LOG_DOMAIN="GLib"'] subdir('gobject') subdir('refcount') + +# FIXME: We are using list of dictionnaries until we can depend on Meson 0.48.0 +# that supports '+=' operator on dictionnaries. +tests = [{ + 'testglib' : {}, + 'testgdate' : {}, + 'datetime' : {}, + 'atomic-test' : {}, + 'bit-test' : {}, + 'child-test' : {}, + 'completion-test' : {}, + 'dirname-test' : {}, + 'file-test' : {}, + 'env-test' : {}, + 'gio-test' : {}, + 'mainloop-test' : {}, + 'mapping-test' : {}, + 'onceinit' : {}, + 'asyncqueue-test' : {}, + 'qsort-test' : {}, + 'relation-test' : {}, + 'slice-concurrent' : {}, + 'slice-threadinit' : { + 'dependencies' : [libgthread_dep], + }, + 'sources' : {}, + 'thread-test' : {}, + 'threadpool-test' : {'suite' : ['slow']}, + 'type-test' : {}, + 'unicode-caseconv' : {}, + 'unicode-encoding' : {}, + 'module-test' : { + 'dependencies' : [libgmodule_dep], + 'export_dynamic' : true, + }, + 'timeloop' : {}, + 'cxx-test' : { + 'source' : 'cxx-test.C', + 'include_directories' : gmoduleinc, + 'dependencies' : [libgio_dep], + }, +}] + +test_extra_programs = { + 'slice-test' : { + 'extra_sources' : ['memchunks.c'], + }, + 'slice-color' : { + 'extra_sources' : ['memchunks.c'], + }, + 'assert-msg-test' : {}, + 'unicode-collate' : {}, +} + +if host_machine.system() != 'windows' + tests += [{ + 'spawn-test' : {}, + 'iochannel-test' : {}, + }] +endif + +if installed_tests_enabled + install_data( + 'iochannel-test-infile', + 'casemap.txt', + 'casefold.txt', + 'utf8.txt', + install_dir : installed_tests_execdir, + ) +endif + +foreach module : ['moduletestplugin_a', 'moduletestplugin_b'] + shared_module(module, 'lib@0@.c'.format(module), + dependencies : [libglib_dep, libgmodule_dep], + install_dir : installed_tests_execdir, + install : installed_tests_enabled + ) +endforeach + +common_c_args = test_cargs + ['-DGLIB_DISABLE_DEPRECATION_WARNINGS'] +common_deps = [libm, thread_dep, libglib_dep] + +foreach test_dict : tests + foreach test_name, extra_args : test_dict + source = extra_args.get('source', test_name + '.c') + extra_sources = extra_args.get('extra_sources', []) + install = installed_tests_enabled and extra_args.get('install', true) + + if install + test_conf = configuration_data() + test_conf.set('installed_tests_dir', installed_tests_execdir) + test_conf.set('program', test_name) + configure_file( + input: installed_tests_template, + output: test_name + '.test', + install_dir: installed_tests_metadir, + configuration: test_conf + ) + endif + + # FIXME? $(GLIB_DEBUG_FLAGS) + exe = executable(test_name, [source, extra_sources], + c_args : common_c_args + extra_args.get('c_args', []), + dependencies : common_deps + extra_args.get('dependencies', []), + export_dynamic : extra_args.get('export_dynamic', false), + include_directories : extra_args.get('include_directories', []), + install_dir: installed_tests_execdir, + install: install, + ) + + suite = ['glib'] + extra_args.get('suite', []) + timeout = suite.contains('slow') ? 120 : 30 + # FIXME? TESTS_ENVIRONMENT = LIBCHARSET_ALIAS_DIR=$(top_builddir)/glib/libcharset + test(test_name, exe, env : test_env, timeout : timeout, suite : suite) + endforeach +endforeach + +foreach program_name, extra_args : test_extra_programs + source = extra_args.get('source', program_name + '.c') + extra_sources = extra_args.get('extra_sources', []) + install = installed_tests_enabled and extra_args.get('install', true) + executable(program_name, [source, extra_sources], + c_args : common_c_args, + dependencies : common_deps + extra_args.get('dependencies', []), + install_dir : installed_tests_execdir, + install : install, + ) +endforeach diff --git a/tests/refcount/meson.build b/tests/refcount/meson.build index afec05114..3a2072d08 100644 --- a/tests/refcount/meson.build +++ b/tests/refcount/meson.build @@ -1,30 +1,59 @@ -refcount_tests = [ - ['closures', 'closures.c', [], 90], - ['objects', 'objects.c', []], - ['objects2', 'objects2.c', [], 90], - ['properties', 'properties.c', []], - ['properties2', 'properties2.c', [], 90], - ['properties3', 'properties3.c', [], 90], # extra long timeout - ['properties4', 'properties4.c', []], - ['signal1', 'signals.c', ['-DTESTNUM=1']], - ['signal2', 'signals.c', ['-DTESTNUM=2']], - ['signal3', 'signals.c', ['-DTESTNUM=3']], - ['signal4', 'signals.c', ['-DTESTNUM=4']], -] +refcount_tests = { + 'closures' : {'suite' : ['slow']}, + 'objects' : {}, + 'objects2' : {'suite' : ['slow']}, + 'properties' : {}, + 'properties2' : {'suite' : ['slow']}, + 'properties3' : {'suite' : ['slow']}, + 'properties4' : {}, + 'signal1' : { + 'source' : 'signals.c', + 'c_args' : ['-DTESTNUM=1'], + }, + 'signal2' : { + 'source' : 'signals.c', + 'c_args' : ['-DTESTNUM=2'], + }, + 'signal3' : { + 'source' : 'signals.c', + 'c_args' : ['-DTESTNUM=3'], + }, + 'signal4' : { + 'source' : 'signals.c', + 'c_args' : ['-DTESTNUM=4'], + }, +} -foreach t : refcount_tests - test_name = t.get(0) - test_src = t.get(1) - test_extra_cargs = t.get(2) - test_timeout = t.get(3, 30) - test_suite = test_timeout == 30 ? ['refcount'] : ['refcount', 'slow'] +common_c_args = test_cargs + ['-DGLIB_DISABLE_DEPRECATION_WARNINGS'] +common_deps = [libm, thread_dep, libglib_dep, libgobject_dep] + +foreach test_name, extra_args : refcount_tests + source = extra_args.get('source', test_name + '.c') + extra_sources = extra_args.get('extra_sources', []) + install = installed_tests_enabled and extra_args.get('install', true) + + if install + test_conf = configuration_data() + test_conf.set('installed_tests_dir', installed_tests_execdir) + test_conf.set('program', test_name) + configure_file( + input: installed_tests_template, + output: test_name + '.test', + install_dir: installed_tests_metadir, + configuration: test_conf + ) + endif # FIXME? $(GLIB_DEBUG_FLAGS) - exe = executable(test_name + '-test', test_src, - c_args : test_cargs + test_extra_cargs + ['-DGLIB_DISABLE_DEPRECATION_WARNINGS'], - dependencies : [libm, thread_dep, libglib_dep, libgobject_dep], - install : false, + exe = executable(test_name, [source, extra_sources], + c_args : common_c_args + extra_args.get('c_args', []), + dependencies : common_deps + extra_args.get('dependencies', []), + install_dir: installed_tests_execdir, + install: install, ) + + suite = ['refcount'] + extra_args.get('suite', []) + timeout = suite.contains('slow') ? 120 : 30 # FIXME? TESTS_ENVIRONMENT = LIBCHARSET_ALIAS_DIR=$(top_builddir)/glib/libcharset - test(test_name, exe, env : test_env, timeout : test_timeout, suite : test_suite) + test(test_name, exe, env : test_env, timeout : timeout, suite : suite) endforeach From ef1bcc5a0423bff1ab9bb14bdf740d27a84c5c09 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 19 Sep 2018 22:36:38 -0400 Subject: [PATCH 03/10] Rename cxx-test.C to cxx-test.cpp Meson checks file extension case-insentively, and compiles ".C" as C source instead of C++. --- tests/Makefile.am | 2 +- tests/{cxx-test.C => cxx-test.cpp} | 0 tests/meson.build | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename tests/{cxx-test.C => cxx-test.cpp} (100%) diff --git a/tests/Makefile.am b/tests/Makefile.am index fba18655d..9682352d0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -123,7 +123,7 @@ dist-hook: $(BUILT_EXTRA_DIST) if HAVE_CXX installed_test_programs += cxx-test -cxx_test_SOURCES = cxx-test.C +cxx_test_SOURCES = cxx-test.cpp endif if ENABLE_TIMELOOP diff --git a/tests/cxx-test.C b/tests/cxx-test.cpp similarity index 100% rename from tests/cxx-test.C rename to tests/cxx-test.cpp diff --git a/tests/meson.build b/tests/meson.build index 162051a15..7530571bf 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -51,7 +51,7 @@ tests = [{ }, 'timeloop' : {}, 'cxx-test' : { - 'source' : 'cxx-test.C', + 'source' : 'cxx-test.cpp', 'include_directories' : gmoduleinc, 'dependencies' : [libgio_dep], }, From 3cdce166688293f059f8004380aa72ce5fc202e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Thu, 20 Sep 2018 05:17:02 +0000 Subject: [PATCH 04/10] tests W32: Cast the MSG struct as (gchar *) for g_io_channel_read --- tests/gio-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/gio-test.c b/tests/gio-test.c index 22ae77cff..c9523fba2 100644 --- a/tests/gio-test.c +++ b/tests/gio-test.c @@ -218,7 +218,7 @@ recv_windows_message (GIOChannel *channel, while (1) { - error = g_io_channel_read (channel, &msg, sizeof (MSG), &nb); + error = g_io_channel_read (channel, (gchar *) &msg, sizeof (MSG), &nb); if (error != G_IO_ERROR_NONE) { From 190ea6ed1006959a6cfab405b932aa89fb9b461a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Thu, 20 Sep 2018 05:18:51 +0000 Subject: [PATCH 05/10] tests W32: Fix Windows values casting LPARAM is LONG_PTR which is the same as INT_PTR on Windows. WPARAM is UINT_PTR. HWND is a pointer. (%p prints pointers without 0x prefix, hence the extra 0x). --- tests/gio-test.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/gio-test.c b/tests/gio-test.c index c9523fba2..d9bd7e357 100644 --- a/tests/gio-test.c +++ b/tests/gio-test.c @@ -214,7 +214,7 @@ recv_windows_message (GIOChannel *channel, { GIOError error; MSG msg; - guint nb; + gsize nb; while (1) { @@ -232,20 +232,25 @@ recv_windows_message (GIOChannel *channel, break; } - g_print ("gio-test: ...Windows message for %#x: %d,%d,%d\n", - msg.hwnd, msg.message, msg.wParam, msg.lParam); + g_print ("gio-test: ...Windows message for 0x%p: %d,%" G_GUINTPTR_FORMAT ",%" G_GINTPTR_FORMAT "\n", + msg.hwnd, msg.message, msg.wParam, (gintptr)msg.lParam); return TRUE; } +LRESULT CALLBACK window_procedure (HWND hwnd, + UINT message, + WPARAM wparam, + LPARAM lparam); + LRESULT CALLBACK window_procedure (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { - g_print ("gio-test: window_procedure for %#x: %d,%d,%d\n", - hwnd, message, wparam, lparam); + g_print ("gio-test: window_procedure for 0x%p: %d,%" G_GUINTPTR_FORMAT ",%" G_GINTPTR_FORMAT "\n", + hwnd, message, wparam, (gintptr)lparam); return DefWindowProc (hwnd, message, wparam, lparam); } @@ -331,7 +336,7 @@ main (int argc, nrunning++; #ifdef G_OS_WIN32 - cmdline = g_strdup_printf ("%d:%d:%d", + cmdline = g_strdup_printf ("%d:%d:0x%p", pipe_to_sub[0], pipe_from_sub[1], hwnd); @@ -388,7 +393,7 @@ main (int argc, sscanf (argv[2], "%d:%d%n", &readfd, &writefd, &n); #ifdef G_OS_WIN32 - sscanf (argv[2] + n, ":%d", &hwnd); + sscanf (argv[2] + n, ":0x%p", &hwnd); #endif srand (tv.tv_sec ^ (tv.tv_usec / 1000) ^ readfd ^ (writefd << 4)); @@ -413,8 +418,8 @@ main (int argc, int msg = WM_USER + (rand() % 100); WPARAM wparam = rand (); LPARAM lparam = rand (); - g_print ("gio-test: child posting message %d,%d,%d to %#x\n", - msg, wparam, lparam, hwnd); + g_print ("gio-test: child posting message %d,%" G_GUINTPTR_FORMAT ",%" G_GINTPTR_FORMAT " to 0x%p\n", + msg, wparam, (gintptr)lparam, hwnd); PostMessage (hwnd, msg, wparam, lparam); } #endif From d2c9543f2e674d20e72144122b7409c31f08c7e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Thu, 20 Sep 2018 05:20:24 +0000 Subject: [PATCH 06/10] tests W32: include process.h for getpid() At least, MinGW has POSIX names. No idea if this works in MSVC. --- tests/mapping-test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/mapping-test.c b/tests/mapping-test.c index 3eb90fa48..27c6d8366 100644 --- a/tests/mapping-test.c +++ b/tests/mapping-test.c @@ -25,6 +25,9 @@ #ifdef G_OS_UNIX #include #endif +#ifdef G_OS_WIN32 +#include +#endif static gchar *dir, *filename, *displayname, *childname; From 4c91334412f89623dc4be4b11549ecb194395633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Thu, 20 Sep 2018 05:21:38 +0000 Subject: [PATCH 07/10] tests W32: ugly fix for sscanf() format As we recently established, G_G*_FORMAT macros are for glib functions *only*. It's not guaranteed that they will work for C runtime printf() or scanf() variants, and indeed - in this case they do not (GCC thinks that MSVCRT sscanf() requires %I64 prefix for 64-bit values; whether that is true or not is irrelevant at this point - we need to make the werror go away). --- tests/type-test.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/type-test.c b/tests/type-test.c index ed7cc44cf..43da39472 100644 --- a/tests/type-test.c +++ b/tests/type-test.c @@ -120,8 +120,13 @@ main (int argc, gu64t1 = G_GINT64_CONSTANT (0xFAFAFAFAFAFAFAFA); #define FORMAT64 "%" G_GINT64_FORMAT " %" G_GUINT64_FORMAT "\n" +#ifndef G_OS_WIN32 +# define SCAN_FORMAT64 FORMAT64 +#else +# define SCAN_FORMAT64 "%I64d %I64u\n" +#endif string = g_strdup_printf (FORMAT64, gi64t1, gu64t1); - sscanf (string, FORMAT64, &gi64t2, &gu64t2); + sscanf (string, SCAN_FORMAT64, &gi64t2, &gu64t2); g_free (string); g_assert (gi64t1 == gi64t2); g_assert (gu64t1 == gu64t2); @@ -130,8 +135,13 @@ main (int argc, gst1 = 0xFAFAFAFA; #define FORMATSIZE "%" G_GSSIZE_FORMAT " %" G_GSIZE_FORMAT "\n" +#ifndef G_OS_WIN32 +# define SCAN_FORMATSIZE FORMATSIZE +#else +# define SCAN_FORMATSIZE "%Id %Iu\n" +#endif string = g_strdup_printf (FORMATSIZE, gsst1, gst1); - sscanf (string, FORMATSIZE, &gsst2, &gst2); + sscanf (string, SCAN_FORMATSIZE, &gsst2, &gst2); g_free (string); g_assert (gsst1 == gsst2); g_assert (gst1 == gst2); From 665677ce5e6d39780873e1506c20c929fb337361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Thu, 20 Sep 2018 05:24:08 +0000 Subject: [PATCH 08/10] tests W32: Move timeloop test to the non-Windows section It just doesn't work on Windows, and that can't be fixed with a quick patch. --- tests/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/meson.build b/tests/meson.build index 7530571bf..b054a1732 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -49,7 +49,6 @@ tests = [{ 'dependencies' : [libgmodule_dep], 'export_dynamic' : true, }, - 'timeloop' : {}, 'cxx-test' : { 'source' : 'cxx-test.cpp', 'include_directories' : gmoduleinc, @@ -70,6 +69,7 @@ test_extra_programs = { if host_machine.system() != 'windows' tests += [{ + 'timeloop' : {}, 'spawn-test' : {}, 'iochannel-test' : {}, }] From 3ae1244ba10de8a0070613b0377a2deabeee1822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Thu, 20 Sep 2018 07:26:49 +0000 Subject: [PATCH 09/10] tests W32: ifdef a variable not used on Windows --- tests/mapping-test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/mapping-test.c b/tests/mapping-test.c index 27c6d8366..ad776fad1 100644 --- a/tests/mapping-test.c +++ b/tests/mapping-test.c @@ -191,7 +191,9 @@ test_child_private (gchar *argv0) gsize len; gchar *child_argv[4]; GPid child_pid; +#ifndef G_OS_WIN32 GMainLoop *loop; +#endif gchar pid[100]; #ifdef G_OS_WIN32 From abac67c050c1e795035a1d691a87817b7f41dab7 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 20 Sep 2018 09:36:20 -0400 Subject: [PATCH 10/10] Tests: Fix -Wformat-nonliteral causing build failure with clang --- tests/unicode-encoding.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unicode-encoding.c b/tests/unicode-encoding.c index 8ac4f9522..80427bd86 100644 --- a/tests/unicode-encoding.c +++ b/tests/unicode-encoding.c @@ -9,6 +9,8 @@ static gint exit_status = 0; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" static void croak (char *format, ...) { @@ -32,6 +34,7 @@ fail (char *format, ...) exit_status |= 1; } +#pragma GCC diagnostic pop typedef enum {