]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3785] Ported rebuild-tests target
authorFrancis Dupont <fdupont@isc.org>
Sat, 22 Mar 2025 14:59:58 +0000 (15:59 +0100)
committerFrancis Dupont <fdupont@isc.org>
Mon, 24 Mar 2025 14:54:17 +0000 (15:54 +0100)
src/bin/dhcp4/tests/get_config_unittest.cc
src/bin/dhcp4/tests/make-rebuild.sh.in [new file with mode: 0755]
src/bin/dhcp4/tests/meson.build
src/bin/dhcp6/tests/make-rebuild.sh.in [new file with mode: 0755]
src/bin/dhcp6/tests/meson.build

index eca36f8112c6632887dafc450bcbdbead4a69a95..8dfec9edaad008e0d3ca6ac58d2b8c4d2edc244f 100644 (file)
@@ -2761,7 +2761,7 @@ const char* EXTRACTED_CONFIGS[] = {
 
 /// @brief unparsed configurations
 const char* UNPARSED_CONFIGS[] = {
-///put this after const char* UNPARSED_CONFIGS[] = {
+/// put this after const char* UNPARSED_CONFIGS[] = {
     // CONFIGURATION 0
 "{\n"
 "        \"allocator\": \"iterative\",\n"
diff --git a/src/bin/dhcp4/tests/make-rebuild.sh.in b/src/bin/dhcp4/tests/make-rebuild.sh.in
new file mode 100755 (executable)
index 0000000..ed4ef71
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+set -eu
+
+pwd=$(pwd -P)
+cd "@builddir@"
+npwd=$(pwd -P)
+
+if test "$pwd" != "$npwd"; then
+    echo "This script should be run from the build directory (@builddir@)"
+    read -p "Press ENTER to continue anyway"
+fi
+
+# Initialize.
+rm -f x u get_config_unittest_rebuild.cc
+cp -f "@skeleton@" get_config_unittest_rebuild.cc
+rm -f kea-dhcp4-tests-extract
+echo "Please recompile kea-dhcp4-tests-extract"
+read -p "Press ENTER when ready"
+
+# Extract step.
+./kea-dhcp4-tests-extract --gtest_filter="Dhcp4Parser*" > /dev/null 2> x
+rm -f kea-dhcp4-tests-generate
+echo "Please copy content of x file into EXTRACTED_CONFIGS in get_config_unittest_rebuild.cc and recompile kea-dhcp4-tests-generate"
+read -p "Press ENTER when ready"
+
+# Generate step
+./kea-dhcp4-tests-generate --gtest_filter="Dhcp4GetConfig*" > /dev/null 2> u
+echo "Please copy content of u file into UNPARSED_CONFIGS in get_config_unittest_rebuild.cc"
+read -p "Press ENTER when ready"
+mv get_config_unittest_rebuild.cc get_config_unittest.cc
+cp -f get_config_unittest.cc "@source@"
+echo "Please recompile the kea_dhcp4_tests target"
+echo "When done with success you can check it (test suite is Dhcp4GetConfigTest)"
index 4f699eb56a30492398ea8981581fb687d30dfbd2..46cd6d23baf1182d54d50363fc7a03a8995d02de 100644 (file)
@@ -101,6 +101,15 @@ co4 = shared_library(
     name_suffix: 'so',
 )
 
+dhcp4_tests_cpp_args = [
+    f'-DTEST_DATA_BUILDDIR="@current_build_dir@"',
+    f'-DCFG_EXAMPLES="@TOP_SOURCE_DIR@/doc/examples/kea4"',
+    f'-DDHCP_DATA_DIR="@current_build_dir@"',
+    f'-DSYNTAX_FILE="@current_source_dir@/../dhcp4_parser.yy"',
+    f'-DKEA_LFC_EXECUTABLE="@KEA_LFC_BUILT@"',
+    f'-DTEST_CA_DIR="@TEST_CA_DIR@"',
+]
+
 # Not yet used configs-list.txt
 kea_dhcp4_tests = executable(
     'kea-dhcp4-tests',
@@ -133,14 +142,7 @@ kea_dhcp4_tests = executable(
     '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"',
-        f'-DDHCP_DATA_DIR="@current_build_dir@"',
-        f'-DSYNTAX_FILE="@current_source_dir@/../dhcp4_parser.yy"',
-        f'-DKEA_LFC_EXECUTABLE="@KEA_LFC_BUILT@"',
-        f'-DTEST_CA_DIR="@TEST_CA_DIR@"',
-    ],
+    cpp_args: dhcp4_tests_cpp_args,
     dependencies: dhcp4_tests_deps,
     include_directories: [include_directories('.')] + INCLUDES,
     link_with: [dhcp4_lib] + dhcp4_tests_libs + LIBS_BUILT_SO_FAR,
@@ -159,3 +161,53 @@ test(
     timeout: 60,
 )
 
+get_config_unittest_rebuild = configure_file(
+    input: 'get_config_unittest.cc.skel',
+    output: 'get_config_unittest_rebuild.cc',
+    copy: true,
+)
+kea_dhcp4_tests_extract = executable(
+    'kea-dhcp4-tests-extract',
+    get_config_unittest_rebuild,
+    'config_parser_unittest.cc',
+    objects: kea_dhcp4_tests.extract_objects(
+        'dhcp4_test_utils.cc',
+        'dhcp4_unittests.cc',
+        'marker_file.cc',
+    ),
+    cpp_args: ['-DEXTRACT_CONFIG'] + dhcp4_tests_cpp_args,
+    dependencies: dhcp4_tests_deps,
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: [dhcp4_lib] + dhcp4_tests_libs + LIBS_BUILT_SO_FAR,
+    build_by_default: false,
+)
+kea_dhcp4_tests_generate = executable(
+    'kea-dhcp4-tests-generate',
+    get_config_unittest_rebuild,
+    'config_parser_unittest.cc',
+    objects: kea_dhcp4_tests.extract_objects(
+        'dhcp4_test_utils.cc',
+        'dhcp4_unittests.cc',
+        'marker_file.cc',
+    ),
+    cpp_args: ['-DGENERATE_ACTION'] + dhcp4_tests_cpp_args,
+    dependencies: dhcp4_tests_deps,
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: [dhcp4_lib] + dhcp4_tests_libs + LIBS_BUILT_SO_FAR,
+    build_by_default: false,
+)
+
+make_rebuild_conf = configuration_data()
+make_rebuild_conf.set('builddir', current_build_dir)
+make_rebuild_conf.set('source', current_source_dir / 'get_config_unittest.cc')
+make_rebuild_conf.set(
+    'skeleton',
+    current_source_dir / 'get_config_unittest.cc.skel',
+)
+make_rebuild = configure_file(
+    input: 'make-rebuild.sh.in',
+    output: 'make-rebuild.sh',
+    configuration: make_rebuild_conf,
+)
+# Better when not use as a target.
+find_program(make_rebuild, required: true)
diff --git a/src/bin/dhcp6/tests/make-rebuild.sh.in b/src/bin/dhcp6/tests/make-rebuild.sh.in
new file mode 100755 (executable)
index 0000000..9dd1735
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+set -eu
+
+pwd=$(pwd -P)
+cd "@builddir@"
+npwd=$(pwd -P)
+
+if test "$pwd" != "$npwd"; then
+    echo "This script should be run from the build directory (@builddir@)"
+    read -p "Press ENTER to continue anyway"
+fi
+
+# Initialize.
+rm -f x u get_config_unittest_rebuild.cc
+cp -f "@skeleton@" get_config_unittest_rebuild.cc
+rm -f kea-dhcp6-tests-extract
+echo "Please recompile kea-dhcp6-tests-extract"
+read -p "Press ENTER when ready"
+
+# Extract step.
+./kea-dhcp6-tests-extract --gtest_filter="Dhcp6Parser*" > /dev/null 2> x
+rm -f kea-dhcp6-tests-generate
+echo "Please copy content of x file into EXTRACTED_CONFIGS in get_config_unittest_rebuild.cc and recompile kea-dhcp6-tests-generate"
+read -p "Press ENTER when ready"
+
+# Generate step
+./kea-dhcp6-tests-generate --gtest_filter="Dhcp6GetConfig*" > /dev/null 2> u
+echo "Please copy content of u file into UNPARSED_CONFIGS in get_config_unittest_rebuild.cc"
+read -p "Press ENTER when ready"
+mv get_config_unittest_rebuild.cc get_config_unittest.cc
+cp -f get_config_unittest.cc "@source@"
+echo "Please recompile the kea_dhcp6_tests target"
+echo "When done with success you can check it (test suite is Dhcp6GetConfigTest)"
index c62f05bd2451e926cf629fc9a7398e6d67e1fb81..d97a3f5eab64bf87c5e56c5b33cc3ea4cb340e33 100644 (file)
@@ -101,6 +101,16 @@ co4 = shared_library(
     name_suffix: 'so',
 )
 
+dhcp6_tests_cpp_args = [
+    f'-DTOP_BUILDDIR="@TOP_BUILD_DIR@"',
+    f'-DTEST_DATA_BUILDDIR="@current_build_dir@"',
+    f'-DCFG_EXAMPLES="@TOP_SOURCE_DIR@/doc/examples/kea6"',
+    f'-DDHCP_DATA_DIR="@current_build_dir@"',
+    f'-DSYNTAX_FILE="@current_source_dir@/../dhcp6_parser.yy"',
+    f'-DKEA_LFC_EXECUTABLE="@KEA_LFC_BUILT@"',
+    f'-DTEST_CA_DIR="@TEST_CA_DIR@"',
+]
+
 kea_dhcp6_tests = executable(
     'kea-dhcp6-tests',
     'addr_reg_unittest.cc',
@@ -134,15 +144,7 @@ kea_dhcp6_tests = executable(
     'simple_parser6_unittest.cc',
     'tee_times_unittest.cc',
     'vendor_opts_unittest.cc',
-    cpp_args: [
-        f'-DTOP_BUILDDIR="@TOP_BUILD_DIR@"',
-        f'-DTEST_DATA_BUILDDIR="@current_build_dir@"',
-        f'-DCFG_EXAMPLES="@TOP_SOURCE_DIR@/doc/examples/kea6"',
-        f'-DDHCP_DATA_DIR="@current_build_dir@"',
-        f'-DSYNTAX_FILE="@current_source_dir@/../dhcp6_parser.yy"',
-        f'-DKEA_LFC_EXECUTABLE="@KEA_LFC_BUILT@"',
-        f'-DTEST_CA_DIR="@TEST_CA_DIR@"',
-    ],
+    cpp_args: dhcp6_tests_cpp_args,
     dependencies: dhcp6_tests_deps,
     include_directories: [include_directories('.')] + INCLUDES,
     link_with: [dhcp6_lib] + dhcp6_tests_libs + LIBS_BUILT_SO_FAR,
@@ -161,3 +163,55 @@ test(
     timeout: 60,
 )
 
+get_config_unittest_rebuild = configure_file(
+    input: 'get_config_unittest.cc.skel',
+    output: 'get_config_unittest_rebuild.cc',
+    copy: true,
+)
+kea_dhcp6_tests_extract = executable(
+    'kea-dhcp6-tests-extract',
+    get_config_unittest_rebuild,
+    'config_parser_unittest.cc',
+    objects: kea_dhcp6_tests.extract_objects(
+        'dhcp6_client.cc',
+        'dhcp6_test_utils.cc',
+        'dhcp6_unittests.cc',
+        'marker_file.cc',
+    ),
+    cpp_args: ['-DEXTRACT_CONFIG'] + dhcp6_tests_cpp_args,
+    dependencies: dhcp6_tests_deps,
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: [dhcp6_lib] + dhcp6_tests_libs + LIBS_BUILT_SO_FAR,
+    build_by_default: false,
+)
+kea_dhcp6_tests_generate = executable(
+    'kea-dhcp6-tests-generate',
+    get_config_unittest_rebuild,
+    'config_parser_unittest.cc',
+    objects: kea_dhcp6_tests.extract_objects(
+        'dhcp6_client.cc',
+        'dhcp6_test_utils.cc',
+        'dhcp6_unittests.cc',
+        'marker_file.cc',
+    ),
+    cpp_args: ['-DGENERATE_ACTION'] + dhcp6_tests_cpp_args,
+    dependencies: dhcp6_tests_deps,
+    include_directories: [include_directories('.')] + INCLUDES,
+    link_with: [dhcp6_lib] + dhcp6_tests_libs + LIBS_BUILT_SO_FAR,
+    build_by_default: false,
+)
+
+make_rebuild_conf = configuration_data()
+make_rebuild_conf.set('builddir', current_build_dir)
+make_rebuild_conf.set('source', current_source_dir / 'get_config_unittest.cc')
+make_rebuild_conf.set(
+    'skeleton',
+    current_source_dir / 'get_config_unittest.cc.skel',
+)
+make_rebuild = configure_file(
+    input: 'make-rebuild.sh.in',
+    output: 'make-rebuild.sh',
+    configuration: make_rebuild_conf,
+)
+# Better when not use as a target.
+find_program(make_rebuild, required: true)