• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1marshalers_h = custom_target('marshalers_h',
2  output : 'marshalers.h',
3  input : 'marshalers.list',
4  command : [
5    python, glib_genmarshal,
6    '--prefix=test',
7    '--valist-marshallers',
8    '--output=@OUTPUT@',
9    '--quiet',
10    '--header',
11    '@INPUT@',
12  ],
13)
14marshalers_c = custom_target('marshalers_c',
15  output : 'marshalers.c',
16  input : 'marshalers.list',
17  command : [
18    python, glib_genmarshal,
19    '--prefix=test',
20    '--valist-marshallers',
21    '--include-header=marshalers.h',
22    '--output=@OUTPUT@',
23    '--quiet',
24    '--body',
25    '@INPUT@',
26  ],
27)
28
29gobject_tests = {
30  'qdata' : {},
31  'boxed' : {},
32  'enums' : {},
33  'param' : {},
34  'threadtests' : {},
35  'dynamictests' : {},
36  'binding' : {},
37  'properties' : {},
38  'reference' : {},
39  'flags' : {},
40  'value' : {},
41  'type' : {},
42  'gobject-private' : {
43    'source' : 'private.c',
44  },
45  'closure' : {},
46  'closure-refcount' : { 'suite': ['slow'] },
47  'object' : {},
48  'signal-handler' : {},
49  'ifaceproperties' : {},
50  'signals' : {
51    'source' : ['signals.c', marshalers_h, marshalers_c],
52  },
53}
54
55if cc.get_id() != 'msvc'
56  gobject_tests += {'autoptr' : {}}
57endif
58
59python_tests = [
60  'genmarshal.py',
61  'mkenums.py',
62]
63
64# FIXME: put common bits of test environment() in one location
65# Not entirely random of course, but at least it changes over time
66random_number = minor_version + meson.version().split('.').get(1).to_int()
67
68test_env = environment()
69test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
70test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
71test_env.set('G_DEBUG', 'gc-friendly')
72test_env.set('MALLOC_CHECK_', '2')
73test_env.set('MALLOC_PERTURB_', '@0@'.format(random_number % 256))
74
75test_deps = [libm, thread_dep, libglib_dep, libgobject_dep]
76test_cargs = ['-DG_LOG_DOMAIN="GLib-GObject"', '-UG_DISABLE_ASSERT']
77
78foreach test_name, extra_args : gobject_tests
79  source = extra_args.get('source', test_name + '.c')
80  install = installed_tests_enabled and extra_args.get('install', true)
81
82  if install
83    test_conf = configuration_data()
84    test_conf.set('installed_tests_dir', installed_tests_execdir)
85    test_conf.set('program', test_name)
86    test_conf.set('env', '')
87    configure_file(
88      input: installed_tests_template_tap,
89      output: test_name + '.test',
90      install_dir: installed_tests_metadir,
91      configuration: test_conf
92    )
93  endif
94
95  exe = executable(test_name, source,
96    c_args : test_cargs + extra_args.get('c_args', []),
97    dependencies : test_deps + extra_args.get('dependencies', []),
98    install_dir: installed_tests_execdir,
99    install: install,
100  )
101
102  suite = ['gobject'] + extra_args.get('suite', [])
103  timeout = suite.contains('slow') ? test_timeout_slow : test_timeout
104
105  # FIXME: https://gitlab.gnome.org/GNOME/glib/issues/1316
106  # aka https://bugs.debian.org/880883
107  if test_name == 'closure-refcount' and ['arm', 'aarch64'].contains(host_cpu_family)
108    timeout = timeout * 10
109  endif
110
111  test(test_name, exe, env : test_env, timeout : timeout, suite : suite)
112endforeach
113
114foreach test_name : python_tests
115  test(
116    test_name,
117    python,
118    args: ['-B', files(test_name)],
119    env: test_env,
120    suite: ['gobject', 'no-valgrind'],
121  )
122
123  if installed_tests_enabled
124    install_data(
125      files(test_name),
126      install_dir: installed_tests_execdir,
127      install_mode: 'rwxr-xr-x',
128    )
129
130    test_conf = configuration_data()
131    test_conf.set('installed_tests_dir', installed_tests_execdir)
132    test_conf.set('program', test_name)
133    test_conf.set('env', '')
134    configure_file(
135      input: installed_tests_template_tap,
136      output: test_name + '.test',
137      install_dir: installed_tests_metadir,
138      configuration: test_conf,
139    )
140  endif
141endforeach
142
143# TAP test runner for Python tests
144if installed_tests_enabled
145  install_data(
146    files('taptestrunner.py'),
147    install_dir: installed_tests_execdir,
148  )
149endif
150