Imported Upstream version 2.59.0
[platform/upstream/glib.git] / glib / tests / meson.build
1 glib_tests = {
2   'array-test' : {},
3   'asyncqueue' : {},
4   'atomic' : {
5     'c_args' : cc.get_id() == 'gcc' ? ['-Wstrict-aliasing=2'] : [],
6   },
7   'base64' : {},
8   'bitlock' : {},
9   'bookmarkfile' : {},
10   'bytes' : {},
11   'cache' : {},
12   'charset' : {},
13   'checksum' : {},
14   'collate' : {},
15   'cond' : {},
16   'convert' : {},
17   'dataset' : {},
18   'date' : {},
19   'dir' : {},
20   'environment' : {},
21   'error' : {},
22   'fileutils' : {},
23   'gdatetime' : {
24     'suite' : ['slow'],
25   },
26   'guuid' : {},
27   'gvariant' : {
28     'suite' : ['slow'],
29   },
30   'gwakeup' : {
31     'source' : ['gwakeuptest.c', '../gwakeup.c'],
32     'install' : false,
33   },
34   'hash' : {},
35   'hmac' : {},
36   'hook' : {},
37   'hostutils' : {},
38   'keyfile' : {},
39   'list' : {},
40   'logging' : {},
41   'mainloop' : {},
42   'mappedfile' : {},
43   'markup' : {},
44   'markup-parse' : {},
45   'markup-collect' : {},
46   'markup-escape' : {},
47   'markup-subparser' : {},
48   'mem-overflow' : {},
49   'mutex' : {},
50   'node' : {},
51   'once' : {},
52   'option-context' : {},
53   'option-argv0' : {},
54   'overflow' : {},
55   'overflow-fallback' : {
56     'source' : 'overflow.c',
57     'c_args' : ['-D_GLIB_TEST_OVERFLOW_FALLBACK'],
58   },
59   'pattern' : {},
60   'private' : {},
61   'protocol' : {},
62   'queue' : {},
63   'rand' : {},
64   'rcbox' : {},
65   'rec-mutex' : {},
66   'refcount' : {},
67   'refcount-macro' : {
68     'source' : 'refcount.c',
69     'c_args' : ['-DG_DISABLE_CHECKS'],
70   },
71   'refstring' : {},
72   'regex' : {
73     'dependencies' : [pcre],
74     'c_args' : use_pcre_static_flag ? ['-DPCRE_STATIC'] : [],
75   },
76   'rwlock' : {},
77   'scannerapi' : {},
78   'search-utils' : {},
79   'sequence' : {
80     'suite' : ['slow'],
81   },
82   'shell' : {},
83   'slice' : {},
84   'slist' : {},
85   'sort' : {},
86   'spawn-multithreaded' : {},
87   'spawn-singlethread' : {},
88   'strfuncs' : {},
89   'string' : {},
90   'testing' : {},
91   'test-printf' : {},
92   'thread' : {},
93   'timeout' : {},
94   'timer' : {},
95   'tree' : {},
96   'utf8-performance' : {},
97   'utf8-pointer' : {},
98   'utf8-validate' : {},
99   'utf8-misc' : {},
100   'utils' : {},
101   'unicode' : {},
102   'uri' : {},
103   '1bit-mutex' : {},
104   '1bit-emufutex' : {
105     'source' : '1bit-mutex.c',
106     'c_args' : ['-DTEST_EMULATED_FUTEX'],
107     'install' : false,
108     'suite' : ['slow'],
109   },
110   '642026' : {
111     'suite' : ['slow'],
112   },
113   '642026-ec' : {
114     'source' : '642026.c',
115     'c_args' : ['-DG_ERRORCHECK_MUTEXES'],
116     'suite' : ['slow'],
117   },
118 }
119
120 if cc.get_id() != 'msvc'
121   glib_tests += {'autoptr' : {}}
122 endif
123
124 if glib_conf.has('HAVE_EVENTFD')
125   glib_tests += {
126     'gwakeup-fallback' : {
127       'source' : ['gwakeuptest.c', '../gwakeup.c'],
128       'c_args' : ['-DTEST_EVENTFD_FALLBACK'],
129       'install' : false,
130     },
131   }
132 endif
133
134 if host_machine.system() != 'windows'
135   glib_tests += {
136     'include' : {},
137     'unix' : {},
138   }
139 endif
140
141 if installed_tests_enabled
142   install_data(
143     'keyfiletest.ini',
144     'pages.ini',
145     'keyfile.c',
146     'empty',
147     '4096-random-bytes',
148     'echo-script',
149     'echo-script.bat',
150     install_dir : installed_tests_execdir,
151   )
152   install_subdir('bookmarks', install_dir : installed_tests_execdir)
153   install_subdir('markups', install_dir : installed_tests_execdir)
154 endif
155
156 # Not entirely random of course, but at least it changes over time
157 random_number = minor_version + meson.version().split('.').get(1).to_int()
158
159 test_env = environment()
160 test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
161 test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
162 test_env.set('G_DEBUG', 'gc-friendly')
163 test_env.set('MALLOC_CHECK_', '2')
164 test_env.set('MALLOC_PERTURB_', '@0@'.format(random_number % 256))
165
166 test_deps = [libm, thread_dep, libglib_dep]
167 test_cargs = ['-DG_LOG_DOMAIN="GLib"']
168
169 foreach test_name, extra_args : glib_tests
170   source = extra_args.get('source', test_name + '.c')
171   install = installed_tests_enabled and extra_args.get('install', true)
172
173   if install
174     test_conf = configuration_data()
175     test_conf.set('installed_tests_dir', installed_tests_execdir)
176     test_conf.set('program', test_name)
177     configure_file(
178       input: installed_tests_template_tap,
179       output: test_name + '.test',
180       install_dir: installed_tests_metadir,
181       configuration: test_conf
182     )
183   endif
184
185   exe = executable(test_name, source,
186     c_args : test_cargs + extra_args.get('c_args', []),
187     dependencies : test_deps + extra_args.get('dependencies', []),
188     install_dir: installed_tests_execdir,
189     install: install,
190   )
191
192   suite = ['glib'] + extra_args.get('suite', [])
193   timeout = suite.contains('slow') ? test_timeout_slow : test_timeout
194   test(test_name, exe, env : test_env, timeout : timeout, suite : suite,
195     args : ['--tap'])
196 endforeach
197
198 # test-spawn-echo helper binary required by the spawn tests above
199 executable('test-spawn-echo', 'test-spawn-echo.c',
200   c_args : test_cargs,
201   dependencies : test_deps,
202   install_dir: installed_tests_execdir,
203   install: installed_tests_enabled,
204 )
205
206 executable('testing-helper', 'testing-helper.c',
207   c_args : test_cargs,
208   dependencies : test_deps,
209   install_dir: installed_tests_execdir,
210   install: installed_tests_enabled,
211 )
212
213 # some testing of gtester functionality
214 if not meson.is_cross_build() and host_system != 'windows'
215   xmllint = find_program('xmllint', required: false)
216   if xmllint.found()
217     tmpsample_xml = custom_target('tmpsample.xml',
218       output : 'tmpsample.xml',
219       command : [ gtester, '-k', '--quiet', '-o', '@OUTPUT@',
220                   '--test-arg=--gtester-selftest', gtester])
221
222     test('gtester-xmllint-check', xmllint,
223       args : ['--noout', tmpsample_xml],
224       env : test_env,
225       suite : ['glib'],
226     )
227   endif
228 endif