From: Francis Dupont Date: Sat, 22 Mar 2025 14:59:58 +0000 (+0100) Subject: [#3785] Ported rebuild-tests target X-Git-Tag: botan2+3~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9c6532213a27baf9281b98ec9772545a1444e43d;p=thirdparty%2Fkea.git [#3785] Ported rebuild-tests target --- diff --git a/src/bin/dhcp4/tests/get_config_unittest.cc b/src/bin/dhcp4/tests/get_config_unittest.cc index eca36f8112..8dfec9edaa 100644 --- a/src/bin/dhcp4/tests/get_config_unittest.cc +++ b/src/bin/dhcp4/tests/get_config_unittest.cc @@ -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 index 0000000000..ed4ef71fcd --- /dev/null +++ b/src/bin/dhcp4/tests/make-rebuild.sh.in @@ -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)" diff --git a/src/bin/dhcp4/tests/meson.build b/src/bin/dhcp4/tests/meson.build index 4f699eb56a..46cd6d23ba 100644 --- a/src/bin/dhcp4/tests/meson.build +++ b/src/bin/dhcp4/tests/meson.build @@ -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 index 0000000000..9dd17357c0 --- /dev/null +++ b/src/bin/dhcp6/tests/make-rebuild.sh.in @@ -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)" diff --git a/src/bin/dhcp6/tests/meson.build b/src/bin/dhcp6/tests/meson.build index c62f05bd24..d97a3f5eab 100644 --- a/src/bin/dhcp6/tests/meson.build +++ b/src/bin/dhcp6/tests/meson.build @@ -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)