William A. Kennington III | 0a01b2a | 2021-05-13 18:38:57 -0700 | [diff] [blame] | 1 | gtest = dependency('gtest', main: true, disabler: true, required: false) |
| 2 | gmock = dependency('gmock', disabler: true, required: false) |
| 3 | if 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 III | fc3aff9 | 2021-05-29 15:09:58 -0700 | [diff] [blame] | 19 | assert(not get_option('tests').enabled(), 'Googletest is required') |
William A. Kennington III | 0a01b2a | 2021-05-13 18:38:57 -0700 | [diff] [blame] | 20 | endif |
| 21 | endif |
| 22 | |
| 23 | test_headers = include_directories('.') |
| 24 | |
| 25 | test_deps = [ |
| 26 | meson.get_compiler('cpp').find_library('dl'), |
| 27 | networkd_dep, |
| 28 | gtest, |
| 29 | gmock, |
William A. Kennington III | 84bfe67 | 2022-07-13 14:15:30 -0700 | [diff] [blame] | 30 | dependency('stdplus-gtest'), |
William A. Kennington III | 0a01b2a | 2021-05-13 18:38:57 -0700 | [diff] [blame] | 31 | ] |
| 32 | |
| 33 | test_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 | |
| 41 | test_dep = declare_dependency( |
| 42 | dependencies: test_deps, |
| 43 | include_directories: test_headers, |
| 44 | link_with: test_lib) |
| 45 | |
| 46 | tests = [ |
| 47 | 'config_parser', |
| 48 | 'ethernet_interface', |
William A. Kennington III | 0a01b2a | 2021-05-13 18:38:57 -0700 | [diff] [blame] | 49 | 'netlink', |
| 50 | 'network_manager', |
William A. Kennington III | 6a92363 | 2022-11-06 18:17:33 -0800 | [diff] [blame] | 51 | 'rtnetlink', |
| 52 | #'rtnetlink_server', |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 53 | 'system_queries', |
William A. Kennington III | bb0eacc | 2022-10-21 15:22:06 -0700 | [diff] [blame] | 54 | 'types', |
William A. Kennington III | 0a01b2a | 2021-05-13 18:38:57 -0700 | [diff] [blame] | 55 | 'util', |
William A. Kennington III | 0a01b2a | 2021-05-13 18:38:57 -0700 | [diff] [blame] | 56 | ] |
| 57 | |
William A. Kennington III | 84bfe67 | 2022-07-13 14:15:30 -0700 | [diff] [blame] | 58 | run_with_tmp = find_program('run_with_tmp', native: true) |
| 59 | |
William A. Kennington III | 7ba2d56 | 2022-08-02 13:20:23 -0700 | [diff] [blame] | 60 | add_test_setup( |
| 61 | 'networkd', |
| 62 | exe_wrapper: run_with_tmp, |
| 63 | env: {'TMPTMPL': 'phosphor-networkd-test.XXXXXXXXXX'}, |
| 64 | is_default: true) |
| 65 | |
| 66 | add_test_setup( |
| 67 | 'valgrind', |
| 68 | exe_wrapper: [run_with_tmp, 'valgrind'], |
| 69 | env: {'TMPTMPL': 'phosphor-networkd-test.XXXXXXXXXX'}) |
| 70 | |
William A. Kennington III | 0a01b2a | 2021-05-13 18:38:57 -0700 | [diff] [blame] | 71 | foreach t : tests |
| 72 | test( |
| 73 | t, |
William A. Kennington III | 7ba2d56 | 2022-08-02 13:20:23 -0700 | [diff] [blame] | 74 | executable( |
William A. Kennington III | 0a01b2a | 2021-05-13 18:38:57 -0700 | [diff] [blame] | 75 | t.underscorify(), |
| 76 | 'test_' + t + '.cpp', |
| 77 | implicit_include_directories: false, |
William A. Kennington III | 7ba2d56 | 2022-08-02 13:20:23 -0700 | [diff] [blame] | 78 | dependencies: test_dep)) |
William A. Kennington III | 0a01b2a | 2021-05-13 18:38:57 -0700 | [diff] [blame] | 79 | endforeach |
Asmitha Karunanithi | a6c0757 | 2022-05-05 03:19:45 -0500 | [diff] [blame] | 80 | |
| 81 | if (get_option('hyp-nw-config') == true) |
| 82 | subdir('ibm/hypervisor-network-mgr-test') |
| 83 | endif |