]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3729] Finished lib tests
authorFrancis Dupont <fdupont@isc.org>
Thu, 6 Feb 2025 00:31:30 +0000 (01:31 +0100)
committerAndrei Pavel <andrei@isc.org>
Thu, 13 Feb 2025 08:05:20 +0000 (10:05 +0200)
src/lib/dhcpsrv/tests/meson-test_libraries.h.in [new file with mode: 0644]
src/lib/dhcpsrv/tests/meson.build
src/lib/hooks/tests/meson-test_libraries.h.in [new file with mode: 0644]
src/lib/hooks/tests/meson.build

diff --git a/src/lib/dhcpsrv/tests/meson-test_libraries.h.in b/src/lib/dhcpsrv/tests/meson-test_libraries.h.in
new file mode 100644 (file)
index 0000000..5325403
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef TEST_LIBRARIES_H
+#define TEST_LIBRARIES_H
+
+#include <config.h>
+
+namespace {
+
+// Names of the libraries used in these tests.  These libraries are built using
+// libtool, so we need to look in the hidden ".libs" directory to locate the
+// shared library.
+
+// Library with load/unload functions creating marker files to check their
+// operation.
+static const char* CALLOUT_LIBRARY_1 = "@abs_builddir@/libco1.so";
+static const char* CALLOUT_LIBRARY_2 = "@abs_builddir@/libco2.so";
+
+// This library will try to get the following parameters:
+// - svalue (and will expect its value to be "string value")
+// - ivalue (and will expect its value to be 42)
+// - bvalue (and will expect its value to be true)
+static const char* CALLOUT_PARAMS_LIBRARY = "@abs_builddir@/libco3.so";
+
+// Name of a library which is not present.
+static const char* NOT_PRESENT_LIBRARY = "@abs_builddir@/libnothere.so";
+
+} // anonymous namespace
+
+
+#endif // TEST_LIBRARIES_H
index dc17f5b2d9b0b2158e5515c8e3346a2780566183..d09f2d7197838f484c500e2216670764b63110fb 100644 (file)
@@ -14,6 +14,13 @@ configure_file(
     output: 'test_kea_lfc_env.sh',
     copy: true,
 )
