xref: /openbmc/phosphor-networkd/test/meson.build (revision c38b07102f67751ebd6aa46814c9d65c36b89812)
1gtest = dependency('gtest', main: true, disabler: true, required: false)
2gmock = dependency('gmock', disabler: true, required: false)
3if not gtest.found() or not gmock.found()
4  gtest_opts = import('cmake').subproject_options()
5  gtest_opts.add_cmake_defines({'CMAKE_CXX_FLAGS': '-Wno-pedantic'})
6  gtest_proj = import('cmake').subproject(
7    'googletest',
8    options: gtest_opts,
9    required: false)
10  if gtest_proj.found()
11    gtest = declare_dependency(
12      dependencies: [
13        dependency('threads'),
14        gtest_proj.dependency('gtest'),
15        gtest_proj.dependency('gtest_main'),
16      ])
17    gmock = gtest_proj.dependency('gmock')
18  else
19    assert(not get_option('tests').enabled(), 'Googletest is required')
20  endif
21endif
22
23test_headers = include_directories('.')
24
25test_deps = [
26  meson.get_compiler('cpp').find_library('dl'),
27  networkd_dep,
28  gtest,
29  gmock,
30  dependency('stdplus-gtest'),
31]
32
33test_lib = static_library(
34  'networkd-test',
35  'mock_syscall.cpp',
36  'global_network_objects.cpp',
37  implicit_include_directories: false,
38  include_directories: test_headers,
39  dependencies: test_deps)
40
41test_dep = declare_dependency(
42  dependencies: test_deps,
43  include_directories: test_headers,
44  link_with: test_lib)
45
46tests = [
47  'config_parser',
48  'ethernet_interface',
49  'neighbor',
50  'netlink',
51  'network_manager',
52  #'rtnetlink',
53  'util',
54  'vlan_interface',
55]
56
57run_with_tmp = find_program('run_with_tmp', native: true)
58
59foreach t : tests
60  test(
61    t,
62    run_with_tmp,
63    args: executable(
64      t.underscorify(),
65      'test_' + t + '.cpp',
66      implicit_include_directories: false,
67      dependencies: test_dep),
68    env: {'TMPTMPL': 'phosphor-networkd-test.XXXXXXXXXX'})
69endforeach
70
71if (get_option('hyp-nw-config') == true)
72  subdir('ibm/hypervisor-network-mgr-test')
73endif
74