@@ -446,3 +446,39 @@ if(WITH_SYSTEMD)
446446 target_link_libraries (unittest_journald_logger ceph-common)
447447 add_ceph_unittest(unittest_journald_logger)
448448endif ()
449+
450+ # Validation of the DECODE_START's struct_v compile-time checker.
451+ # First, ensure buildability of the test program itself. This is
452+ # useful to avoid false positives coming from other-than-the-assert
453+ # build failures.
454+ add_executable (unittest_decode_start_v_checker
455+ test_decode_start_v_checker.cpp)
456+ target_link_libraries (unittest_decode_start_v_checker global )
457+ set_target_properties (unittest_decode_start_v_checker
458+ PROPERTIES
459+ EXCLUDE_FROM_ALL TRUE
460+ EXCLUDE_FROM_DEFAULT_BUILD TRUE )
461+ add_test (
462+ NAME unittest_decode_start_v_checker
463+ COMMAND ${CMAKE_COMMAND} --build . --target unittest_decode_start_v_checker --config $<CONFIGURATION >
464+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )
465+
466+ # Second, ensure that adding a single, wrongly versioned comparison
467+ # fails the build.
468+ add_executable (unittest_decode_start_v_checker_expect_failure
469+ test_decode_start_v_checker.cpp)
470+ target_link_libraries (unittest_decode_start_v_checker_expect_failure global )
471+ target_compile_definitions (unittest_decode_start_v_checker_expect_failure
472+ PRIVATE SHOULD_FAIL)
473+ set_target_properties (
474+ unittest_decode_start_v_checker_expect_failure
475+ PROPERTIES
476+ EXCLUDE_FROM_ALL TRUE
477+ EXCLUDE_FROM_DEFAULT_BUILD TRUE )
478+ # Add the test bypassing the macros from AddCephTest.cmake. The idea is to
479+ # invoke "cmake --build ..." as the actual test and check whether it fails.
480+ add_test (NAME unittest_decode_start_v_checker_expect_failure
481+ COMMAND ${CMAKE_COMMAND} --build . --target unittest_decode_start_v_checker_expect_failure --config $<CONFIGURATION >
482+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )
483+ set_tests_properties (unittest_decode_start_v_checker_expect_failure
484+ PROPERTIES WILL_FAIL TRUE )
0 commit comments