summaryrefslogtreecommitdiff
path: root/src/tests/meson.build
blob: ae8c0ca60bf7df0e3e8ddcff1b7cd89c0ff308b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
mutter_test_sources = [
  'meta-backend-test.c',
  'meta-backend-test.h',
  'meta-context-test.c',
  'meta-gpu-test.c',
  'meta-gpu-test.h',
  'meta-monitor-manager-test.c',
  'meta-monitor-manager-test.h',
  'meta-monitor-test-utils.c',
  'meta-monitor-test-utils.h',
  'meta-ref-test.c',
  'meta-ref-test.h',
  'meta-sensors-proxy-mock.c',
  'meta-sensors-proxy-mock.h',
  'meta-test-utils.c',
  'meta-test-utils.h',
]

libmutter_test_name = 'mutter-test-' + libmutter_api_version

clutter_test_utils = files (
  'clutter-test-utils.c',
  'clutter-test-utils.h',
)

tests_includepath = include_directories('.')
tests_includes = mutter_includes
tests_c_args = mutter_c_args

tests_deps = [
  mutter_deps,
  libmutter_dep,
  libmutter_cogl_dep,
  libmutter_clutter_dep,
]

libmutter_test = shared_library(libmutter_test_name,
                                mutter_test_sources,
                                gnu_symbol_visibility: 'hidden',
                                include_directories: tests_includes,
                                c_args: [
                                  tests_c_args,
                                  '-DG_LOG_DOMAIN="libmutter-test"',
                                ],
                                dependencies: tests_deps,
                                install_rpath: pkglibdir,
                                install_dir: libdir,
                                install: true,
)

libmutter_test_dep = declare_dependency(
  link_with: libmutter_test,
  include_directories: tests_includes,
  dependencies: tests_deps,
)

pkg.generate(libmutter_test,
  name: 'Meta (test framework)',
  filebase: 'libmutter-test-' + libmutter_api_version,
  description: 'Mutter test framework',
  subdirs: pkgname,
  requires: ['libmutter-' + libmutter_api_version],
  version: meson.project_version(),
  variables: [
    'apiversion=' + libmutter_api_version,
  ],
  install_dir: pcdir,
)

if have_clutter_tests
  subdir('clutter')
endif

subdir('meta-test')
subdir('wayland-test-clients')

if have_installed_tests
  stacking_files_datadir = join_paths(pkgdatadir, 'tests')

  installed_tests_cdata = configuration_data()
  installed_tests_cdata.set('libexecdir', libexecdir)
  installed_tests_cdata.set('apiversion', libmutter_api_version)

  configure_file(
    input: 'mutter-all.test.in',
    output: 'mutter-all.test',
    configuration: installed_tests_cdata,
    install: true,
    install_dir: mutter_installed_tests_datadir,
  )

  install_subdir('stacking', install_dir: stacking_files_datadir)
endif

test_env = environment()

test_env_variables = {
  'G_TEST_SRCDIR': join_paths(mutter_srcdir, 'src'),
  'G_TEST_BUILDDIR': mutter_builddir,
  'MUTTER_TEST_PLUGIN_PATH': '@0@'.format(default_plugin.full_path()),
}

foreach name, value: test_env_variables
  test_env.set(name, value)
endforeach

test_client = executable('mutter-test-client',
  sources: ['test-client.c'],
  include_directories: tests_includes,
  c_args: [
    tests_c_args,
    '-DG_LOG_DOMAIN="mutter-test-client"',
  ],
  dependencies: [
    gtk3_dep,
    gio_unix_dep,
    x11_dep,
    xext_dep,
  ],
  install: have_installed_tests,
  install_dir: mutter_installed_tests_libexecdir,
)

test_runner = executable('mutter-test-runner',
  sources: [
    'test-runner.c',
  ],
  include_directories: tests_includes,
  c_args: [
    tests_c_args,
    '-DG_LOG_DOMAIN="mutter-test-runner"',
  ],
  dependencies: libmutter_test_dep,
  install: have_installed_tests,
  install_dir: mutter_installed_tests_libexecdir,
)

meta_dbus_runner = find_program('meta-dbus-runner.py')

if have_installed_tests
  install_data('meta-dbus-runner.py',
    install_dir: mutter_installed_tests_libexecdir,
  )
  install_subdir('dbusmock-templates',
    install_dir: mutter_installed_tests_libexecdir,
  )
endif

wayland_test_utils = [
  'meta-wayland-test-driver.c',
  'meta-wayland-test-driver.h',
  'meta-wayland-test-utils.c',
  'meta-wayland-test-utils.h',
  test_driver_server_header,
  test_driver_protocol_code,
]

# The test_cases is a list of dictionaries each one representing one test case.
# It consists of the following keys:
#  - 'name' - the test name
#  - 'suite' - the test suite
#  - 'sources' - a list of source code files

test_cases = []
privileged_test_cases = []

test_cases += [
  {
    'name': 'unit',
    'suite': 'unit',
    'sources': [
      'unit-tests.c',
      'boxes-tests.c',
      'boxes-tests.h',
      'monitor-config-migration-unit-tests.c',
      'monitor-config-migration-unit-tests.h',
      'monitor-store-unit-tests.c',
      'monitor-store-unit-tests.h',
      'monitor-transform-tests.c',
      'monitor-transform-tests.h',
      'orientation-manager-unit-tests.c',
    ],
  },
  {
    'name': 'monitor-unit',
    'suite': 'backend',
    'sources': [ 'monitor-unit-tests.c', ],
  },
  {
    'name': 'headless-start',
    'suite': 'backend',
    'sources': [ 'headless-start-test.c', ],
  },
  {
    'name': 'stage-views',
    'suite': 'compositor',
    'sources': [ 'stage-view-tests.c', ],
  },
  {
    'name': 'anonymous-file',
    'suite': 'unit',
    'sources': [ 'anonymous-file.c', ],
  },
]

