Skip to content

Commit 5d6cd05

Browse files
fxdupontandrei-pavel
authored andcommitted
[#3729] Began perfdhcp UTs
1 parent 5198ace commit 5d6cd05

7 files changed

+132
-20
lines changed

src/bin/d2/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ executable(
2727
install_dir: 'sbin',
2828
link_with: [d2_lib] + LIBS_BUILT_SO_FAR,
2929
)
30+
subdir('tests')

src/bin/d2/tests/d2_process_tests.sh.in

100644100755
File mode changed.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (C) 2021 Internet Systems Consortium, Inc. ("ISC")
2+
//
3+
// This Source Code Form is subject to the terms of the Mozilla Public
4+
// License, v. 2.0. If a copy of the MPL was not distributed with this
5+
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
7+
#ifndef D2_TEST_CALLOUT_LIBRARIES_H
8+
#define D2_TEST_CALLOUT_LIBRARIES_H
9+
10+
#include <config.h>
11+
12+
namespace {
13+
14+
// Names of the libraries used in these tests. These libraries are built using
15+
// libtool, so we need to look in the hidden ".libs" directory to locate the
16+
// .so file. Note that we access the .so file - libtool creates this as a
17+
// like to the real shared library.
18+
19+
// Basic callout library with context_create and three "standard" callouts.
20+
static const char* CALLOUT_LIBRARY = "@abs_builddir@/libcallout.so";
21+
22+
} // anonymous namespace
23+
24+
#endif // D2_TEST_CALLOUT_LIBRARIES_H
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (C) 2021 Internet Systems Consortium, Inc. ("ISC")
2+
//
3+
// This Source Code Form is subject to the terms of the Mozilla Public
4+
// License, v. 2.0. If a copy of the MPL was not distributed with this
5+
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
7+
#ifndef D2_TEST_CONFIGURED_LIBRARIES_H
8+
#define D2_TEST_CONFIGURED_LIBRARIES_H
9+
10+
#include <config.h>
11+
12+
namespace {
13+
14+
// Names of the libraries used in these tests. These libraries are built using
15+
// libtool, so we need to look in the hidden ".libs" directory to locate the
16+
// .so file. Note that we access the .so file - libtool creates this as a
17+
// like to the real shared library.
18+
19+
// Configured library with d2_srv_configured testing: if there is a toplevel
20+
// user context with an error entry the returned status is DROP with the
21+
// content of the error entry.
22+
static const char* CONFIGURED_LIBRARY = "@abs_builddir@/libconfigured.so";
23+
24+
} // anonymous namespace
25+
26+
#endif // D2_TEST_CONFIGURED_LIBRARIES_H

src/bin/d2/tests/meson.build

Lines changed: 76 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,91 @@ if not gtest.found()
33
endif
44

55
current_build_dir = meson.current_build_dir()
6+
kea_d2_tests_data = configuration_data()
7+
kea_d2_tests_data.set('abs_top_builddir', TOP_BUILD_DIR)
8+
kea_d2_tests_data.set('abs_top_srcdir', TOP_SOURCE_DIR)
9+
kea_d2_tests_data.set('abs_builddir', current_build_dir)
10+
d2_process_tests = configure_file(
11+
input: 'd2_process_tests.sh.in',
12+
output: 'd2_process_tests.sh',
13+
configuration: kea_d2_tests_data,
14+
)
15+
test(
16+
'd2_process_tests.sh',
17+
d2_process_tests,
18+
workdir: current_build_dir,
19+
is_parallel: false,
20+
priority: -1,
21+
)
22+
configure_file(
23+
input: 'meson-test_callout_libraries.h.in',
24+
output: 'test_callout_libraries.h',
25+
configuration: kea_d2_tests_data,
26+
)
27+
configure_file(
28+
input: 'test_data_files_config.h.in',
29+
output: 'test_data_files_config.h',
30+
configuration: kea_d2_tests_data,
31+
)
32+
configure_file(
33+
input: 'meson-test_configured_libraries.h.in',
34+
output: 'test_configured_libraries.h',
35+
configuration: kea_d2_tests_data,
36+
)
637

38+
current_source_dir = meson.current_source_dir()
39+
kea_d2_tests_libs = [
40+
kea_d2srv_testutils_lib,
41+
kea_process_testutils_lib,
42+
kea_testutils_lib,
43+
kea_asiolink_testutils_lib,
44+
]
745
kea_d2_tests = executable(
846
'kea-d2-tests',
9-
'check_exists_add.cc',
10-
'check_exists_remove.cc',
11-
'd2_controller.cc',
12-
'd2_lexer.cc',
13-
'd2_parser.cc',
14-
'd2_process.cc',
15-
'd2_queue_mgr.cc',
16-
'd2_update_mgr.cc',
17-
'main.cc',
18-
'nc_add.cc',
19-
'nc_remove.cc',
20-
'parser_context.cc',
21-
'simple_add.cc',
22-
'simple_add_without_dhcid.cc',
23-
'simple_remove.cc',
24-
'simple_remove_without_dhcid.cc',
47+
'check_exists_add_unittests.cc',
48+
'check_exists_remove_unittests.cc',
49+
'd2_cfg_mgr_unittests.cc',
50+
'd2_command_unittest.cc',
51+
'd2_controller_unittests.cc',
52+
'd2_http_command_unittest.cc',
53+
'd2_process_unittests.cc',
54+
'd2_queue_mgr_unittests.cc',
55+
'd2_simple_parser_unittest.cc',
56+
'd2_unittests.cc',
57+
'd2_update_mgr_unittests.cc',
58+
'get_config_unittest.cc',
59+
'nc_add_unittests.cc',
60+
'nc_remove_unittests.cc',
61+
'parser_unittest.cc',
62+
'simple_add_unittests.cc',
63+
'simple_add_without_dhcid_unittests.cc',
64+
'simple_remove_unittests.cc',
65+
'simple_remove_without_dhcid_unittests.cc',
2566
cpp_args: [
67+
f'-DTEST_DATA_BUILDDIR="@current_build_dir@"',
2668
f'-DCFG_EXAMPLES="@TOP_SOURCE_DIR@/doc/examples/ddns"',
2769
f'-DSYNTAX_FILE="@current_source_dir@/../d2_parser.yy"',
2870
f'-DTEST_CA_DIR="@TEST_CA_DIR@"',
29-
f'-DTEST_DATA_BUILDDIR="@current_build_dir@"',
3071
],
3172
dependencies: [gtest],
3273
include_directories: [include_directories('.')] + INCLUDES,
33-
link_with: [d2_lib] + LIBS_BUILT_SO_FAR,
74+
link_with: [d2_lib] + kea_d2_tests_libs + LIBS_BUILT_SO_FAR,
3475
)
3576
test('kea-d2-tests', kea_d2_tests, protocol: 'gtest')
77+
78+
shared_library(
79+
'callout',
80+
'callout_library.cc',
81+
include_directories: [include_directories('.')] + INCLUDES,
82+
link_with: LIBS_BUILT_SO_FAR,
83+
build_rpath: '/nowhere',
84+
name_suffix: 'so',
85+
)
86+
shared_library(
87+
'configured',
88+
'configured_library.cc',
89+
include_directories: [include_directories('.')] + INCLUDES,
90+
link_with: LIBS_BUILT_SO_FAR,
91+
build_rpath: '/nowhere',
92+
name_suffix: 'so',
93+
)

src/bin/perfdhcp/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ executable(
2121
install_dir: 'sbin',
2222
link_with: [perfdhcp_lib] + LIBS_BUILT_SO_FAR,
2323
)
24+
subdir('tests')

src/bin/perfdhcp/tests/meson.build

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ if not gtest.found()
22
subdir_done()
33
endif
44

5+
current_source_dir = meson.current_source_dir()
56
perfdhcp_tests = executable(
67
'perfdhcp-tests',
78
'avalanche_scen_unittest.cc',
@@ -17,8 +18,9 @@ perfdhcp_tests = executable(
1718
'run_unittests.cc',
1819
'stats_mgr_unittest.cc',
1920
'test_control_unittest.cc',
21+
cpp_args: [f'-DTEST_DATA_DIR="@current_source_dir@/testdata"'],
2022
dependencies: [gtest],
21-
include_directories: [include_directories('.')] + INCLUDES,
22-
link_with: LIBS_BUILT_SO_FAR,
23+
include_directories: [include_directories('.'), include_directories('..')] + INCLUDES,
24+
link_with: [perfdhcp_lib, kea_util_unittests_lib] + LIBS_BUILT_SO_FAR,
2325
)
2426
test('perfdhcp-tests', perfdhcp_tests, protocol: 'gtest')

0 commit comments

Comments
 (0)