From: Simon McVittie Date: Mon, 9 Dec 2024 17:45:32 +0000 (+0000) Subject: Rename "embedded tests" to "intrusive tests" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c5b5838f5ff667225a913f97006816e3e401d55;p=thirdparty%2Fdbus.git Rename "embedded tests" to "intrusive tests" This hopefully helps to get across the point that enabling these tests adds instrumentation to libdbus and dbus-daemon, with a potentially significant impact on code size, performance and security. To avoid a huge diffstat which would be difficult to review, the cpp macro that is checked by most of the C code is still DBUS_ENABLE_EMBEDDED_TESTS, which is defined or undefined under exactly the same conditions as the new DBUS_ENABLE_INTRUSIVE_TESTS. Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/537 Co-authored-by: Philip Withnall Signed-off-by: Simon McVittie --- diff --git a/CMakeLists.txt b/CMakeLists.txt index d3ec71be4..3f9f37f1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -443,7 +443,7 @@ enable_testing() ########### command line options ############### if(DBUS_BUILD_TESTS) - set(DBUS_ENABLE_EMBEDDED_TESTS ON) + set(DBUS_ENABLE_INTRUSIVE_TESTS ON) set(DBUS_ENABLE_MODULAR_TESTS ON) endif() diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 1cf57286f..17e0def0f 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -59,10 +59,15 @@ #ifndef DBUS_DISABLE_CHECKS # define DBUS_ENABLE_CHECKS 1 #endif -#cmakedefine DBUS_ENABLE_EMBEDDED_TESTS 1 +#cmakedefine DBUS_ENABLE_INTRUSIVE_TESTS 1 #cmakedefine DBUS_ENABLE_MODULAR_TESTS 1 #cmakedefine DBUS_USE_OUTPUT_DEBUG_STRING 1 +/* Compatibility with the old name for this functionality */ +#ifdef DBUS_ENABLE_INTRUSIVE_TESTS +# define DBUS_ENABLE_EMBEDDED_TESTS 1 +#endif + /* xmldocs */ /* doxygen */ #cmakedefine DBUS_GCOV_ENABLED 1 diff --git a/dbus/CMakeLists.txt b/dbus/CMakeLists.txt index aaa5a52df..04f9ca225 100644 --- a/dbus/CMakeLists.txt +++ b/dbus/CMakeLists.txt @@ -143,7 +143,7 @@ set(DBUS_SHARED_HEADERS dbus-sysdeps.h ) -if(DBUS_ENABLE_EMBEDDED_TESTS) +if(DBUS_ENABLE_INTRUSIVE_TESTS) set(DBUS_SHARED_SOURCES ${DBUS_SHARED_SOURCES} dbus-test-tap.c) set(DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS} dbus-test-tap.h) # ... else they are in the test library instead diff --git a/dbus/dbus-macros-internal.h b/dbus/dbus-macros-internal.h index 3d7c06831..474a84b56 100644 --- a/dbus/dbus-macros-internal.h +++ b/dbus/dbus-macros-internal.h @@ -29,11 +29,12 @@ #include -#ifdef DBUS_ENABLE_EMBEDDED_TESTS -# define DBUS_EMBEDDED_TESTS_EXPORT DBUS_PRIVATE_EXPORT +#ifdef DBUS_ENABLE_INTRUSIVE_TESTS +# define DBUS_INTRUSIVE_TESTS_EXPORT DBUS_PRIVATE_EXPORT #else -# define DBUS_EMBEDDED_TESTS_EXPORT /* nothing */ +# define DBUS_INTRUSIVE_TESTS_EXPORT /* nothing */ #endif +#define DBUS_EMBEDDED_TESTS_EXPORT DBUS_INTRUSIVE_TESTS_EXPORT #if defined(DBUS_PRIVATE_EXPORT) /* value forced by compiler command line, don't redefine */ diff --git a/dbus/meson.build b/dbus/meson.build index 905255c2e..87f18d914 100644 --- a/dbus/meson.build +++ b/dbus/meson.build @@ -79,7 +79,7 @@ dbus_shared_sources = [ 'dbus-sysdeps.c', ] -if embedded_tests +if intrusive_tests dbus_shared_sources += 'dbus-test-tap.c' endif diff --git a/meson.build b/meson.build index 01d097fda..bac82baa7 100644 --- a/meson.build +++ b/meson.build @@ -879,10 +879,12 @@ config.set('DBUS_USE_OUTPUT_DEBUG_STRING', windows_output_debug) # Controls whether the tools are built. tools = get_option('tools') -# DBUS_ENABLE_EMBEDDED_TESTS controls unit tests built in to .c files +# DBUS_ENABLE_INTRUSIVE_TESTS controls unit tests built in to .c files # and some stuff in the test/ subdir. -embedded_tests = get_option('embedded_tests') -config.set('DBUS_ENABLE_EMBEDDED_TESTS', embedded_tests) +intrusive_tests = get_option('intrusive_tests') +config.set('DBUS_ENABLE_INTRUSIVE_TESTS', intrusive_tests) +# An older name for the same thing +config.set('DBUS_ENABLE_EMBEDDED_TESTS', intrusive_tests) # DBUS_ENABLE_MODULAR_TESTS controls tests that work based on public API. @@ -1343,7 +1345,7 @@ summary_dict += { 'gcc coverage': get_option('b_coverage'), 'gcc profiling': get_option('b_pgo'), - 'Building embedded tests': embedded_tests, + 'Building intrusive tests': intrusive_tests, 'Building modular tests': dbus_enable_modular_tests, '- with GLib': use_glib, 'Installing tests': get_option('installed_tests'), @@ -1385,10 +1387,10 @@ endif summary(summary_dict, bool_yn: true) -if embedded_tests - warning('building with unit tests increases the size of the installed library and renders it insecure.') +if intrusive_tests + warning('building with intrusive tests increases the size of the installed library and renders it insecure.') if not asserts - warning('building with embedded tests but without assertions means tests may not properly report failures (this configuration is only useful when doing something like profiling the tests)') + warning('building with intrusive tests but without assertions means tests may not properly report failures (this configuration is only useful when doing something like profiling the tests)') endif endif diff --git a/meson_options.txt b/meson_options.txt index 83c1c9217..3ce22c9b9 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -89,10 +89,10 @@ option( ) option( - 'embedded_tests', + 'intrusive_tests', type: 'boolean', value: false, - description: 'Enable unit test code in the library and binaries' + description: 'Enable tests that require insecure extra code in the library and binaries' ) option( diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b3c593e5d..032ba1f7e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,7 +13,7 @@ add_library(dbus-testutils STATIC ) target_link_libraries(dbus-testutils ${DBUS_INTERNAL_LIBRARIES}) -if(DBUS_ENABLE_EMBEDDED_TESTS) +if(DBUS_ENABLE_INTRUSIVE_TESTS) add_subdirectory( name-test ) endif() @@ -100,7 +100,7 @@ if(WIN32) add_helper_executable(manual-paths ${manual-paths_SOURCES} dbus-testutils) endif() -if(DBUS_ENABLE_EMBEDDED_TESTS) +if(DBUS_ENABLE_INTRUSIVE_TESTS) add_test_executable(test-atomic ${test-atomic_SOURCES} dbus-testutils) add_test_executable(test-hash internals/hash.c dbus-testutils) set_target_properties(test-hash PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) diff --git a/test/meson.build b/test/meson.build index d66c64109..a60afac6a 100644 --- a/test/meson.build +++ b/test/meson.build @@ -254,7 +254,9 @@ endif tests = [] -if embedded_tests +if intrusive_tests + # These tests require special instrumentation in libdbus and/or + # dbus-daemon, which is not safe to enable in production builds. tests += [ { @@ -688,10 +690,10 @@ if message_bus and tools and platform_unix and use_glib ] # Testing dbus-launch relies on special code in that binary. - if embedded_tests + if intrusive_tests scripts += { 'name': 'test-dbus-launch-eval.sh' } endif - if embedded_tests and use_x11_autolaunch + if intrusive_tests and use_x11_autolaunch scripts += { 'name': 'test-dbus-launch-x11.sh' } endif endif diff --git a/test/name-test/meson.build b/test/name-test/meson.build index 293a9d36d..a99c0e9fa 100644 --- a/test/name-test/meson.build +++ b/test/name-test/meson.build @@ -20,7 +20,7 @@ # SOFTWARE. -if embedded_tests +if intrusive_tests tests = [ {'name': 'test-ids'}, diff --git a/test/use-as-subproject/meson.build b/test/use-as-subproject/meson.build index 8111e9ee4..e2a67d4a7 100644 --- a/test/use-as-subproject/meson.build +++ b/test/use-as-subproject/meson.build @@ -22,7 +22,7 @@ libdbus_dep = dependency( fallback: ['dbus', 'libdbus_dep'], default_options: [ 'default_library=static', - 'embedded_tests=false', + 'intrusive_tests=false', 'message_bus=false', 'modular_tests=disabled', 'tools=false', diff --git a/tools/ci-build.sh b/tools/ci-build.sh index c971415cd..55a3c1a42 100755 --- a/tools/ci-build.sh +++ b/tools/ci-build.sh @@ -354,7 +354,7 @@ case "$ci_buildsys" in case "$ci_variant" in (debug) set -- -Dasserts=true "$@" - set -- -Dembedded_tests=true "$@" + set -- -Dintrusive_tests=true "$@" set -- -Dverbose_mode=true "$@" case "$ci_host" in