if have_native_tests
  screen_cast_client = executable('mutter-screen-cast-client',
    sources: [
      'screen-cast-client.c',
      dbus_remote_desktop_built_sources,
      dbus_screen_cast_built_sources,
    ],
    include_directories: tests_includes,
    c_args: [
      tests_c_args,
      '-DG_LOG_DOMAIN="mutter-screen-cast-client"',
    ],
    dependencies: [
      gio_dep,
      libpipewire_dep,
    ],
    install: have_installed_tests,
    install_dir: mutter_installed_tests_libexecdir,
  )

  # Native backend tests
  test_cases += [
    {
      'name': 'kms-utils',
      'suite': 'backends/native',
      'sources': [ 'kms-utils-unit-tests.c', ],
    },
    {
      'name': 'native-unit',
      'suite': 'backends/native',
      'sources': [
        'native-headless.c',
        'native-screen-cast.c',
        'native-screen-cast.h',
        'native-virtual-monitor.c',
        'native-virtual-monitor.h',
      ],
    },
    {
      'name': 'pointer-constraints',
      'suite': 'backends/native',
      'sources': [ 'native-pointer-constraints.c' ],
    },
    {
      'name': 'ref-test-sanity',
      'suite': 'backends/native',
      'sources': [ 'ref-test-sanity.c' ],
    },
    {
      'name': 'persistent-virtual-monitor',
      'suite': 'backends/native',
      'sources': [ 'native-persistent-virtual-monitor.c' ],
    },
  ]

  # Privileged tests
  privileged_test_cases += [
    {
      'name': 'kms-render',
      'suite': 'backends/native/kms',
      'sources': [ 'native-kms-render.c' ],
    },
    {
      'name': 'kms-device',
      'suite': 'backends/native/kms',
      'sources': [
        'meta-kms-test-utils.c',
        'meta-kms-test-utils.h',
        'native-kms-device.c',
      ],
    },
    {
      'name': 'kms-update',
      'suite': 'backends/native/kms',
      'sources': [
        'meta-kms-test-utils.c',
        'meta-kms-test-utils.h',
        'native-kms-updates.c',
      ],
    },
  ]

  # Wayland tests
  test_cases += [
    {
      'name': 'wayland-unit',
      'suite': 'wayland',
      'sources': [
        'wayland-unit-tests.c',
        wayland_test_utils,
      ],
    },
    {
      'name': 'xwayland',
      'suite': 'wayland',
      'sources': [
        'xwayland-tests.c',
      ],
    },
  ]

  foreach test_case: test_cases
    test_executable = executable('mutter-' + test_case['name'],
      sources: test_case['sources'],
      include_directories: tests_includes,
      c_args: [
        tests_c_args,
        '-DG_LOG_DOMAIN="mutter-@0@-test"'.format(test_case['name']),
      ],
      dependencies: libmutter_test_dep,
      install: have_installed_tests,
      install_dir: mutter_installed_tests_libexecdir,
    )

    test(test_case['name'], test_executable,
      suite: ['core', 'mutter/' + test_case['suite']],
      env: test_env,
      is_parallel: false,
      timeout: 60,
    )
  endforeach
endif

stacking_tests = [
  'basic-x11',
  'basic-wayland',
  'client-side-decorated',
  'closed-transient',
  'closed-transient-no-default-focus',
  'closed-transient-no-input-no-take-focus-parent',
  'closed-transient-no-input-no-take-focus-parents',
  'closed-transient-no-input-parent',
  'closed-transient-no-input-parent-delayed-focus-default-cancelled',
  'closed-transient-no-input-parents',
  'closed-transient-no-input-parents-queued-default-focus-destroyed',
  'closed-transient-only-take-focus-parents',
  'minimized',
  'mixed-windows',
  'set-parent',
  'override-redirect',
  'set-override-redirect-parent',
  'set-parent-exported',
  'restore-size',
  'unmaximize-new-size',
  'fullscreen-maximize',
  'unfullscreen-strut-change',
  'restore-position',
  'default-size',
  'modals',
  'map-fixed-size',
  'client-resize-respect-constraints',
  'map-on-hotplug',
]

foreach stacking_test: stacking_tests
  test(stacking_test, test_runner,
    suite: ['core', 'mutter/stacking'],
    env: test_env,
    args: [
      files(join_paths('stacking', stacking_test + '.metatest')),
    ],
    is_parallel: false,
    timeout: 60,
  )
endforeach

if have_kvm_tests or have_tty_tests
  privileged_tests = []
  foreach test_case: privileged_test_cases
    test_executable = executable('mutter-' + test_case['name'],
      sources: test_case['sources'],
      include_directories: tests_includes,
      c_args: [
        tests_c_args,
        '-DG_LOG_DOMAIN="mutter-@0@-test"'.format(test_case['name']),
      ],
      dependencies: libmutter_test_dep,
      install: have_installed_tests,
      install_dir: mutter_installed_tests_libexecdir,
    )
    privileged_tests += [
      {
        'name': test_case['name'],
        'suite': test_case['suite'],
        'executable': test_executable,
      },
    ]
  endforeach

  if have_kvm_tests
    subdir('kvm')
  endif

  if have_tty_tests
    foreach test_case: privileged_tests
      test('tty-' + test_case['name'], test_case['executable'],
        suite: ['core', 'mutter/tty', 'mutter/tty/' + test_case['suite']],
        env: test_env,
        is_parallel: false,
        timeout: 60,
      )
    endforeach
  endif
endif