blob: 169b33f54433e5bb346795354bd9e173524d7a13 [file] [log] [blame]
William A. Kennington III7d6fa422021-02-08 17:04:02 -08001gtest = 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_proj = import('cmake').subproject(
5 'googletest',
6 cmake_options: [
7 '-DCMAKE_CXX_FLAGS=-Wno-pedantic',
8 ],
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 build_tests.enabled(), 'Googletest is required')
20 endif
21endif
22
23tests = [
24 'iface_test',
25 'sock_test',
26 #'ncsi_test', # TODO: Re-enable when fixed
27]
28
29ncsid_test_headers = include_directories('.')
30
31ncsid_test_lib = static_library(
32 'ncsid_test',
33 [
34 'net_iface_mock.cpp',
35 'nic_mock.cpp',
36 ],
37 include_directories: ncsid_test_headers,
38 implicit_include_directories: false,
39 dependencies: ncsid)
40
41ncsid_test = declare_dependency(
42 dependencies: ncsid,
43 include_directories: ncsid_test_headers,
44 link_with: ncsid_test_lib)
45
46foreach t : tests
47 test(t, executable(t.underscorify(), t + '.cpp',
48 implicit_include_directories: false,
49 dependencies: [gtest, gmock, ncsid_test]))
50endforeach
51
52script_tests = [
53 'normalize_ip_test',
54 'normalize_mac_test',
55]
56
57script_env = environment()
58script_deps = []
59script_env.set('NORMALIZE_IP', normalize_ip.full_path())
60script_deps += normalize_ip
61script_env.set('NORMALIZE_MAC', normalize_mac.full_path())
62script_deps += normalize_mac
63
64foreach st : script_tests
65 test(st, find_program('bash'), args: files(st + '.sh'),
66 protocol: 'tap', env: script_env, depends: script_deps)
67endforeach