summaryrefslogtreecommitdiff
path: root/tests/meson.build
blob: 96e45dc6de75ea7e0ec218eb68356b30e144b2cb (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
sources = files(
  'dconf-mock-dbus.c',
  'dconf-mock-gvdb.c',
  'dconf-mock-shm.c'
)

libdconf_mock = static_library(
  'dconf-mock',
  sources: sources,
  dependencies: glib_dep
)

envs = test_env + [
  'G_TEST_SRCDIR=' + meson.current_source_dir(),
  'G_TEST_BUILDDIR=' + meson.current_build_dir(),
]

test_dir = meson.current_source_dir()

dl_dep = cc.find_library('dl', required: false)
m_dep = cc.find_library('m')

unit_tests = [
  # [name, sources, c_args, dependencies, link_with]
  ['paths', 'paths.c', [], libdconf_common_dep, []],
  ['changeset', 'changeset.c', [], libdconf_common_dep, []],
  ['shm', ['shm.c', 'tmpdir.c'], [], [dl_dep, libdconf_common_dep, libdconf_shm_dep], []],
  ['gvdb', 'gvdb.c', '-DSRCDIR="@0@"'.format(test_dir), libgvdb_dep, []],
  ['gdbus-thread', 'dbus.c', '-DDBUS_BACKEND="/gdbus/thread"', libdconf_gdbus_thread_dep, []],
  ['gdbus-filter', 'dbus.c', '-DDBUS_BACKEND="/gdbus/filter"', libdconf_gdbus_filter_dep, []],
  ['engine', 'engine.c', '-DSRCDIR="@0@"'.format(test_dir), [dl_dep, libdconf_engine_dep, m_dep], libdconf_mock],
  ['client', 'client.c', '-DSRCDIR="@0@"'.format(test_dir), [libdconf_client_dep, libdconf_engine_dep], libdconf_mock]
]

foreach unit_test: unit_tests
  exe = executable(
    unit_test[0],
    unit_test[1],
    c_args: unit_test[2],
    dependencies: unit_test[3],
    link_with: unit_test[4]
  )

  test(unit_test[0], exe, is_parallel: false, env: envs)
endforeach