]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Rename "embedded tests" to "intrusive tests"
authorSimon McVittie <smcv@collabora.com>
Mon, 9 Dec 2024 17:45:32 +0000 (17:45 +0000)
committerSimon McVittie <smcv@collabora.com>
Tue, 10 Dec 2024 15:43:31 +0000 (15:43 +0000)
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 <philip@tecnocode.co.uk>
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 9c5b5838f5ff667225a913f97006816e3e401d55)

12 files changed:
CMakeLists.txt
cmake/config.h.cmake
dbus/CMakeLists.txt
dbus/dbus-macros-internal.h
dbus/meson.build
meson.build
meson_options.txt
test/CMakeLists.txt
test/meson.build
test/name-test/meson.build
test/use-as-subproject/meson.build
tools/ci-build.sh

index d3ec71be4a252b31e01d5b3a6ee9886e13fda61a..3f9f37f1c9ab0f973f3a981ce546cfea2c4281ff 100644 (file)
@@ -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()
 
index 1cf57286f9aabeed6648086f60fbb544ff8b29b4..17e0def0f170e40805b99392573425469aad7f68 100644 (file)
 #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
index aaa5a52df236ec5915bf4d74ffcd3486b343124f..04f9ca225991284cbdc37498894bea608fd15880 100644 (file)
@@ -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
index 3d7c068317e9dcb19b3daea5922c237a8b7db386..474a84b5687e82d3507573d19b73275965902fb4 100644 (file)
 
 #include <dbus/dbus-macros.h>
 
-#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 */
index 905255c2e4e9bbacb1433ed95534af1e726a7739..87f18d914b75fd9fd6e6b715a92c8f92b43dbf98 100644 (file)
@@ -79,7 +79,7 @@ dbus_shared_sources = [
     'dbus-sysdeps.c',
 ]
 
-if embedded_tests
+if intrusive_tests
     dbus_shared_sources += 'dbus-test-tap.c'
 endif
 
index 1a1e80881f88a2e5e25b4bf4f535d9cdd4723ab0..fed1b7f2737ee6a45d7e2f20625a7cb0780e594f 100644 (file)
@@ -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.
@@ -1344,7 +1346,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
 
index e63f4bd6bb0e89f102ffe92ca8ec04bef06cb1c4..1fc8a2ad0b7f3589212fad9a792ee475a8e36c3b 100644 (file)
@@ -82,10 +82,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(
index b3c593e5d16862fa1ec7e1e5cfae8459091598e0..032ba1f7eb7c9b5f8c00e559de1dc05514ee1a18 100644 (file)
@@ -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})
index 1e61679aa1ddd5d6bf6b199a3ba931aa8f8e3c4f..e99196b8e7a9091c2b4f4262564ee8861e8ff8cf 100644 (file)
@@ -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 += [
         {
@@ -682,10 +684,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
index 293a9d36dbed36006d0c878e2a5abcd6e0a848e3..a99c0e9fa4ef319b9a190ce9b7752b4264876718 100644 (file)
@@ -20,7 +20,7 @@
 # SOFTWARE.
 
 
-if embedded_tests
+if intrusive_tests
 
     tests = [
         {'name': 'test-ids'},
index 8111e9ee499cce4b1e30fb877d8522d477a57937..e2a67d4a73d21a9292164d4b34e6e45ddfa91dc7 100644 (file)
@@ -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',
index c971415cde051eb5b25794d427133c5858a1bae5..55a3c1a42aa18211c14dcb11a20088c1f0abc37c 100755 (executable)
@@ -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