Imported Upstream version 2.53.5
[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 dbus1_dep.found()
84   glib_conf.set('HAVE_DBUS1', 1)
85
86   exe = executable('gdbus-serialization',
87       'gdbus-serialization.c', 'gdbus-tests.c',
88       install : false,
89       c_args : test_c_args,
90       dependencies : common_gio_tests_deps + [dbus1_dep])
91   test('gdbus-serialization', exe, env : test_env)
92 endif
93
94 #  Test programs buildable on UNIX only
95 if host_machine.system() != 'windows'
96   gio_tests += [
97     'file',
98     'gdbus-peer',
99     'gdbus-peer-object-manager',
100     'live-g-file',
101     'socket-address',
102     'stream-rw_all',
103     'unix-fd',
104     'unix-streams',
105     'gschema-compile',
106   ]
107
108   # Uninstalled because of the check-for-executable logic in DesktopAppInfo
109   # unable to find the installed executable
110   if not glib_have_cocoa
111     gio_tests += [
112       'appinfo',
113       'desktop-app-info',
114     ]
115   endif
116
117   test_extra_programs += [
118     ['basic-application'],
119     ['dbus-launch'],
120     ['appinfo-test'],
121   ]
122
123   if not glib_have_cocoa
124     test_extra_programs += [['apps']]
125     gio_tests += ['mimeapps']
126   endif
127
128   #  Test programs that need to bring up a session bus (requires dbus-daemon)
129   have_dbus_daemon = find_program('dbus-daemon', required : false).found()
130   if have_dbus_daemon
131     # Generate gdbus-test-codegen-generated.{c,h}
132     gdbus_test_codegen_generated = custom_target('gdbus-test-codegen-generated',
133         input :   ['test-codegen.xml'],
134         output :  ['gdbus-test-codegen-generated.h',
135                    'gdbus-test-codegen-generated.c'],
136         command : [python, gdbus_codegen,
137                    '--interface-prefix', 'org.project.',
138                    '--output-directory', '@OUTDIR@',
139                    '--generate-c-code', 'gdbus-test-codegen-generated',
140                    '--c-generate-object-manager',
141                    '--c-namespace', 'Foo_iGen',
142                    '--generate-docbook', 'gdbus-test-codegen-generated-doc',
143                    '--annotate', 'org.project.Bar', 'Key1', 'Value1',
144                    '--annotate', 'org.project.Bar', 'org.gtk.GDBus.Internal', 'Value2',
145                    '--annotate', 'org.project.Bar.HelloWorld()', 'Key3', 'Value3',
146                    '--annotate', 'org.project.Bar::TestSignal', 'Key4', 'Value4',
147                    '--annotate', 'org.project.Bar:ay', 'Key5', 'Value5',
148                    '--annotate', 'org.project.Bar.TestPrimitiveTypes()[val_int32]', 'Key6', 'Value6',
149                    '--annotate', 'org.project.Bar.TestPrimitiveTypes()[ret_uint32]', 'Key7', 'Value7',
150                    '--annotate', 'org.project.Bar::TestSignal[array_of_strings]', 'Key8', 'Value8',
151                    '@INPUT@'])
152
153     gio_dbus_tests = [
154       ['actions', [], []],
155       ['gdbus-auth', [], []],
156       ['gdbus-bz627724', [], []],
157       ['gdbus-close-pending', [], []],
158       ['gdbus-connection', [], []],
159       ['gdbus-connection-loss', [], []],
160       ['gdbus-connection-slow', [], []],
161       ['gdbus-error', [], []],
162       ['gdbus-exit-on-close', [], []],
163       ['gdbus-export', [], []],
164       ['gdbus-introspection', [], []],
165       ['gdbus-names', [], []],
166       ['gdbus-proxy', [], []],
167       ['gdbus-proxy-threads', [], [dbus1_dep]],
168       ['gdbus-proxy-well-known-name', [], []],
169       ['gdbus-test-codegen', [gdbus_test_codegen_generated], []],
170       ['gdbus-threading', [], []],
171       ['gmenumodel', [], []],
172       ['gnotification', ['gnotification-server.c'], []],
173     ]
174
175     if not glib_have_cocoa
176       gio_dbus_tests = [['dbus-appinfo', [], []]]
177     endif
178
179     # separate loop because extra source files for each test
180     foreach dbus_test : gio_dbus_tests
181       test_name = dbus_test[0]
182       extra_src = dbus_test[1]
183       extra_deps = dbus_test[2]
184       exe = executable(test_name, '@0@.c'.format(test_name),
185           'gdbus-sessionbus.c', 'gdbus-tests.c', extra_src,
186           install : false,
187           c_args : test_c_args,
188           dependencies : common_gio_tests_deps + extra_deps)
189       test(test_name, exe, env : test_env)
190     endforeach
191
192     exe = executable('gdbus-test-codegen-old', 'gdbus-test-codegen.c',
193           'gdbus-sessionbus.c', 'gdbus-tests.c', gdbus_test_codegen_generated,
194           install : false,
195           c_args : test_c_args + ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36', '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36'],
196           dependencies : common_gio_tests_deps)
197     test('gdbus-test-codegen-old', exe, env : test_env)
198
199     # There is already a gapplication exe target in gio so need to use a
200     # different name for the unit test executable, since we can't have two
201     # targets of the same name even if in different directories
202     # (FIXME: just rename source file to gapplication-test.c)
203     if not glib_have_cocoa
204       exe = executable('gapplication-test', 'gapplication.c',
205                        'gdbus-sessionbus.c', 'gdbus-tests.c',
206                        install : false,
207                        c_args : test_c_args,
208                        dependencies : common_gio_tests_deps)
209     endif
210     test('gapplication', exe, env : test_env)
211
212     gio_tests += ['gdbus-unix-addresses']
213   endif # have_dbus_daemon
214
215   # This test is currently unreliable
216   executable('gdbus-overflow', 'gdbus-overflow.c',
217       install : false,
218       c_args : test_c_args,
219       dependencies : common_gio_tests_deps)
220
221   exe = executable('gdbus-connection-flush', 'gdbus-connection-flush.c',
222       'test-io-stream.c', 'test-pipe-unix.c',
223       install : false,
224       c_args : test_c_args,
225       dependencies : common_gio_tests_deps)
226   test('gdbus-connection-flush', exe, env : test_env)
227
228   exe = executable('gdbus-non-socket', 'gdbus-non-socket.c',
229       'gdbus-tests.c', 'test-io-stream.c', 'test-pipe-unix.c',
230       install : false,
231       c_args : test_c_args,
232       dependencies : common_gio_tests_deps)
233   test('gdbus-non-socket', exe, env : test_env)
234
235   # Generate test.mo from de.po using msgfmt
236   msgfmt = find_program('msgfmt', required : false)
237   if msgfmt.found()
238     subdir('de/LC_MESSAGES')
239     # gsettings target exe already exists in gio directory
240     exe = executable('gsettings-test', 'gsettings.c', test_mo,
241         install : false,
242         c_args : test_c_args + [
243                    '-DSRCDIR="@0@"'.format(meson.current_source_dir()),
244                    '-DTEST_LOCALE_PATH="@0@"'.format(test_mo_dir),
245                  ],
246         dependencies : common_gio_tests_deps)
247     test('gsettings', exe, env : test_env)
248   endif
249 endif # unix
250
251 #  Test programs buildable on Windows only
252 if host_machine.system() == 'windows'
253   gio_tests += ['win32-streams']
254 endif
255
256 if cc.get_id() != 'msvc'
257   gio_tests += [ 'autoptr' ]
258 endif
259
260 foreach test_name : gio_tests
261   extra_deps = []
262   srcs = ['@0@.c'.format(test_name)]
263   # conflicts with glib/tests/autoptr, can't have two targets with same name
264   if test_name == 'autoptr'
265     test_name = 'autoptr-gio'
266   elif test_name == 'defaultvalue'
267     srcs += [giotypefuncs_inc]
268   elif test_name == 'gdbus-peer'
269     # This is peer to peer so it doesn't need a session bus, so we can run
270     # it automatically as a test by default
271     extra_deps = [libgdbus_example_objectmanager_dep]
272   endif
273   exe = executable(test_name, srcs,
274       install : false,
275       c_args : test_c_args,
276       dependencies : common_gio_tests_deps + extra_deps)
277   if test_name == 'testfilemonitor'
278     test(test_name, exe, env : test_env, timeout : 45)
279   else
280     test(test_name, exe, env : test_env)
281   endif
282 endforeach
283
284 uninstalled_test_extra_programs = [
285   ['gio-du'],
286   ['echo-server'],
287   ['filter-cat'],
288   ['gapplication-example-actions'],
289   ['gapplication-example-cmdline'],
290   ['gapplication-example-cmdline2'],
291   ['gapplication-example-cmdline3'],
292   ['gapplication-example-dbushooks'],
293   ['gapplication-example-open'],
294   ['gdbus-daemon', gdbus_daemon_sources],
295   ['gdbus-example-export'],
296   ['gdbus-example-own-name'],
297   ['gdbus-example-peer'],
298   ['gdbus-example-proxy-subclass'],
299   ['gdbus-example-server'],
300   ['gdbus-example-subtree'],
301   ['gdbus-example-watch-name'],
302   ['gdbus-example-watch-proxy'],
303   ['gsubprocess-testprog'],
304   ['httpd'],
305   ['proxy'],
306   ['resolver'],
307   ['send-data'],
308   ['socket-server'],
309   ['socket-client', ['gtlsconsoleinteraction.c']],
310   ['tls-certificate', ['gtesttlsbackend.c']],
311   ['tls-interaction', ['gtesttlsbackend.c']],
312   # These three are manual-run tests because they need a session bus but don't bring one up themselves
313   # FIXME: these build but don't seem to work!
314   ['gdbus-example-objectmanager-client', [], [libgdbus_example_objectmanager_dep]],
315   ['gdbus-example-objectmanager-server', [], [libgdbus_example_objectmanager_dep]],
316   ['gdbus-test-fixture', [], [libgdbus_example_objectmanager_dep]],
317 ]
318
319 if host_machine.system() != 'windows'
320   uninstalled_test_extra_programs += [['gdbus-example-unix-fd-client']]
321 endif
322
323 foreach extra_program : uninstalled_test_extra_programs + test_extra_programs
324   srcs = ['@0@.c'.format(extra_program[0])]
325   if extra_program.length() > 1
326     srcs += extra_program[1]
327   endif
328   extra_deps = []
329   if extra_program.length() > 2
330     extra_deps = extra_program[2]
331   endif
332   executable(extra_program[0], srcs,
333       install : false,
334       c_args : test_c_args,
335       dependencies : common_gio_tests_deps + extra_deps)
336 endforeach
337
338 if not meson.is_cross_build() or meson.has_exe_wrapper()
339
340   plugin_resources_c = custom_target('plugin-resources.c',
341     input : 'test4.gresource.xml',
342     output : 'plugin-resources.c',
343     command : [glib_compile_resources,
344                '--target=@OUTPUT@',
345                '--sourcedir=' + meson.current_source_dir(),
346                '--generate-source',
347                '--c-name', '_g_plugin',
348                '@INPUT@'])
349
350   if host_system == 'windows'
351     resource_plugin_platform_link_args = ['-no-undefined']
352   else
353     resource_plugin_platform_link_args = []
354   endif
355   shared_module ('resourceplugin', 'resourceplugin.c', plugin_resources_c,
356     link_args : ['-export-dynamic'] + resource_plugin_platform_link_args,
357     dependencies : common_gio_tests_deps)
358
359   test_gresource = custom_target('test.gresource',
360     input : 'test.gresource.xml',
361     output : 'test.gresource',
362     command : [glib_compile_resources,
363                '--target=@OUTPUT@',
364                '--sourcedir=' + meson.current_source_dir(),
365                '--sourcedir=' + meson.current_build_dir(),
366                '@INPUT@'])
367
368   test_resources2_c = custom_target('test_resources2.c',
369     input : 'test3.gresource.xml',
370     output : 'test_resources2.c',
371     command : [glib_compile_resources,
372                '--target=@OUTPUT@',
373                '--sourcedir=' + meson.current_source_dir(),
374                '--generate',
375                '--c-name', '_g_test2',
376                '--manual-register',
377                '@INPUT@'])
378
379   test_resources2_h = custom_target('test_resources2.h',
380     input : 'test3.gresource.xml',
381     output : 'test_resources2.h',
382     command : [glib_compile_resources,
383                '--target=@OUTPUT@',
384                '--sourcedir=' + meson.current_source_dir(),
385                '--generate',
386                '--c-name', '_g_test2',
387                '--manual-register',
388                '@INPUT@'])
389
390   test_resources_c = custom_target('test_resources.c',
391     input : 'test2.gresource.xml',
392     output : 'test_resources.c',
393     command : [glib_compile_resources,
394                '--target=@OUTPUT@',
395                '--sourcedir=' + meson.current_source_dir(),
396                '--generate-source',
397                '--c-name', '_g_test1',
398                '@INPUT@'])
399
400   # referenced by test.gresource.xml
401   test_generated_txt = configure_file(input : 'test1.txt',
402     output : 'test-generated.txt',
403     configuration : configuration_data(),
404     install : false)
405
406   exe = executable('resources', 'resources.c', test_gresource,
407       test_resources_c, test_resources2_c, test_resources2_h,
408       install : false,
409       c_args : test_c_args,
410       dependencies : common_gio_tests_deps)
411   test('resources', exe, env : test_env)
412 endif
413
414 # FIXME: subdir('services')
415 subdir('modules')