diff --git a/gio/meson.build b/gio/meson.build index 803b7ac01..8535d079f 100644 --- a/gio/meson.build +++ b/gio/meson.build @@ -341,8 +341,9 @@ if host_system != 'windows' endif endif +# This is also used by tests/gdbus-daemon, so use files() to include the path gdbus_daemon_sources = [ - 'gdbusdaemon.c', + files('gdbusdaemon.c'), gdbus_daemon_generated, ] diff --git a/gio/tests/gdbus-object-manager-example/meson.build b/gio/tests/gdbus-object-manager-example/meson.build new file mode 100644 index 000000000..a5cff0c3f --- /dev/null +++ b/gio/tests/gdbus-object-manager-example/meson.build @@ -0,0 +1,23 @@ +# FIXME: set UNINSTALLED_GLIB_{SRC|BUILD}DIR=top_{src|build}dir ? +gdbus_example_objectmanager_generated = custom_target('gdbus-example-objectmanager-generated', + input : ['gdbus-example-objectmanager.xml'], + output : ['gdbus-example-objectmanager-generated.h', + 'gdbus-example-objectmanager-generated.c', + 'gdbus-example-objectmanager-generated-org.gtk.GDBus.Example.ObjectManager.Animal.xml', + 'gdbus-example-objectmanager-generated-org.gtk.GDBus.Example.ObjectManager.Cat.xml'], + command : [python, gdbus_codegen, + '--interface-prefix', 'org.gtk.GDBus.Example.ObjectManager.', + '--c-namespace', 'Example', + '--c-generate-object-manager', + '--generate-c-code', '@OUTDIR@/gdbus-example-objectmanager-generated', + '--generate-docbook', '@OUTDIR@/gdbus-example-objectmanager-generated', + '@INPUT@']) + +libgdbus_example_objectmanager = shared_library('libgdbus-example-objectmanager', + gdbus_example_objectmanager_generated, + c_args : ['-DHAVE_CONFIG_H=1'] + gio_c_args, + dependencies : [libglib_dep, libgmodule_dep, libgobject_dep, libgio_dep], + install : false) + +libgdbus_example_objectmanager_dep = declare_dependency(sources : gdbus_example_objectmanager_generated, + link_with : libgdbus_example_objectmanager) diff --git a/gio/tests/gengiotypefuncs.py b/gio/tests/gengiotypefuncs.py new file mode 100644 index 000000000..9732d7892 --- /dev/null +++ b/gio/tests/gengiotypefuncs.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import sys +import re +import os + +debug = os.getenv('GIO_GENTYPEFUNCS_DEBUG') is not None + +out_file = sys.argv[1] +in_files = sys.argv[2:] + +funcs = [] + + +if debug: print ('Output file: ', out_file) + +if debug: print (len(in_files), 'input files') + +for filename in in_files: + if debug: print ('Input file: ', filename) + with open(filename, "r") as f: + for line in f: + line = line.rstrip('\n').rstrip('\r') + # print line + match = re.search(r'\bg_[a-zA-Z0-9_]*_get_type\b', line) + if match: + func = match.group(0) + if not func in funcs: + funcs.append(func) + if debug: print ('Found ', func) + +file_output = 'G_GNUC_BEGIN_IGNORE_DEPRECATIONS\n' + +funcs = sorted(funcs) + +for f in funcs: + if f not in ['g_io_extension_get_type', 'g_settings_backend_get_type']: + file_output += '*tp++ = {0} ();\n'.format(f) + +if debug: print (len(funcs), 'functions') + +ofile = open(out_file, "w") +ofile.write(file_output) +ofile.close() diff --git a/gio/tests/meson.build b/gio/tests/meson.build index fd0ecea29..3bc644a3c 100644 --- a/gio/tests/meson.build +++ b/gio/tests/meson.build @@ -1,3 +1,12 @@ +subdir('gdbus-object-manager-example') + +gengiotypefuncs_prog = find_program('gengiotypefuncs.py') +giotypefuncs_inc = custom_target( + 'giotypefuncs.inc', + output : 'giotypefuncs.inc', + input : gio_headers + [gioenumtypes_h] + gobject_install_headers, + command: [gengiotypefuncs_prog, '@OUTPUT@', '@INPUT@']) + # Test programs buildable on all platforms gio_tests = [ 'appmonitor', @@ -12,7 +21,7 @@ gio_tests = [ 'credentials', 'data-input-stream', 'data-output-stream', - #'defaultvalue', # FIXME: needs giotypefuncs.c generated + 'defaultvalue', 'fileattributematcher', 'filter-streams', 'giomodule', @@ -45,26 +54,39 @@ gio_tests = [ 'volumemonitor', 'glistmodel', 'testfilemonitor', -] - -gio_tests += [ 'thumbnail-verification', ] -# Test programs buildable on UNIX only +test_extra_programs = [ + ['gdbus-connection-flush-helper'], + ['gdbus-testserver'], +] +# Test programs buildable on UNIX only if host_machine.system() != 'windows' gio_tests += [ 'file', - #'gdbus-peer', Needs gdbus-object-manager-example/gdbus-example-objectmanager-generated.h + 'gdbus-peer', 'gdbus-peer-object-manager', - 'gdbus-unix-addresses', 'live-g-file', 'socket-address', 'stream-rw_all', 'unix-fd', 'unix-streams', + 'mimeapps', ] + + test_extra_programs += [ + ['basic-application'], + ['dbus-launch'], + ['appinfo-test'], + ['apps'], + ] + + have_dbus_daemon = find_program('dbus-daemon', required : false).found() + if have_dbus_daemon + gio_tests += ['gdbus-unix-addresses'] + endif endif if cc.get_id() != 'msvc' @@ -83,16 +105,22 @@ test_c_args = [ ] foreach test_name : gio_tests - src_file = '@0@.c'.format(test_name) + extra_deps = [] + srcs = ['@0@.c'.format(test_name)] # conflicts with glib/tests/autoptr, can't have two targets with same name if test_name == 'autoptr' test_name = 'autoptr-gio' + elif test_name == 'defaultvalue' + srcs += [giotypefuncs_inc] + elif test_name == 'gdbus-peer' + # This is peer to peer so it doesn't need a session bus, so we can run + # it automatically as a test by default + extra_deps = [libgdbus_example_objectmanager_dep] endif - exe = executable(test_name, src_file, + exe = executable(test_name, srcs, install : false, c_args : test_c_args, - dependencies : [libglib_dep, libgmodule_dep, libgio_dep], - ) + dependencies : [libglib_dep, libgmodule_dep, libgio_dep] + extra_deps) if test_name == 'testfilemonitor' test(test_name, exe, env : test_env, timeout : 45) else @@ -101,68 +129,59 @@ foreach test_name : gio_tests endforeach uninstalled_test_extra_programs = [ - 'gio-du', - 'echo-server', - 'filter-cat', - 'gapplication-example-actions', - 'gapplication-example-cmdline', - 'gapplication-example-cmdline2', - 'gapplication-example-cmdline3', - 'gapplication-example-dbushooks', - 'gapplication-example-open', - 'gdbus-example-export', - 'gdbus-example-own-name', - 'gdbus-example-peer', - 'gdbus-example-proxy-subclass', - 'gdbus-example-server', - 'gdbus-example-subtree', - 'gdbus-example-watch-name', - 'gdbus-example-watch-proxy', - 'gsubprocess-testprog', - 'httpd', - 'proxy', - 'resolver', - 'send-data', - 'socket-server', + ['gio-du'], + ['echo-server'], + ['filter-cat'], + ['gapplication-example-actions'], + ['gapplication-example-cmdline'], + ['gapplication-example-cmdline2'], + ['gapplication-example-cmdline3'], + ['gapplication-example-dbushooks'], + ['gapplication-example-open'], + ['gdbus-daemon', gdbus_daemon_sources], + ['gdbus-example-export'], + ['gdbus-example-own-name'], + ['gdbus-example-peer'], + ['gdbus-example-proxy-subclass'], + ['gdbus-example-server'], + ['gdbus-example-subtree'], + ['gdbus-example-watch-name'], + ['gdbus-example-watch-proxy'], + ['gsubprocess-testprog'], + ['httpd'], + ['proxy'], + ['resolver'], + ['send-data'], + ['socket-server'], + ['socket-client', ['gtlsconsoleinteraction.c']], + ['tls-certificate', ['gtesttlsbackend.c']], + ['tls-interaction', ['gtesttlsbackend.c']], + # 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', [], [libgdbus_example_objectmanager_dep]], + ['gdbus-example-objectmanager-server', [], [libgdbus_example_objectmanager_dep]], + ['gdbus-test-fixture', [], [libgdbus_example_objectmanager_dep]], ] -foreach extra_program : uninstalled_test_extra_programs - exe = executable(extra_program, '@0@.c'.format(extra_program), +if host_machine.system() != 'windows' + uninstalled_test_extra_programs += [['gdbus-example-unix-fd-client']] +endif + +foreach extra_program : uninstalled_test_extra_programs + test_extra_programs + srcs = ['@0@.c'.format(extra_program[0])] + if extra_program.length() > 1 + srcs += extra_program[1] + endif + extra_deps = [] + if extra_program.length() > 2 + extra_deps = extra_program[2] + endif + executable(extra_program[0], srcs, install : false, c_args : test_c_args, - dependencies : [libglib_dep, libgmodule_dep, libgio_dep], - ) + dependencies : [libglib_dep, libgmodule_dep, libgio_dep] + extra_deps) endforeach -test_extra_programs = [ - 'gdbus-connection-flush-helper', - 'gdbus-testserver', -] - -exe = executable('tls-certificate', 'tls-certificate.c', 'gtesttlsbackend.c', - c_args : test_c_args, - dependencies : [libglib_dep, libgmodule_dep, libgio_dep], -) -test('tls-certificate', exe, env : test_env) - -exe = executable('tls-interaction', 'tls-interaction.c', 'gtesttlsbackend.c', - c_args : test_c_args, - dependencies : [libglib_dep, libgmodule_dep, libgio_dep], -) -test('tls-interaction', exe, env : test_env) - -exe = executable('socket-client', 'socket-client.c', 'gtlsconsoleinteraction.c', - c_args : test_c_args, - dependencies : [libglib_dep, libgmodule_dep, libgio_dep], -) - -#exe = executable('gdbus-daemon', 'gdbus-daemon.c', '../gdbusdaemon.c', -# #meson.build_root() + '/gio/gdbus-daemon-generated.c', # FIXME -# c_args : test_c_args, -# dependencies : [libglib_dep, libgmodule_dep, libgio_dep], -#) -#test('gdbus-daemon', exe, env : test_env) - # FIXME: Add resources test foo = ''' diff --git a/gobject/tests/meson.build b/gobject/tests/meson.build index 03be192a0..69d4facb5 100644 --- a/gobject/tests/meson.build +++ b/gobject/tests/meson.build @@ -17,9 +17,17 @@ gobject_tests = [ 'ifaceproperties', ] +# FIXME: use new environment() object +# FIXME: put common bits of test environment() in one location +# Not entirely random of course, but at least it changes over time +random_number = minor_version.to_int() + meson.version().split('.').get(1).to_int() + test_env = [ 'G_TEST_SRCDIR=' + meson.current_source_dir(), 'G_TEST_BUILDDIR=' + meson.current_build_dir(), + 'G_DEBUG=gc-friendly', + 'MALLOC_CHECK_=2', + 'MALLOC_PERTURB_=@0@'.format(random_number % 256), ] foreach test_name : gobject_tests