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)
########### 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()
#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
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
#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 */
'dbus-sysdeps.c',
]
-if embedded_tests
+if intrusive_tests
dbus_shared_sources += 'dbus-test-tap.c'
endif
# 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.
'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'),
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
)
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(
)
target_link_libraries(dbus-testutils ${DBUS_INTERNAL_LIBRARIES})
-if(DBUS_ENABLE_EMBEDDED_TESTS)
+if(DBUS_ENABLE_INTRUSIVE_TESTS)
add_subdirectory( name-test )
endif()
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})
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 += [
{
]
# 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
# SOFTWARE.
-if embedded_tests
+if intrusive_tests
tests = [
{'name': 'test-ids'},
fallback: ['dbus', 'libdbus_dep'],
default_options: [
'default_library=static',
- 'embedded_tests=false',
+ 'intrusive_tests=false',
'message_bus=false',
'modular_tests=disabled',
'tools=false',
case "$ci_variant" in
(debug)
set -- -Dasserts=true "$@"
- set -- -Dembedded_tests=true "$@"
+ set -- -Dintrusive_tests=true "$@"
set -- -Dverbose_mode=true "$@"
case "$ci_host" in