Imported Upstream version 2.55.0
[platform/upstream/glib.git] / gio / tests / meson.build
1 common_gio_tests_deps = [libglib_dep, libgmodule_dep, libgobject_dep, libgio_dep]
2
3 subdir('gdbus-object-manager-example')
4
5 gengiotypefuncs_prog = find_program('gengiotypefuncs.py')
6 giotypefuncs_inc = custom_target(
7   'giotypefuncs.inc',
8   output : 'giotypefuncs.inc',
9   input : gio_headers + [gioenumtypes_h] + gobject_install_headers,
10   command: [gengiotypefuncs_prog, '@OUTPUT@', '@INPUT@'])
11
12 #  Test programs buildable on all platforms
13 gio_tests = [
14   'appmonitor',
15   'async-close-output-stream',
16   'async-splice-output-stream',
17   'buffered-input-stream',
18   'buffered-output-stream',
19   'cancellable',
20   'contexts',
21   'contenttype',
22   'converter-stream',
23   'credentials',
24   'data-input-stream',
25   'data-output-stream',
26   'defaultvalue',
27   'fileattributematcher',
28   'filter-streams',
29   'giomodule',
30   'gsubprocess',
31   'g-file',
32   'g-file-info',
33   'g-icon',
34   'gdbus-addresses',
35   'gdbus-message',
36   'inet-address',
37   'io-stream',
38   'memory-input-stream',
39   'memory-output-stream',
40   'monitor',
41   'network-address',
42   'network-monitor',
43   'permission',
44   'pollable',
45   'proxy-test',
46   'readwrite',
47   'simple-async-result',
48   'simple-proxy',
49   'sleepy-stream',
50   'socket',
51   'socket-listener',
52   'socket-service',
53   'srvtarget',
54   'task',
55   'vfs',
56   'volumemonitor',
57   'glistmodel',
58   'testfilemonitor',
59   'thumbnail-verification',
60 ]
61
62 test_extra_programs = [
63   ['gdbus-connection-flush-helper'],
64   ['gdbus-testserver'],
65 ]
66
67 test_env = [
68   'G_TEST_SRCDIR=' + meson.current_source_dir(),
69   'G_TEST_BUILDDIR=' + meson.current_build_dir(),
70 ]
71
72 test_c_args = [
73   '-DHAVE_CONFIG_H=1',
74   '-DG_LOG_DOMAIN="GLib-GIO"',
75   '-DTEST_SERVICES="@0@/gio/tests/services"'.format(meson.build_root()),
76   '-DGLIB_MKENUMS="@0@"'.format(glib_mkenums),
77   '-DGLIB_COMPILE_SCHEMAS="@0@"'.format(glib_compile_schemas.full_path()),
78 ]
79
80 # Check for libdbus1 - Optional - is only used in the GDBus test cases
81 # 1.2.14 required for dbus_message_set_serial
82 dbus1_dep = dependency('dbus-1', required : false, version : '>= 1.2.14')
83 if not dbus1_dep.found()
84   if cc.get_id() == 'msvc'
85     # MSVC: Search for the DBus library by the configuration, which corresponds
86     # to the output of CMake builds of DBus.  Note that debugoptimized
87     # is really a Release build with .PDB files.
88     if buildtype == 'debug'
89       dbus1_dep = cc.find_library('dbus-1d', required : false)
90     else
91       dbus1_dep = cc.find_library('dbus-1', required : false)
92     endif
93   endif
94 endif
95 if dbus1_dep.found()
96   glib_conf.set('HAVE_DBUS1', 1)
97
98   exe = executable('gdbus-serialization',
99       'gdbus-serialization.c', 'gdbus-tests.c',
100       install : false,
101       c_args : test_c_args,
102       dependencies : common_gio_tests_deps + [dbus1_dep])
103   test('gdbus-serialization', exe, env : test_env)
104 endif
105
106 #  Test programs buildable on UNIX only
107 if host_machine.system() != 'windows'
108   gio_tests += [
109     'file',
110     'gdbus-peer',
111     'gdbus-peer-object-manager',
112     'live-g-file',
113     'socket-address',
114     'stream-rw_all',
115     'unix-fd',
116     'unix-mounts',
117     'unix-streams',
118     'g-file-info-filesystem-readonly',
119     'gschema-compile',
120   ]
121
122   # Uninstalled because of the check-for-executable logic in DesktopAppInfo
123   # unable to find the installed executable
124   if not glib_have_cocoa
125     gio_tests += [
126       'appinfo',
127       'desktop-app-info',
128     ]
129   endif
130
131   test_extra_programs += [
132     ['basic-application'],
133     ['dbus-launch'],
134     ['appinfo-test'],
135   ]
136
137   if not glib_have_cocoa
138     test_extra_programs += [['apps']]
139     gio_tests += ['mimeapps']
140   endif
141
142   #  Test programs that need to bring up a session bus (requires dbus-daemon)
143   have_dbus_daemon = find_program('dbus-daemon', required : false).found()
144   if have_dbus_daemon
145     # Generate gdbus-test-codegen-generated.{c,h}
146     gdbus_test_codegen_generated = custom_target('gdbus-test-codegen-generated',
147         input :   ['test-codegen.xml'],
148         output :  ['gdbus-test-codegen-generated.h',
149                    'gdbus-test-codegen-generated.c'],
150         depend_files : gdbus_codegen_built_files,
151         command : [python, gdbus_codegen,
152                    '--interface-prefix', 'org.project.',
153                    '--output-directory', '@OUTDIR@',
154                    '--generate-c-code', 'gdbus-test-codegen-generated',
155                    '--c-generate-object-manager',
156                    '--c-namespace', 'Foo_iGen',
157                    '--generate-docbook', 'gdbus-test-codegen-generated-doc',
158                    '--annotate', 'org.project.Bar', 'Key1', 'Value1',
159                    '--annotate', 'org.project.Bar', 'org.gtk.GDBus.Internal', 'Value2',
160                    '--annotate', 'org.project.Bar.HelloWorld()', 'Key3', 'Value3',
161                    '--annotate', 'org.project.Bar::TestSignal', 'Key4', 'Value4',
162                    '--annotate', 'org.project.Bar:ay', 'Key5', 'Value5',
163                    '--annotate', 'org.project.Bar.TestPrimitiveTypes()[val_int32]', 'Key6', 'Value6',
164                    '--annotate', 'org.project.Bar.TestPrimitiveTypes()[ret_uint32]', 'Key7', 'Value7',
165                    '--annotate', 'org.project.Bar::TestSignal[array_of_strings]', 'Key8', 'Value8',
166                    '@INPUT@'])
167
168     gio_dbus_tests = [
169       ['actions', [], []],
170       ['gdbus-auth', [], []],
171       ['gdbus-bz627724', [], []],
172       ['gdbus-close-pending', [], []],
173       ['gdbus-connection', [], []],
174       ['gdbus-connection-loss', [], []],
175       ['gdbus-connection-slow', [], []],
176       ['gdbus-error', [], []],
177       ['gdbus-exit-on-close', [], []],
178       ['gdbus-export', [], []],
179       ['gdbus-introspection', [], []],
180       ['gdbus-names', [], []],
181       ['gdbus-proxy', [], []],
182       ['gdbus-proxy-threads', [], [dbus1_dep]],
183       ['gdbus-proxy-well-known-name', [], []],
184       ['gdbus-test-codegen', [gdbus_test_codegen_generated], []],
185       ['gdbus-threading', [], []],
186       ['gmenumodel', [], []],
187       ['gnotification', ['gnotification-server.c'], []],
188     ]
189
190     if not glib_have_cocoa
191       gio_dbus_tests = [['dbus-appinfo', [], []]]
192     endif
193
194     # separate loop because extra source files for each test
195     foreach dbus_test : gio_dbus_tests
196       test_name = dbus_test[0]
197       extra_src = dbus_test[1]
198       extra_deps = dbus_test[2]
199       exe = executable(test_name, '@0@.c'.format(test_name),
200           'gdbus-sessionbus.c', 'gdbus-tests.c', extra_src,
201           install : false,
202           c_args : test_c_args,
203           dependencies : common_gio_tests_deps + extra_deps)
204       test(test_name, exe, env : test_env)
205     endforeach
206
207     exe = executable('gdbus-test-codegen-old', 'gdbus-test-codegen.c',
208           'gdbus-sessionbus.c', 'gdbus-tests.c', gdbus_test_codegen_generated,
209           install : false,
210           c_args : test_c_args + ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36', '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36'],
211           dependencies : common_gio_tests_deps)
212     test('gdbus-test-codegen-old', exe, env : test_env)
213
214     # There is already a gapplication exe target in gio so need to use a
215     # different name for the unit test executable, since we can't have two
216     # targets of the same name even if in different directories
217     # (FIXME: just rename source file to gapplication-test.c)
218     if not glib_have_cocoa
219       exe = executable('gapplication-test', 'gapplication.c',
220                        'gdbus-sessionbus.c', 'gdbus-tests.c',
221                        install : false,
222                        c_args : test_c_args,
223                        dependencies : common_gio_tests_deps)
224     endif
225     test('gapplication', exe, env : test_env)
226
227     gio_tests += ['gdbus-unix-addresses']
228   endif # have_dbus_daemon
229
230   # This test is currently unreliable
231   executable('gdbus-overflow', 'gdbus-overflow.c',
232       install : false,
233       c_args : test_c_args,
234       dependencies : common_gio_tests_deps)
235
236   exe = executable('gdbus-connection-flush', 'gdbus-connection-flush.c',
237       'test-io-stream.c', 'test-pipe-unix.c',
238       install : false,
239       c_args : test_c_args,
240       dependencies : common_gio_tests_deps)
241   test('gdbus-connection-flush', exe, env : test_env)
242
243   exe = executable('gdbus-non-socket', 'gdbus-non-socket.c',
244       'gdbus-tests.c', 'test-io-stream.c', 'test-pipe-unix.c',
245       install : false,
246       c_args : test_c_args,
247       dependencies : common_gio_tests_deps)
248   test('gdbus-non-socket', exe, env : test_env)
249
250   # Generate test.mo from de.po using msgfmt
251   msgfmt = find_program('msgfmt', required : false)
252   if msgfmt.found()
253     subdir('de/LC_MESSAGES')
254     # gsettings target exe already exists in gio directory
255     exe = executable('gsettings-test', 'gsettings.c', test_mo,
256         install : false,
257         c_args : test_c_args + [
258                    '-DSRCDIR="@0@"'.format(meson.current_source_dir()),
259                    '-DTEST_LOCALE_PATH="@0@"'.format(test_mo_dir),
260                  ],
261         dependencies : common_gio_tests_deps)
262     test('gsettings', exe, env : test_env)
263   endif
264 endif # unix
265
266 #  Test programs buildable on Windows only
267 if host_machine.system() == 'windows'
268   gio_tests += ['win32-streams']
269 endif
270
271 if cc.get_id() != 'msvc'
272   gio_tests += [ 'autoptr' ]
273 endif
274
275 foreach test_name : gio_tests
276   extra_deps = []
277   srcs = ['@0@.c'.format(test_name)]
278   # conflicts with glib/tests/autoptr, can't have two targets with same name
279   if test_name == 'autoptr'
280     test_name = 'autoptr-gio'
281   elif test_name == 'defaultvalue'
282     srcs += [giotypefuncs_inc]
283   elif test_name == 'gdbus-peer'
284     # This is peer to peer so it doesn't need a session bus, so we can run
285     # it automatically as a test by default
286     extra_deps = [libgdbus_example_objectmanager_dep]
287   endif
288   exe = executable(test_name, srcs,
289       install : false,
290       c_args : test_c_args,
291       dependencies : common_gio_tests_deps + extra_deps)
292   if test_name == 'testfilemonitor'
293     test(test_name, exe, env : test_env, timeout : 45)
294   else
295     test(test_name, exe, env : test_env)
296   endif
297 endforeach
298
299 uninstalled_test_extra_programs = [
300   ['gio-du'],
301   ['echo-server'],
302   ['filter-cat'],
303   ['gapplication-example-actions'],
304   ['gapplication-example-cmdline'],
305   ['gapplication-example-cmdline2'],
306   ['gapplication-example-cmdline3'],
307   ['gapplication-example-dbushooks'],
308   ['gapplication-example-open'],
309   ['gdbus-daemon', gdbus_daemon_sources],
310   ['gdbus-example-export'],
311   ['gdbus-example-own-name'],
312   ['gdbus-example-peer'],
313   ['gdbus-example-proxy-subclass'],
314   ['gdbus-example-server'],
315   ['gdbus-example-subtree'],
316   ['gdbus-example-watch-name'],
317   ['gdbus-example-watch-proxy'],
318   ['gsubprocess-testprog'],
319   ['httpd'],
320   ['proxy'],
321   ['resolver'],
322   ['send-data'],
323   ['socket-server'],
324   ['socket-client', ['gtlsconsoleinteraction.c']],
325   ['tls-certificate', ['gtesttlsbackend.c']],
326   ['tls-interaction', ['gtesttlsbackend.c']],
327   # These three are manual-run tests because they need a session bus but don't bring one up themselves
328   # FIXME: these build but don't seem to work!
329   ['gdbus-example-objectmanager-client', [], [libgdbus_example_objectmanager_dep]],
330   ['gdbus-example-objectmanager-server', [], [libgdbus_example_objectmanager_dep]],
331   ['gdbus-test-fixture', [], [libgdbus_example_objectmanager_dep]],
332 ]
333
334 if host_machine.system() != 'windows'
335   uninstalled_test_extra_programs += [['gdbus-example-unix-fd-client']]
336 endif
337
338 foreach extra_program : uninstalled_test_extra_programs + test_extra_programs
339   srcs = ['@0@.c'.format(extra_program[0])]
340   if extra_program.length() > 1
341     srcs += extra_program[1]
342   endif
343   extra_deps = []
344   if extra_program.length() > 2
345     extra_deps = extra_program[2]
346   endif
347   executable(extra_program[0], srcs,
348       install : false,
349       c_args : test_c_args,
350       dependencies : common_gio_tests_deps + extra_deps)
351 endforeach
352
353 if not meson.is_cross_build() or meson.has_exe_wrapper()
354
355   plugin_resources_c = custom_target('plugin-resources.c',
356     input : 'test4.gresource.xml',
357     output : 'plugin-resources.c',
358     command : [glib_compile_resources,
359                '--target=@OUTPUT@',
360                '--sourcedir=' + meson.current_source_dir(),
361                '--generate-source',
362                '--c-name', '_g_plugin',
363                '@INPUT@'])
364
365   if host_system == 'windows'
366     resource_plugin_platform_link_args = ['-no-undefined']
367   else
368     resource_plugin_platform_link_args = []
369   endif
370   shared_module ('resourceplugin', 'resourceplugin.c', plugin_resources_c,
371     link_args : ['-export-dynamic'] + resource_plugin_platform_link_args,
372     dependencies : common_gio_tests_deps)
373
374   test_gresource = custom_target('test.gresource',
375     input : 'test.gresource.xml',
376     output : 'test.gresource',
377     command : [glib_compile_resources,
378                '--target=@OUTPUT@',
379                '--sourcedir=' + meson.current_source_dir(),
380                '--sourcedir=' + meson.current_build_dir(),
381                '@INPUT@'])
382
383   test_resources2_c = custom_target('test_resources2.c',
384     input : 'test3.gresource.xml',
385     output : 'test_resources2.c',
386     command : [glib_compile_resources,
387                '--target=@OUTPUT@',
388                '--sourcedir=' + meson.current_source_dir(),
389                '--generate',
390                '--c-name', '_g_test2',
391                '--manual-register',
392                '@INPUT@'])
393
394   test_resources2_h = custom_target('test_resources2.h',
395     input : 'test3.gresource.xml',
396     output : 'test_resources2.h',
397     command : [glib_compile_resources,
398                '--target=@OUTPUT@',
399                '--sourcedir=' + meson.current_source_dir(),
400                '--generate',
401                '--c-name', '_g_test2',
402                '--manual-register',
403                '@INPUT@'])
404
405   test_resources_c = custom_target('test_resources.c',
406     input : 'test2.gresource.xml',
407     output : 'test_resources.c',
408     command : [glib_compile_resources,
409                '--target=@OUTPUT@',
410                '--sourcedir=' + meson.current_source_dir(),
411                '--generate-source',
412                '--c-name', '_g_test1',
413                '@INPUT@'])
414
415   # referenced by test.gresource.xml
416   test_generated_txt = configure_file(input : 'test1.txt',
417     output : 'test-generated.txt',
418     configuration : configuration_data(),
419     install : false)
420
421   exe = executable('resources', 'resources.c', test_gresource,
422       test_resources_c, test_resources2_c, test_resources2_h,
423       install : false,
424       c_args : test_c_args,
425       dependencies : common_gio_tests_deps)
426   test('resources', exe, env : test_env)
427 endif
428
429 # FIXME: subdir('services')
430 subdir('modules')