+kea_dhcpsrv_conf_data = configuration_data()
+kea_dhcpsrv_conf_data.set('abs_builddir', meson.current_build_dir())
+configure_file(
+    input: 'meson-test_libraries.h.in',
+    output: 'test_libraries.h',
+    configuration: kea_dhcpsrv_conf_data,
+)
 kea_dhcpsrv_tests = executable(
     'kea-dhcpsrv-tests',
     'alloc_engine4_unittest.cc',
@@ -46,7 +53,7 @@ kea_dhcpsrv_tests = executable(
     'd2_client_unittest.cc',
     'd2_udp_unittest.cc',
     'dhcp4o6_ipc_unittest.cc',
-    'dhcp_parsers_unittest.cc',
+    'dhcp_parsers_unittest.cc',
     'dhcp_queue_control_parser_unittest.cc',
     'duid_config_parser_unittest.cc',
     'expiration_config_parser_unittest.cc',
@@ -104,3 +111,28 @@ test(
     protocol: 'gtest',
     is_parallel: false,
 )
+
+shared_library(
+    'co1',
+    'callout_library.cc',
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: LIBS_BUILT_SO_FAR,
+    build_rpath: '/nowhere',
+    name_suffix: 'so',
+)
+shared_library(
+    'co2',
+    'callout_library.cc',
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: LIBS_BUILT_SO_FAR,
+    build_rpath: '/nowhere',
+    name_suffix: 'so',
+)
+shared_library(
+    'co3',
+    'callout_params_library.cc',
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: LIBS_BUILT_SO_FAR,
+    build_rpath: '/nowhere',
+    name_suffix: 'so',
+)
diff --git a/src/lib/hooks/tests/meson-test_libraries.h.in b/src/lib/hooks/tests/meson-test_libraries.h.in
new file mode 100644 (file)
index 0000000..141d7af
--- /dev/null
@@ -0,0 +1,61 @@
+// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef TEST_LIBRARIES_H
+#define TEST_LIBRARIES_H
+
+#include <config.h>
+
+namespace {
+
+// Names of the libraries used in these tests.  These libraries are built using
+// libtool, so we need to look in the hidden ".libs" directory to locate the
+// .so file.  Note that we access the .so file - libtool creates this as a
+// like to the real shared library.
+
+// Basic library with context_create and three "standard" callouts.
+static const char* BASIC_CALLOUT_LIBRARY = "@abs_builddir@/libbcl.so";
+
+// Library with context_create and three "standard" callouts, as well as
+// load() and unload() functions.
+static const char* FULL_CALLOUT_LIBRARY = "@abs_builddir@/libfcl.so";
+
+// Library where the all framework functions throw an exception
+static const char* FRAMEWORK_EXCEPTION_LIBRARY = "@abs_builddir@/libfxl.so";
+
+// Library where the version() function returns an incorrect result.
+static const char* INCORRECT_VERSION_LIBRARY = "@abs_builddir@/libivl.so";
+
+// Library where some of the callout registration is done with the load()
+// function.
+static const char* LOAD_CALLOUT_LIBRARY = "@abs_builddir@/liblcl.so";
+
+// Library where the load() function returns an error.
+static const char* LOAD_ERROR_CALLOUT_LIBRARY =
+    "@abs_builddir@/liblecl.so";
+
+// Name of a library which is not present.
+static const char* NOT_PRESENT_LIBRARY = "@abs_builddir@/libnothere.so";
+
+// Library that does not include a version function.
+static const char* NO_VERSION_LIBRARY = "@abs_builddir@/libnvl.so";
+
+// Library where there is an unload() function.
+static const char* UNLOAD_CALLOUT_LIBRARY = "@abs_builddir@/libucl.so";
+
+// Library where parameters are checked.
+static const char* CALLOUT_PARAMS_LIBRARY = "@abs_builddir@/libpcl.so";
+
+// Library which tests objects parking.
+// Used only by hooks_manager_unittest.cc.
+#ifdef TEST_ASYNC_CALLOUT
+static const char* ASYNC_CALLOUT_LIBRARY = "@abs_builddir@/libacl.so";
+#endif
+
+} // anonymous namespace
+
+
+#endif // TEST_LIBRARIES_H
index 988a1bb35f971cb48e4c395aeaace4ed9b529780..f05c2575b2ec3c934cd01e0a41cf35385d3a7596 100644 (file)
@@ -9,9 +9,9 @@ kea_hooks_tests = executable(
     'callout_handle_unittest.cc',
     'callout_manager_unittest.cc',
     'handles_unittest.cc',
-    'hooks_manager_unittest.cc',
-    'library_manager_collection_unittest.cc',
-    'library_manager_unittest.cc',
+    'hooks_manager_unittest.cc',
+    'library_manager_collection_unittest.cc',
+    'library_manager_unittest.cc',
     'parking_lots_unittest.cc',
     'run_unittests.cc',
     'server_hooks_unittest.cc',
@@ -20,3 +20,97 @@ kea_hooks_tests = executable(
     link_with: [kea_util_unittests_lib] + LIBS_BUILT_SO_FAR,
 )
 test('kea_hooks_tests', kea_hooks_tests, protocol: 'gtest')
+
+kea_hooks_conf_data = configuration_data()
+kea_hooks_conf_data.set('abs_builddir', meson.current_build_dir())
+configure_file(
+    input: 'marker_file.h.in',
+    output: 'marker_file.h',
+    configuration: kea_hooks_conf_data,
+)
+configure_file(
+    input: 'meson-test_libraries.h.in',
+    output: 'test_libraries.h',
+    configuration: kea_hooks_conf_data,
+)
+
+shared_library(
+    'nvl',
+    'no_version_library.cc',
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: LIBS_BUILT_SO_FAR,
+    build_rpath: '/nowhere',
+    name_suffix: 'so',
+)
+shared_library(
+    'ivl',
+    'incorrect_version_library.cc',
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: LIBS_BUILT_SO_FAR,
+    build_rpath: '/nowhere',
+    name_suffix: 'so',
+)
+shared_library(
+    'fxl',
+    'framework_exception_library.cc',
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: LIBS_BUILT_SO_FAR,
+    build_rpath: '/nowhere',
+    name_suffix: 'so',
+)
+shared_library(
+    'bcl',
+    'basic_callout_library.cc',
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: LIBS_BUILT_SO_FAR,
+    build_rpath: '/nowhere',
+    name_suffix: 'so',
+)
+shared_library(
+    'lcl',
+    'load_callout_library.cc',
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: LIBS_BUILT_SO_FAR,
+    build_rpath: '/nowhere',
+    name_suffix: 'so',
+)
+shared_library(
+    'lecl',
+    'load_error_callout_library.cc',
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: LIBS_BUILT_SO_FAR,
+    build_rpath: '/nowhere',
+    name_suffix: 'so',
+)
+shared_library(
+    'ucl',
+    'unload_callout_library.cc',
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: LIBS_BUILT_SO_FAR,
+    build_rpath: '/nowhere',
+    name_suffix: 'so',
+)
+shared_library(
+    'fcl',
+    'full_callout_library.cc',
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: LIBS_BUILT_SO_FAR,
+    build_rpath: '/nowhere',
+    name_suffix: 'so',
+)
+shared_library(
+    'pcl',
+    'callout_params_library.cc',
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: LIBS_BUILT_SO_FAR,
+    build_rpath: '/nowhere',
+    name_suffix: 'so',
+)
+shared_library(
+    'acl',
+    'async_callout_library.cc',
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: LIBS_BUILT_SO_FAR,
+    build_rpath: '/nowhere',
+    name_suffix: 'so',
+)