gkdbus: Fix underflow and unreachable code bug
[platform/upstream/glib.git] / gobject / tests / meson.build
1 subdir('performance')
2
3 marshalers_h = custom_target('marshalers_h',
4   output : 'marshalers.h',
5   input : 'marshalers.list',
6   command : [
7     python, glib_genmarshal,
8     '--prefix=test',
9     '--valist-marshallers',
10     '--output=@OUTPUT@',
11     '--quiet',
12     '--header',
13     '@INPUT@',
14   ],
15 )
16 marshalers_c = custom_target('marshalers_c',
17   output : 'marshalers.c',
18   input : 'marshalers.list',
19   command : [
20     python, glib_genmarshal,
21     '--prefix=test',
22     '--valist-marshallers',
23     '--include-header=marshalers.h',
24     '--output=@OUTPUT@',
25     '--quiet',
26     '--body',
27     '@INPUT@',
28   ],
29 )
30
31 # We must embed custom-dispatch.exe with an application
32 # manifest to pacify UAC in order to run on 32-bit Windows
33 # builds, otherwise the test will not run as UAC will kill it.
34 extra_custom_dispatch_objs = []
35 if embed_uac_manifest
36   uac_exe_pkg = 'gobject'
37   uac_exe_name = 'custom-dispatch'
38
39   # Well, we have to forgo the xxx.exe.manifest in the output listing, since
40   # compile_resources doesn't like to consume targets with multiple outputs,
41   # and the xxx.exe.manifest and xxx.rc are tied together
42   uac_rc = custom_target(
43     '@0@.rc'.format(uac_exe_name),
44     output: ['@0@.rc'.format(uac_exe_name)],
45     command: [gen_uac_manifest,
46               '-p=@0@'.format(uac_exe_pkg),
47               '-n=@0@'.format(uac_exe_name),
48               '--pkg-version=@0@'.format(meson.project_version()),
49               '--output-dir=@OUTDIR@'],
50   )
51   extra_custom_dispatch_objs = import('windows').compile_resources(uac_rc)
52 endif
53
54 gobject_tests = {
55   'notify-init' : {},
56   'notify-init2' : {},
57   'custom-dispatch' : {
58     'extra_objs' : extra_custom_dispatch_objs,
59   },
60   'qdata' : {},
61   'accumulator' : {
62     'source' : ['accumulator.c', marshalers_h, marshalers_c],
63   },
64   'basics-gobject' : {},
65   'boxed' : {},
66   'defaultiface' : {
67     'source' : ['defaultiface.c', 'testmodule.c'],
68   },
69   'deftype' : { 'protocol': 'exitcode' },
70   'deprecated-properties' : {},
71   'dynamictype' : {
72     'source' : ['dynamictype.c', 'testmodule.c'],
73   },
74   'enums' : {},
75   'max-version' : {'install': false},
76   'override' : {},
77   'param' : {},
78   'references' : {},
79   'basic-signals' : {},
80   'singleton' : {},
81   'threadtests' : {},
82   'dynamictests' : {},
83   'binding' : {},
84   'bindinggroup' : {},
85   'properties' : {},
86   'reference' : {},
87   'flags' : {},
88   'value' : {},
89   'type' : {},
90   'gobject-private' : {
91     'source' : 'private.c',
92   },
93   'closure' : {},
94   'closure-refcount' : { 'suite': ['slow'] },
95   'object' : {},
96   'signal-handler' : {},
97   'ifaceproperties' : {},
98   'signals' : {
99     'source' : ['signals.c', marshalers_h, marshalers_c],
100   },
101   'signalgroup' : {},
102   'testing' : {},
103   'type-flags' : {},
104   'objects-refcount1' : {
105     'c_args': cc.get_supported_arguments([
106       '-DG_DISABLE_CAST_CHECKS',
107       '-Werror',
108       '-Wcast-align=strict',
109     ]),
110   },
111   'objects-refcount2' : {'suite' : ['slow']},
112   'properties-refcount1' : {},
113   'properties-refcount2' : {'suite' : ['slow']},
114   'properties-refcount3' : {'suite' : ['slow']},
115   'properties-refcount4' : {},
116   'signals-refcount1' : {
117     'source' : 'signals-refcount.c',
118     'c_args' : ['-DTESTNUM=1'],
119   },
120   'signals-refcount2' : {
121     'source' : 'signals-refcount.c',
122     'c_args' : ['-DTESTNUM=2'],
123   },
124   'signals-refcount3' : {
125     'source' : 'signals-refcount.c',
126     'c_args' : ['-DTESTNUM=3'],
127   },
128   'signals-refcount4' : {
129     'source' : 'signals-refcount.c',
130     'c_args' : ['-DTESTNUM=4'],
131   },
132 }
133
134 if have_cxx
135   gobject_tests += {
136     'cxx' : {
137       'protocol': 'exitcode',
138       'source' : ['cxx.cpp'],
139       'suite' : ['cpp'],
140     },
141   }
142
143   foreach std, arg: cxx_standards
144     gobject_tests += {
145       'cxx-@0@'.format(std) : {
146         'protocol': 'exitcode',
147         'source' : ['cxx.cpp'],
148         'suite' : ['cpp'],
149         'cpp_args' : [arg],
150       },
151     }
152   endforeach
153 endif
154
155 if cc.get_id() != 'msvc'
156   gobject_tests += {'autoptr' : {}}
157 endif
158
159 python_tests = {
160   'genmarshal.py' : {},
161   'gobject-query.py' : {
162     'depends' : gobject_query,
163     'can_fail' : host_system == 'windows',
164   },
165   'mkenums.py' : {},
166 }
167
168 test_env = environment()
169 test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
170 test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
171
172 test_deps = [libm, thread_dep, libglib_dep, libgobject_dep]
173 test_cargs = ['-DG_LOG_DOMAIN="GLib-GObject"', '-UG_DISABLE_ASSERT']
174 test_cpp_args = test_cargs
175
176 foreach test_name, extra_args : gobject_tests
177   source = extra_args.get('source', test_name + '.c')
178   extra_objs = extra_args.get('extra_objs', [])
179   install = installed_tests_enabled and extra_args.get('install', true)
180
181   if install
182     test_conf = configuration_data()
183     test_conf.set('installed_tests_dir', installed_tests_execdir)
184     test_conf.set('program', test_name)
185     test_conf.set('env', '')
186     configure_file(
187       input: installed_tests_template_tap,
188       output: test_name + '.test',
189       install_dir: installed_tests_metadir,
190       install_tag: 'tests',
191       configuration: test_conf
192     )
193   endif
194
195   exe = executable(test_name, source, extra_objs,
196     c_args : test_cargs + extra_args.get('c_args', []),
197     cpp_args : test_cpp_args + extra_args.get('cpp_args', []),
198     dependencies : test_deps + extra_args.get('dependencies', []),
199     install_dir: installed_tests_execdir,
200     install_tag: 'tests',
201     install: install,
202   )
203
204   suite = ['gobject'] + extra_args.get('suite', [])
205   timeout = suite.contains('slow') ? test_timeout_slow : test_timeout
206
207   if extra_args.get('can_fail', false)
208     suite += 'failing'
209   endif
210
211   # FIXME: https://gitlab.gnome.org/GNOME/glib/issues/1316
212   # aka https://bugs.debian.org/880883
213   if test_name == 'closure-refcount' and ['arm', 'aarch64'].contains(host_machine.cpu_family())
214     timeout = timeout * 10
215   endif
216
217   test(test_name,
218     exe,
219     protocol : extra_args.get('protocol', test_protocol),
220     env : test_env,
221     timeout : timeout,
222     suite : suite,
223   )
224 endforeach
225
226 foreach test_name, extra_args : python_tests
227   depends = [extra_args.get('depends', [])]
228   suite = ['gobject', 'no-valgrind']
229
230   if extra_args.get('can_fail', false)
231     suite += 'failing'
232   endif
233
234   test(
235     test_name,
236     python,
237     protocol : extra_args.get('protocol', test_protocol),
238     depends: depends,
239     args: ['-B', files(test_name)],
240     env: test_env,
241     suite: suite,
242   )
243
244   if installed_tests_enabled
245     install_data(
246       files(test_name),
247       install_dir: installed_tests_execdir,
248       install_tag: 'tests',
249       install_mode: 'rwxr-xr-x',
250     )
251
252     test_conf = configuration_data()
253     test_conf.set('installed_tests_dir', installed_tests_execdir)
254     test_conf.set('program', test_name)
255     test_conf.set('env', '')
256     configure_file(
257       input: installed_tests_template_tap,
258       output: test_name + '.test',
259       install_dir: installed_tests_metadir,
260       install_tag: 'tests',
261       configuration: test_conf,
262     )
263   endif
264 endforeach
265
266 # TAP test runner for Python tests
267 if installed_tests_enabled
268   install_data(
269     files('taptestrunner.py'),
270     install_dir: installed_tests_execdir,
271     install_tag: 'tests',
272   )
273 endif