blob: 651f54290413fab052b42eabc099a689404ade13 [file] [log] [blame]
William A. Kennington III0a01b2a2021-05-13 18:38:57 -07001gtest = 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
William A. Kennington IIIfc3aff92021-05-29 15:09:58 -070019 assert(not get_option('tests').enabled(), 'Googletest is required')
William A. Kennington III0a01b2a2021-05-13 18:38:57 -070020 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,
William A. Kennington III84bfe672022-07-13 14:15:30 -070030 dependency('stdplus-gtest'),
William A. Kennington III0a01b2a2021-05-13 18:38:57 -070031]
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',
William A. Kennington IIIc2e5e0e2019-04-22 01:26:06 -070049 'ipaddress',
William A. Kennington III0a01b2a2021-05-13 18:38:57 -070050 'neighbor',
51 'netlink',
52 'network_manager',
53 #'rtnetlink',
William A. Kennington IIIfd862be2022-10-09 18:40:55 -070054 'system_queries',
William A. Kennington IIIbb0eacc2022-10-21 15:22:06 -070055 'types',
William A. Kennington III0a01b2a2021-05-13 18:38:57 -070056 'util',
57 'vlan_interface',
58]
59
William A. Kennington III84bfe672022-07-13 14:15:30 -070060run_with_tmp = find_program('run_with_tmp', native: true)
61
William A. Kennington III7ba2d562022-08-02 13:20:23 -070062add_test_setup(
63 'networkd',
64 exe_wrapper: run_with_tmp,
65 env: {'TMPTMPL': 'phosphor-networkd-test.XXXXXXXXXX'},
66 is_default: true)
67
68add_test_setup(
69 'valgrind',
70 exe_wrapper: [run_with_tmp, 'valgrind'],
71 env: {'TMPTMPL': 'phosphor-networkd-test.XXXXXXXXXX'})
72
William A. Kennington III0a01b2a2021-05-13 18:38:57 -070073foreach t : tests
74 test(
75 t,
William A. Kennington III7ba2d562022-08-02 13:20:23 -070076 executable(
William A. Kennington III0a01b2a2021-05-13 18:38:57 -070077 t.underscorify(),
78 'test_' + t + '.cpp',
79 implicit_include_directories: false,
William A. Kennington III7ba2d562022-08-02 13:20:23 -070080 dependencies: test_dep))
William A. Kennington III0a01b2a2021-05-13 18:38:57 -070081endforeach
Asmitha Karunanithia6c07572022-05-05 03:19:45 -050082
83if (get_option('hyp-nw-config') == true)
84 subdir('ibm/hypervisor-network-mgr-test')
85endif