mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2025-12-20 05:40:10 +01:00
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 <philip@tecnocode.co.uk>
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 9c5b5838f5)
This commit is contained in:
parent
d440173062
commit
53bcfe2de1
12 changed files with 34 additions and 24 deletions
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -29,11 +29,12 @@
|
|||
|
||||
#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 */
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ dbus_shared_sources = [
|
|||
'dbus-sysdeps.c',
|
||||
]
|
||||
|
||||
if embedded_tests
|
||||
if intrusive_tests
|
||||
dbus_shared_sources += 'dbus-test-tap.c'
|
||||
endif
|
||||
|
||||
|
|
|
|||
16
meson.build
16
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.
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
# SOFTWARE.
|
||||
|
||||
|
||||
if embedded_tests
|
||||
if intrusive_tests
|
||||
|
||||
tests = [
|
||||
{'name': 'test-ids'},
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue