mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2025-12-20 06:50:08 +01:00
test: Move TAP helpers into dbus-testutils if embedded tests are disabled
This lets us run a subset of the tests that previously relied on extra test-only code being compiled into libdbus. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
c46e002fe6
commit
fcbb5e6586
6 changed files with 38 additions and 25 deletions
|
|
@ -125,7 +125,6 @@ set(DBUS_SHARED_SOURCES
|
||||||
dbus-string.c
|
dbus-string.c
|
||||||
dbus-sysdeps.c
|
dbus-sysdeps.c
|
||||||
dbus-pipe.c
|
dbus-pipe.c
|
||||||
dbus-test-tap.c
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(DBUS_SHARED_HEADERS
|
set(DBUS_SHARED_HEADERS
|
||||||
|
|
@ -140,9 +139,14 @@ set(DBUS_SHARED_HEADERS
|
||||||
dbus-string-private.h
|
dbus-string-private.h
|
||||||
dbus-pipe.h
|
dbus-pipe.h
|
||||||
dbus-sysdeps.h
|
dbus-sysdeps.h
|
||||||
dbus-test-tap.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(DBUS_ENABLE_EMBEDDED_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
|
||||||
|
endif()
|
||||||
|
|
||||||
### source code that is generic utility functionality used
|
### source code that is generic utility functionality used
|
||||||
### by the bus daemon or test apps, but is NOT included
|
### by the bus daemon or test apps, but is NOT included
|
||||||
### in the D-BUS client library (all symbols in here
|
### in the D-BUS client library (all symbols in here
|
||||||
|
|
|
||||||
|
|
@ -240,10 +240,16 @@ DBUS_SHARED_SOURCES= \
|
||||||
$(DBUS_SHARED_arch_sources) \
|
$(DBUS_SHARED_arch_sources) \
|
||||||
dbus-sysdeps.c \
|
dbus-sysdeps.c \
|
||||||
dbus-sysdeps.h \
|
dbus-sysdeps.h \
|
||||||
dbus-test-tap.c \
|
|
||||||
dbus-test-tap.h \
|
|
||||||
dbus-valgrind-internal.h
|
dbus-valgrind-internal.h
|
||||||
|
|
||||||
|
if DBUS_ENABLE_EMBEDDED_TESTS
|
||||||
|
DBUS_SHARED_SOURCES += \
|
||||||
|
dbus-test-tap.c \
|
||||||
|
dbus-test-tap.h \
|
||||||
|
$(NULL)
|
||||||
|
# else they are included in the test library instead
|
||||||
|
endif
|
||||||
|
|
||||||
### source code that is generic utility functionality used
|
### source code that is generic utility functionality used
|
||||||
### by the bus daemon or test apps, but is NOT included
|
### by the bus daemon or test apps, but is NOT included
|
||||||
### in the D-Bus client library (all symbols in here
|
### in the D-Bus client library (all symbols in here
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,6 @@
|
||||||
* will not be explained here.
|
* will not be explained here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
@ -166,6 +164,7 @@ _dbus_test_skip (const char *format,
|
||||||
void
|
void
|
||||||
_dbus_test_check_memleaks (const char *test_name)
|
_dbus_test_check_memleaks (const char *test_name)
|
||||||
{
|
{
|
||||||
|
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
|
||||||
dbus_shutdown ();
|
dbus_shutdown ();
|
||||||
|
|
||||||
if (_dbus_get_malloc_blocks_outstanding () == 0)
|
if (_dbus_get_malloc_blocks_outstanding () == 0)
|
||||||
|
|
@ -180,6 +179,12 @@ _dbus_test_check_memleaks (const char *test_name)
|
||||||
_dbus_get_malloc_blocks_outstanding ());
|
_dbus_get_malloc_blocks_outstanding ());
|
||||||
failures++;
|
failures++;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
_dbus_test_skip (
|
||||||
|
"unable to determine whether %s leaked memory (not compiled "
|
||||||
|
"with memory instrumentation)",
|
||||||
|
test_name);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -202,5 +207,3 @@ _dbus_test_done_testing (void)
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
||||||
|
|
@ -29,34 +29,32 @@
|
||||||
|
|
||||||
#include <dbus/dbus-internals.h>
|
#include <dbus/dbus-internals.h>
|
||||||
|
|
||||||
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
|
DBUS_EMBEDDED_TESTS_EXPORT
|
||||||
|
|
||||||
DBUS_PRIVATE_EXPORT
|
|
||||||
void _dbus_test_fatal (const char *format,
|
void _dbus_test_fatal (const char *format,
|
||||||
...) _DBUS_GNUC_NORETURN _DBUS_GNUC_PRINTF (1, 2);
|
...) _DBUS_GNUC_NORETURN _DBUS_GNUC_PRINTF (1, 2);
|
||||||
|
|
||||||
DBUS_PRIVATE_EXPORT
|
DBUS_EMBEDDED_TESTS_EXPORT
|
||||||
void _dbus_test_diag (const char *format,
|
void _dbus_test_diag (const char *format,
|
||||||
...) _DBUS_GNUC_PRINTF (1, 2);
|
...) _DBUS_GNUC_PRINTF (1, 2);
|
||||||
|
|
||||||
DBUS_PRIVATE_EXPORT
|
DBUS_EMBEDDED_TESTS_EXPORT
|
||||||
void _dbus_test_skip_all (const char *format,
|
void _dbus_test_skip_all (const char *format,
|
||||||
...) _DBUS_GNUC_NORETURN _DBUS_GNUC_PRINTF (1, 2);
|
...) _DBUS_GNUC_NORETURN _DBUS_GNUC_PRINTF (1, 2);
|
||||||
|
|
||||||
DBUS_PRIVATE_EXPORT
|
DBUS_EMBEDDED_TESTS_EXPORT
|
||||||
void _dbus_test_ok (const char *format,
|
void _dbus_test_ok (const char *format,
|
||||||
...) _DBUS_GNUC_PRINTF (1, 2);
|
...) _DBUS_GNUC_PRINTF (1, 2);
|
||||||
DBUS_PRIVATE_EXPORT
|
DBUS_EMBEDDED_TESTS_EXPORT
|
||||||
void _dbus_test_not_ok (const char *format,
|
void _dbus_test_not_ok (const char *format,
|
||||||
...) _DBUS_GNUC_PRINTF (1, 2);
|
...) _DBUS_GNUC_PRINTF (1, 2);
|
||||||
DBUS_PRIVATE_EXPORT
|
DBUS_EMBEDDED_TESTS_EXPORT
|
||||||
void _dbus_test_skip (const char *format,
|
void _dbus_test_skip (const char *format,
|
||||||
...) _DBUS_GNUC_PRINTF (1, 2);
|
...) _DBUS_GNUC_PRINTF (1, 2);
|
||||||
|
|
||||||
DBUS_PRIVATE_EXPORT
|
DBUS_EMBEDDED_TESTS_EXPORT
|
||||||
void _dbus_test_check_memleaks (const char *test_name);
|
void _dbus_test_check_memleaks (const char *test_name);
|
||||||
|
|
||||||
DBUS_PRIVATE_EXPORT
|
DBUS_EMBEDDED_TESTS_EXPORT
|
||||||
int _dbus_test_done_testing (void);
|
int _dbus_test_done_testing (void);
|
||||||
|
|
||||||
#define _dbus_test_check(a) do { \
|
#define _dbus_test_check(a) do { \
|
||||||
|
|
@ -65,5 +63,3 @@ int _dbus_test_done_testing (void);
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
||||||
|
|
@ -54,9 +54,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "dbus/dbus-message-internal.h"
|
#include "dbus/dbus-message-internal.h"
|
||||||
#include "dbus/dbus-test-tap.h"
|
|
||||||
|
|
||||||
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
|
|
||||||
/*
|
/*
|
||||||
* Like strdup(), but crash on out-of-memory, and pass through NULL
|
* Like strdup(), but crash on out-of-memory, and pass through NULL
|
||||||
* unchanged (the "0" in the name is meant to be a mnemonic for this,
|
* unchanged (the "0" in the name is meant to be a mnemonic for this,
|
||||||
|
|
@ -77,7 +75,6 @@ strdup0_or_die (const char *str)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
@ -468,8 +465,6 @@ test_pending_call_store_reply (DBusPendingCall *pc,
|
||||||
_dbus_assert (*message_p != NULL);
|
_dbus_assert (*message_p != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
|
|
||||||
|
|
||||||
#ifdef DBUS_UNIX
|
#ifdef DBUS_UNIX
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -785,4 +780,11 @@ _dbus_test_main (int argc,
|
||||||
return _dbus_test_done_testing ();
|
return _dbus_test_done_testing ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If embedded tests are enabled, the TAP helpers have to be in the
|
||||||
|
* shared library because some of the embedded tests call them. If not,
|
||||||
|
* implement them here. We #include the file here instead of adding it
|
||||||
|
* to SOURCES because Automake versions older than 1.16 can't cope with
|
||||||
|
* expanding directory variables in SOURCES when using subdir-objects. */
|
||||||
|
#ifndef DBUS_ENABLE_EMBEDDED_TESTS
|
||||||
|
#include "dbus/dbus-test-tap.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@
|
||||||
#include <dbus/dbus-internals.h>
|
#include <dbus/dbus-internals.h>
|
||||||
#include <dbus/dbus-types.h>
|
#include <dbus/dbus-types.h>
|
||||||
|
|
||||||
|
#include "dbus/dbus-test-tap.h"
|
||||||
|
|
||||||
typedef DBusLoop TestMainContext;
|
typedef DBusLoop TestMainContext;
|
||||||
|
|
||||||
_DBUS_WARN_UNUSED_RESULT
|
_DBUS_WARN_UNUSED_RESULT
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue