]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3729] Began perfdhcp UTs
authorFrancis Dupont <fdupont@isc.org>
Fri, 14 Feb 2025 23:19:27 +0000 (00:19 +0100)
committerAndrei Pavel <andrei@isc.org>
Mon, 17 Feb 2025 13:34:48 +0000 (15:34 +0200)
src/bin/d2/meson.build
src/bin/d2/tests/d2_process_tests.sh.in [changed mode: 0644->0755]
src/bin/d2/tests/meson-test_callout_libraries.h.in [new file with mode: 0644]
src/bin/d2/tests/meson-test_configured_libraries.h.in [new file with mode: 0644]
src/bin/d2/tests/meson.build
src/bin/perfdhcp/meson.build
src/bin/perfdhcp/tests/meson.build

index e08d9d7bf90f4b551950a100ab3a446139ab92af..b5abd2f79a5209b09dbab475d3334ddc4e4687bf 100644 (file)
@@ -27,3 +27,4 @@ executable(
     install_dir: 'sbin',
     link_with: [d2_lib] + LIBS_BUILT_SO_FAR,
 )
+subdir('tests')
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/src/bin/d2/tests/meson-test_callout_libraries.h.in b/src/bin/d2/tests/meson-test_callout_libraries.h.in
new file mode 100644 (file)
index 0000000..5f04b3e
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright (C) 2021 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 D2_TEST_CALLOUT_LIBRARIES_H
+#define D2_TEST_CALLOUT_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 callout library with context_create and three "standard" callouts.
+static const char* CALLOUT_LIBRARY = "@abs_builddir@/libcallout.so";
+
+} // anonymous namespace
+
+#endif // D2_TEST_CALLOUT_LIBRARIES_H
diff --git a/src/bin/d2/tests/meson-test_configured_libraries.h.in b/src/bin/d2/tests/meson-test_configured_libraries.h.in
new file mode 100644 (file)
index 0000000..cd2fa47
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright (C) 2021 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 D2_TEST_CONFIGURED_LIBRARIES_H
+#define D2_TEST_CONFIGURED_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.
+
+// Configured library with d2_srv_configured testing: if there is a toplevel
+// user context with an error entry the returned status is DROP with the
+// content of the error entry.
+static const char* CONFIGURED_LIBRARY = "@abs_builddir@/libconfigured.so";
+
+} // anonymous namespace
+
+#endif // D2_TEST_CONFIGURED_LIBRARIES_H
index 0ad9c90376f3fd5e88af770dfbd403346cff5e82..d5f8f95b1b3692b96da169eb08bb743f3999e020 100644 (file)
@@ -3,33 +3,91 @@ if not gtest.found()
 endif
 
 current_build_dir = meson.current_build_dir()
+kea_d2_tests_data = configuration_data()
+kea_d2_tests_data.set('abs_top_builddir', TOP_BUILD_DIR)
+kea_d2_tests_data.set('abs_top_srcdir', TOP_SOURCE_DIR)
+kea_d2_tests_data.set('abs_builddir', current_build_dir)
+d2_process_tests = configure_file(
+    input: 'd2_process_tests.sh.in',
+    output: 'd2_process_tests.sh',
+    configuration: kea_d2_tests_data,
+)
+test(
+    'd2_process_tests.sh',
+    d2_process_tests,
+    workdir: current_build_dir,
+    is_parallel: false,
+    priority: -1,
+)
+configure_file(
+    input: 'meson-test_callout_libraries.h.in',
+    output: 'test_callout_libraries.h',
+    configuration: kea_d2_tests_data,
+)
+configure_file(
+    input: 'test_data_files_config.h.in',
+    output: 'test_data_files_config.h',
+    configuration: kea_d2_tests_data,
+)
+configure_file(
+    input: 'meson-test_configured_libraries.h.in',
+    output: 'test_configured_libraries.h',
+    configuration: kea_d2_tests_data,
+)
 
+current_source_dir = meson.current_source_dir()
+kea_d2_tests_libs = [
+    kea_d2srv_testutils_lib,
+    kea_process_testutils_lib,
+    kea_testutils_lib,
+    kea_asiolink_testutils_lib,
+]
 kea_d2_tests = executable(
     'kea-d2-tests',
-    'check_exists_add.cc',
-    'check_exists_remove.cc',
-    'd2_controller.cc',
-    'd2_lexer.cc',
-    'd2_parser.cc',
-    'd2_process.cc',
-    'd2_queue_mgr.cc',
-    'd2_update_mgr.cc',
-    'main.cc',
-    'nc_add.cc',
-    'nc_remove.cc',
-    'parser_context.cc',
-    'simple_add.cc',
-    'simple_add_without_dhcid.cc',
-    'simple_remove.cc',
-    'simple_remove_without_dhcid.cc',
+    'check_exists_add_unittests.cc',
+    'check_exists_remove_unittests.cc',
+    'd2_cfg_mgr_unittests.cc',
+    'd2_command_unittest.cc',
+    'd2_controller_unittests.cc',
+    'd2_http_command_unittest.cc',
+    'd2_process_unittests.cc',
+    'd2_queue_mgr_unittests.cc',
+    'd2_simple_parser_unittest.cc',
+    'd2_unittests.cc',
+    'd2_update_mgr_unittests.cc',
+    'get_config_unittest.cc',
+    'nc_add_unittests.cc',
+    'nc_remove_unittests.cc',
+    'parser_unittest.cc',
+    'simple_add_unittests.cc',
+    'simple_add_without_dhcid_unittests.cc',
+    'simple_remove_unittests.cc',
+    'simple_remove_without_dhcid_unittests.cc',
     cpp_args: [
+        f'-DTEST_DATA_BUILDDIR="@current_build_dir@"',
         f'-DCFG_EXAMPLES="@TOP_SOURCE_DIR@/doc/examples/ddns"',
         f'-DSYNTAX_FILE="@current_source_dir@/../d2_parser.yy"',
         f'-DTEST_CA_DIR="@TEST_CA_DIR@"',
-        f'-DTEST_DATA_BUILDDIR="@current_build_dir@"',
     ],
     dependencies: [gtest],
     include_directories: [include_directories('.')] + INCLUDES,
-    link_with: [d2_lib] + LIBS_BUILT_SO_FAR,
+    link_with: [d2_lib] + kea_d2_tests_libs + LIBS_BUILT_SO_FAR,
 )
 test('kea-d2-tests', kea_d2_tests, protocol: 'gtest')
+
+shared_library(
+    'callout',
+    'callout_library.cc',
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: LIBS_BUILT_SO_FAR,
+    build_rpath: '/nowhere',
+    name_suffix: 'so',
+)
+shared_library(
+    'configured',
+    'configured_library.cc',
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: LIBS_BUILT_SO_FAR,
+    build_rpath: '/nowhere',
+    name_suffix: 'so',
+)
index 6a52e2e86b72ac78748a1c09714d46d996d113ab..36c8353d9e2713b5197b55af270caa386c40304c 100644 (file)
@@ -21,3 +21,4 @@ executable(
     install_dir: 'sbin',
     link_with: [perfdhcp_lib] + LIBS_BUILT_SO_FAR,
 )
+subdir('tests')
index 8d02b2b46935e0fcac0c2195805e826f776dc530..96bd4b9a01f97365c37305401675d37124daaef3 100644 (file)
@@ -2,6 +2,7 @@ if not gtest.found()
     subdir_done()
 endif
 
+current_source_dir = meson.current_source_dir()
 perfdhcp_tests = executable(
     'perfdhcp-tests',
     'avalanche_scen_unittest.cc',
@@ -17,8 +18,9 @@ perfdhcp_tests = executable(
     'run_unittests.cc',
     'stats_mgr_unittest.cc',
     'test_control_unittest.cc',
+    cpp_args: [f'-DTEST_DATA_DIR="@current_source_dir@/testdata"'],
     dependencies: [gtest],
-    include_directories: [include_directories('.')] + INCLUDES,
-    link_with: LIBS_BUILT_SO_FAR,
+    include_directories: [include_directories('.'), include_directories('..')] + INCLUDES,
+    link_with: [perfdhcp_lib, kea_util_unittests_lib] + LIBS_BUILT_SO_FAR,
 )
 test('perfdhcp-tests', perfdhcp_tests, protocol: 'gtest')