2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[#3729] Checkpoint: almost finished dhcp4 UTs

This commit is contained in:
Francis Dupont
2025-02-08 04:04:58 +01:00
committed by Andrei Pavel
parent 5a9488dc27
commit c3fb6a71e0
11 changed files with 384 additions and 20 deletions

View File

@@ -0,0 +1,7 @@
#include <boost/version.hpp>
#include <iostream>
int main() {
std::cout << BOOST_LIB_VERSION << "\n";
return 0;
}

View File

@@ -0,0 +1,7 @@
#include <botan/version.h>
#include <iostream>
int main() {
std::cout << Botan::short_version_string() << "\n";
return 0;
}

View File

@@ -0,0 +1,7 @@
#include <iostream>
int main() {
long v = __cplusplus;
std::cout << v << "\n";
return 0;
}

View File

@@ -0,0 +1,7 @@
#include <log4cplus/version.h>
#include <iostream>
int main() {
std::cout << LOG4CPLUS_VERSION_STR << "\n";
return 0;
}

View File

@@ -0,0 +1,7 @@
#include <openssl/opensslv.h>
#include <iostream>
int main() {
std::cout << OPENSSL_VERSION_TEXT << "\n";
return 0;
}

116
config-report.sh.in Executable file
View File

@@ -0,0 +1,116 @@
#!/bin/sh
# Print the report.
cat > @TOP_BUILD_DIR@/config.report << END
Kea source configure results:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Package:
Name: @PACKAGE_NAME@
Version: @PACKAGE_VERSION@
Extended version: @EXTENDED_VERSION@
Version type: @PACKAGE_VERSION_TYPE@
OS Family: @OS_TYPE@
Prefix: @PREFIX@
Hooks directory: @HOOKS_DIR@
Premium hooks: @PREMIUM@
C++ Compiler:
CXX: @CXX@
CXX_ID: @CXX_ID@
CXX_VERSION: @CXX_VERSION@
CXX_STANDARD: @CXX_STANDARD@
END
if test "@HAVE_PYTHON@" != "no" ; then
cat >> @TOP_BUILD_DIR@/config.report << END
Python:
PYTHON: @PYTHON_PATH@
PKGPYTHONDIR: @PKGPYTHONDIR@
END
fi
cat >> @TOP_BUILD_DIR@/config.report << END
Boost:
BOOST_VERSION: @BOOST_VERSION@
BOOST_CFLAGS: @BOOST_CFLAGS@
BOOST_LIBS: @BOOST_LIBS@
@CRYPTO_NAME@:
CRYPTO_VERSION: @CRYPTO_VERSION@
CRYPTO_CFLAGS: @CRYPTO_CFLAGS@
CRYPTO_LIBS: @CRYPTO_LIBS@
Log4cplus:
LOG4CPLUS_VERSION: @LOG4CPLUS_VERSION@
LOG4CPLUS_CFLAGS: @LOG4CPLUS_CFLAGS@
LOG4CPLUS_LIBS: @LOG4CPLUS_LIBS@
Flex/bison:
FLEX: @FLEX@
BISON: @BISON@
END
if test "@HAVE_MYSQL@" != "no" ; then
cat >> @TOP_BUILD_DIR@/config.report << END
MySQL:
MYSQL_VERSION: @MYSQL_VERSION@
MYSQL_CFLAGS: @MYSQL_CFLAGS@
MYSQL_LIBS: @MYSQL_LIBS@
END
else
cat >> @TOP_BUILD_DIR@/config.report << END
MySQL:
no
END
fi
if test "@HAVE_PGSQL@" != "no" ; then
cat >> @TOP_BUILD_DIR@/config.report << END
PostgreSQL:
PGSQL_VERSION: @PGSQL_VERSION@
PGSQL_CFLAGS: @PGSQL_CFLAGS@
PGSQL_LIBS: @PGSQL_LIBS@
END
else
cat >> @TOP_BUILD_DIR@/config.report << END
PostgreSQL:
no
END
fi
cat >> @TOP_BUILD_DIR@/config.report << END
NETCONF:
@HAVE_NETCONF@
END
if test "@HAVE_GTEST@" != "no" ; then
cat >> @TOP_BUILD_DIR@/config.report << END
Google Test:
GTEST_VERSION: @GTEST_VERSION@
GTEST_CFLAGS: @GTEST_CFLAGS@
GTEST_LIBS: @GTEST_LIBS@
END
else
cat >> @TOP_BUILD_DIR@/config.report << END
Google Test:
no
END
fi
cat >> @TOP_BUILD_DIR@/config.report << END
END
# cat @TOP_BUILD_DIR@/config.report

View File

@@ -35,7 +35,7 @@ conf_data = configuration_data(
# 'CONFIG_H_WAS_INCLUDED': true,
# 'ENABLE_DEBUG': false,
# 'ENABLE_LOGGER_CHECKS': false,
'EXTENDED_VERSION': f'"@project_version@"',
'EXTENDED_VERSION': '"tarball"',
# 'FUZZING': false,
# 'FUZZING_IN_CI': false,
# 'HAS_UNDEFINED_PTHREAD_BEHAVIOR': false,
@@ -99,14 +99,14 @@ conf_data = configuration_data(
# 'LT_OBJDIR': false,
# 'PACKAGE': 'kea',
# 'PACKAGE_BUGREPORT': 'kea-dev@lists.isc.org',
# 'PACKAGE_NAME': 'kea',
'PACKAGE_NAME': 'kea',
# 'PACKAGE_STRING': f'kea "@project_version@"',
# 'PACKAGE_TARNAME': 'kea',
# 'PACKAGE_URL': '',
# 'PACKAGE_VERSION': meson.project_version(),
'PACKAGE_VERSION_TYPE': '"tarball"',
'PACKAGE_VERSION': meson.project_version(),
'PACKAGE_VERSION_TYPE': '"development"',
# 'PREMIUM': false,
'PREMIUM_EXTENDED_VERSION': f'"@project_version@"',
# 'PREMIUM_EXTENDED_VERSION': '"no"',
# 'STDC_HEADERS': false,
# 'TOP_BUILDDIR': false,
# 'USE_STATIC_LINK': false,
@@ -121,6 +121,8 @@ conf_data = configuration_data(
#### Programs
python_exe = find_program('python3', 'python', required: false)
flex_exe = find_program('flex', required: false)
bison_exe = find_program('bison', required: false)
#### Dependencies
@@ -290,20 +292,26 @@ endif
SYSTEM = build_machine.system()
if SYSTEM == 'linux'
conf_data.set('OS_LINUX', true)
OS_TYPE = 'Linux'
elif SYSTEM == 'freebsd'
conf_data.set('OS_BSD', true)
conf_data.set('OS_FREEBSD', true)
OS_TYPE = 'BSD'
elif SYSTEM == 'netbsd'
conf_data.set('OS_BSD', true)
conf_data.set('OS_NETBSD', true)
OS_TYPE = 'BSD'
elif SYSTEM == 'openbsd'
conf_data.set('OS_BSD', true)
conf_data.set('OS_OPENBSD', true)
OS_TYPE = 'BSD'
elif SYSTEM == 'sun'
conf_data.set('OS_SOLARIS', true)
OS_TYPE = 'Solaris'
elif SYSTEM == 'darwin'
conf_data.set('OS_BSD', true)
conf_data.set('OS_OSX', true)
OS_TYPE = 'BSD'
else
error(f'Build failed: Unsupported system "@SYSTEM@".')
endif
@@ -320,7 +328,11 @@ endif
have_premium = fs.is_dir('premium')
if have_premium
conf_data.set('PREMIUM', true)
conf_data.set('PREMIUM', 'yes')
conf_data.set('PREMIUM_EXTENDED_VERSION', f'"@project_version@"')
else
conf_data.set('PREMIUM', 'no')
conf_data.set('PREMIUM_EXTENDED_VERSION', '"no"')
endif
#### Configuration Files
@@ -347,10 +359,180 @@ configure_file(
INCLUDES = [
include_directories('.'),
include_directories('src'),
include_directories('src/bin'),
include_directories('src/lib'),
]
#### Build report
report_conf_data = configuration_data()
report_conf_data.set('TOP_BUILD_DIR', TOP_BUILD_DIR)
report_conf_data.set('PACKAGE_NAME', 'kea')
report_conf_data.set('PACKAGE_VERSION', project_version)
report_conf_data.set('EXTENDED_VERSION', project_version + ' (tarball)')
report_conf_data.set('PACKAGE_VERSION_TYPE', 'development')
report_conf_data.set('OS_TYPE', OS_TYPE)
report_conf_data.set('PREFIX', PREFIX)
report_conf_data.set('HOOKS_DIR', DEFAULT_HOOKS_PATH)
if have_premium
report_conf_data.set('PREMIUM', 'yes')
else
report_conf_data.set('PREMIUM', 'no')
endif
report_conf_data.set('CXX', ' '.join(cpp.cmd_array()))
report_conf_data.set('CXX_ID', cpp.get_id())
result = run_command(cpp, '--version', check: false)
if result.returncode() == 0
v = result.stdout().strip().split('\n')
report_conf_data.set('CXX_VERSION', v.get(0, 'unknown'))
else
report_conf_data.set('CXX_VERSION', 'unknown')
endif
result = cpp.run(
fs.read('compiler-checks/get-cpp-standard.cc'),
name: 'Get cpp standard',
)
if result.returncode() == 0
report_conf_data.set('CXX_STANDARD', result.stdout().strip())
else
report_conf_data.set('CXX_STANDARD', 'unknown')
endif
if python_exe.found()
report_conf_data.set('HAVE_PYTHON', 'yes')
report_conf_data.set('PYTHON_PATH', python_exe.full_path())
result = run_command(
python_exe,
'-c',
'import sysconfig; print(sysconfig.get_paths()[\'purelib\'])',
check: false,
)
if result.returncode() == 0
report_conf_data.set('PKGPYTHONDIR', result.stdout().strip() + '/kea')
else
report_conf_data.set('PKGPYTHONDIR', 'unknown')
endif
else
report_conf_data.set('HAVE_PYTHON', 'no')
endif
result = cpp.run(
fs.read('compiler-checks/get-boost-version.cc'),
name: 'Get Boost version',
dependencies: [boost],
)
if result.returncode() == 0
report_conf_data.set('BOOST_VERSION', result.stdout().strip())
else
report_conf_data.set('BOOST_VERSION', 'unknown')
endif
report_conf_data.set(
'BOOST_CFLAGS',
boost.get_variable('cflags', default_value: 'unknown'),
)
report_conf_data.set(
'BOOST_LIBS',
boost.get_variable('libs', default_value: 'unknown'),
)
report_conf_data.set('CRYPTO_NAME', crypto.name())
report_conf_data.set(
'CRYPTO_CFLAGS',
crypto.get_variable('cflags', default_value: 'unknown'),
)
report_conf_data.set(
'CRYPTO_LIBS',
crypto.get_variable('libs', default_value: 'unknown'),
)
if crypto.name() == botan.name()
result = cpp.run(
fs.read('compiler-checks/get-botan-version.cc'),
name: 'Get Botan version',
dependencies: [crypto],
)
if result.returncode() == 0
report_conf_data.set('CRYPTO_VERSION', result.stdout().strip())
else
report_conf_data.set('CRYPTO_VERSION', botan.name())
endif
elif crypto.name() == openssl.name()
result = cpp.run(
fs.read('compiler-checks/get-openssl-version.cc'),
name: 'Get OpenSSL version',
dependencies: [crypto],
)
if result.returncode() == 0
report_conf_data.set('CRYPTO_VERSION', result.stdout().strip())
else
report_conf_data.set('CRYPTO_VERSION', botan.name())
endif
endif
report_conf_data.set(
'LOG4CPLUS_CFLAGS',
log4cplus.get_variable('cflags', default_value: 'unknown'),
)
report_conf_data.set(
'LOG4CPLUS_LIBS',
log4cplus.get_variable('libs', default_value: 'unknown'),
)
result = cpp.run(
fs.read('compiler-checks/get-log4cplus-version.cc'),
name: 'Get Log4cplus version',
dependencies: [log4cplus],
)
if result.returncode() == 0
report_conf_data.set('LOG4CPLUS_VERSION', result.stdout().strip())
else
report_conf_data.set('LOG4CPLUS_VERSION', 'unknown')
endif
if flex_exe.found()
report_conf_data.set('FLEX', flex_exe.full_path())
else
report_conf_data.set('FLEX', 'unknown')
endif
if bison_exe.found()
report_conf_data.set('BISON', bison_exe.full_path())
else
report_conf_data.set('BISON', 'unknown')
endif
#todo
report_conf_data.set('HAVE_MYSQL', 'no')
report_conf_data.set('MYSQL_VERSION', 'unknown')
report_conf_data.set('MYSQL_CFLAGS', 'unknown')
report_conf_data.set('MYSQL_LIBS', 'unknown')
report_conf_data.set('HAVE_PGSQL', 'no')
report_conf_data.set('PGSQL_VERSION', 'unknown')
report_conf_data.set('PGSQL_CFLAGS', 'unknown')
report_conf_data.set('PGSQL_LIBS', 'unknown')
report_conf_data.set('HAVE_NETCONF', 'no')
if gtest.found()
report_conf_data.set('HAVE_GTEST', 'yes')
report_conf_data.set(
'GTEST_CFLAGS',
gtest.get_variable('cflags', default_value: 'unknown'),
)
report_conf_data.set(
'GTEST_LIBS',
gtest.get_variable('libs', default_value: 'unknown'),
)
report_conf_data.set('GTEST_VERSION', gtest.version())
else
report_conf_data.set('HAVE_GTEST', 'no')
report_conf_data.set('GTEST_VERSION', 'unknown')
report_conf_data.set('GTEST_CFLAGS', 'unknown')
report_conf_data.set('GTEST_LIBS', 'unknown')
endif
config_report_sh = configure_file(
input: 'config-report.sh.in',
output: 'config-report.sh',
configuration: report_conf_data,
)
config_report = custom_target(
'config.report',
output: 'config.report',
depend_files: config_report_sh,
command: [f'@TOP_BUILD_DIR@/config-report.sh'],
)
#### Build Starts Here
LIBS_BUILT_SO_FAR = []

View File

@@ -22,4 +22,4 @@ executable(
install_dir: 'sbin',
link_with: [dhcp4_lib] + LIBS_BUILT_SO_FAR,
)
# subdir('tests')
subdir('tests')

View File

@@ -4,12 +4,32 @@ endif
CURRENT_BUILD_DIR = meson.current_build_dir()
CURRENT_SOURCE_DIR = meson.current_source_dir()
libs_testutils = [
dhcp4_tests_deps = [boost, crypto, gtest]
dhcp4_tests_libs = [
kea_dhcpsrv_testutils_lib,
kea_dhcp_testutils_lib,
kea_database_testutils_lib,
kea_testutils_lib,
kea_util_unittests_lib,
kea_asiolink_testutils_lib,
]
if mysql.found()
dhcp4_tests_deps += [mysql]
dhcp4_tests_libs += [
dhcp_mysql_archive,
kea_mysql_testutils_lib,
kea_mysql_lib,
]
endif
if postgresql.found()
dhcp4_tests_deps += [postgresql]
dhcp4_tests_libs += [
dhcp_pgsql_archive,
kea_pgsql_testutils_lib,
kea_pgsql_lib,
]
endif
dhcp4_tests_conf_data = configuration_data()
dhcp4_tests_conf_data.set('abs_top_builddir', TOP_BUILD_DIR)
dhcp4_tests_conf_data.set('abs_top_srcdir', TOP_SOURCE_DIR)
@@ -45,10 +65,9 @@ dhcp4_unittests = executable(
'dhcp4_unittests',
'classify_unittest.cc',
'client_handler_unittest.cc',
'config_parser_unittest.cc',
'config_backend_unittest.cc',
'config_parser_unittest.cc',
'ctrl_dhcp4_srv_unittest.cc',
'http_control_socket_unittest.cc',
'd2_unittest.cc',
'decline_unittest.cc',
'dhcp4_client.cc',
@@ -62,6 +81,17 @@ dhcp4_unittests = executable(
'get_config_unittest.cc',
'hooks_unittest.cc',
'host_options_unittest.cc',
'host_unittest.cc',
'http_control_socket_unittest.cc',
'inform_unittest.cc',
'kea_controller_unittest.cc',
'marker_file.cc',
'out_of_range_unittest.cc',
'parser_unittest.cc',
'release_unittest.cc',
'shared_network_unittest.cc',
'simple_parser4_unittest.cc',
'vendor_opts_unittest.cc',
cpp_args: [
f'-DTEST_DATA_BUILDDIR="@CURRENT_BUILD_DIR@"',
f'-DCFG_EXAMPLES="@TOP_SOURCE_DIR@/doc/examples/kea4"',
@@ -70,16 +100,16 @@ dhcp4_unittests = executable(
f'-DKEA_LFC_EXECUTABLE="@KEA_LFC@"',
f'-DTEST_CA_DIR="@TEST_CA_DIR@"',
],
dependencies: [boost, crypto, gtest],
dependencies: dhcp4_tests_deps,
include_directories: [include_directories('.')] + INCLUDES,
link_with: [kea_util_unittests_lib] + libs_testutils + LIBS_BUILT_SO_FAR,
link_with: [dhcp4_lib] + dhcp4_tests_libs + LIBS_BUILT_SO_FAR,
)
test('dhcp4_unittests', dhcp4_unittests, protocol: 'gtest', is_parallel: false)
shared_library(
'co1',
'callout_library_1.cc',
dependencies: [boost],
dependencies: dhcp4_tests_deps,
include_directories: [include_directories('.')] + INCLUDES,
link_with: LIBS_BUILT_SO_FAR,
build_rpath: '/nowhere',
@@ -88,7 +118,7 @@ shared_library(
shared_library(
'co2',
'callout_library_2.cc',
dependencies: [boost],
dependencies: dhcp4_tests_deps,
include_directories: [include_directories('.')] + INCLUDES,
link_with: LIBS_BUILT_SO_FAR,
build_rpath: '/nowhere',
@@ -97,7 +127,7 @@ shared_library(
shared_library(
'co3',
'callout_library_3.cc',
dependencies: [boost],
dependencies: dhcp4_tests_deps,
include_directories: [include_directories('.')] + INCLUDES,
link_with: LIBS_BUILT_SO_FAR,
build_rpath: '/nowhere',
@@ -106,7 +136,7 @@ shared_library(
shared_library(
'co4',
'callout_library_4.cc',
dependencies: [boost],
dependencies: dhcp4_tests_deps,
include_directories: [include_directories('.')] + INCLUDES,
link_with: LIBS_BUILT_SO_FAR,
build_rpath: '/nowhere',

View File

@@ -1,7 +1,8 @@
config_report_cc = configure_file(
input: 'config_report.cc.in',
mk_cfgrpt = f'@TOP_SOURCE_DIR@/tools/mk_cfgrpt.sh'
config_report_cc = custom_target(
input: config_report,
output: 'config_report.cc',
configuration: conf_data,
command: [mk_cfgrpt, '@INPUT@', '@OUTPUT@'],
)
kea_cfgrpt_lib = library(
'kea-cfgrpt',

View File

@@ -4,7 +4,7 @@ endif
kea_process_cfgrpt_tests = executable(
'kea-process-cfgrpt-tests',
# 'config_report_unittests.cc',
'config_report_unittests.cc',
'run_unittests.cc',
dependencies: [gtest],
include_directories: [include_directories('.')] + INCLUDES,