mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-05 06:28:00 +02:00
test/bus: Factor out common setup/teardown code
Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
2cdd0d0f30
commit
11e6c92e95
8 changed files with 97 additions and 102 deletions
|
|
@ -146,15 +146,15 @@ if(DBUS_ENABLE_EMBEDDED_TESTS)
|
|||
|
||||
add_test_executable(test-platform-mutex test-platform-mutex.c ${DBUS_INTERNAL_LIBRARIES} dbus-testutils)
|
||||
|
||||
set(SOURCES bus/main.c)
|
||||
set(SOURCES bus/main.c bus/common.c bus/common.h)
|
||||
add_test_executable(test-bus "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
|
||||
set_target_properties(test-bus PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
|
||||
|
||||
set(SOURCES bus/dispatch.c)
|
||||
set(SOURCES bus/dispatch.c bus/common.c bus/common.h)
|
||||
add_test_executable(test-bus-dispatch "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
|
||||
set_target_properties(test-bus-dispatch PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
|
||||
|
||||
set(SOURCES bus/dispatch-sha1.c)
|
||||
set(SOURCES bus/dispatch-sha1.c bus/common.c bus/common.h)
|
||||
add_test_executable(test-bus-dispatch-sha1 "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
|
||||
set_target_properties(test-bus-dispatch-sha1 PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
|
||||
|
||||
|
|
|
|||
|
|
@ -199,19 +199,19 @@ test_bus_system_LDADD = \
|
|||
libdbus-testutils.la \
|
||||
$(NULL)
|
||||
|
||||
test_bus_SOURCES = bus/main.c
|
||||
test_bus_SOURCES = bus/main.c bus/common.c bus/common.h
|
||||
test_bus_LDADD = \
|
||||
$(top_builddir)/bus/libdbus-daemon-internal.la \
|
||||
libdbus-testutils.la \
|
||||
$(NULL)
|
||||
|
||||
test_bus_dispatch_SOURCES = bus/dispatch.c
|
||||
test_bus_dispatch_SOURCES = bus/dispatch.c bus/common.c bus/common.h
|
||||
test_bus_dispatch_LDADD = \
|
||||
$(top_builddir)/bus/libdbus-daemon-internal.la \
|
||||
libdbus-testutils.la \
|
||||
$(NULL)
|
||||
|
||||
test_bus_dispatch_sha1_SOURCES = bus/dispatch-sha1.c
|
||||
test_bus_dispatch_sha1_SOURCES = bus/dispatch-sha1.c bus/common.c bus/common.h
|
||||
test_bus_dispatch_sha1_LDADD = \
|
||||
$(top_builddir)/bus/libdbus-daemon-internal.la \
|
||||
libdbus-testutils.la \
|
||||
|
|
|
|||
61
test/bus/common.c
Normal file
61
test/bus/common.c
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* Copyright 2003-2009 Red Hat, Inc.
|
||||
* Copyright 2011-2022 Collabora Ltd.
|
||||
* SPDX-License-Identifier: AFL-2.1 or GPL-2-or-later
|
||||
*
|
||||
* Licensed under the Academic Free License version 2.1
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "bus/audit.h"
|
||||
#include "bus/selinux.h"
|
||||
|
||||
#include "test/bus/common.h"
|
||||
#include "test/test-utils.h"
|
||||
|
||||
#ifndef DBUS_ENABLE_EMBEDDED_TESTS
|
||||
#error This file is only relevant for the embedded tests
|
||||
#endif
|
||||
|
||||
static void
|
||||
test_pre_hook (void)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
test_post_hook (void)
|
||||
{
|
||||
if (_dbus_getenv ("DBUS_TEST_SELINUX"))
|
||||
bus_selinux_shutdown ();
|
||||
|
||||
bus_audit_shutdown ();
|
||||
}
|
||||
|
||||
int
|
||||
bus_test_main (int argc,
|
||||
char **argv,
|
||||
size_t n_tests,
|
||||
const DBusTestCase *tests)
|
||||
{
|
||||
return _dbus_test_main (argc, argv, n_tests, tests,
|
||||
(DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS |
|
||||
DBUS_TEST_FLAGS_CHECK_FD_LEAKS |
|
||||
DBUS_TEST_FLAGS_REQUIRE_DATA),
|
||||
test_pre_hook, test_post_hook);
|
||||
}
|
||||
21
test/bus/common.h
Normal file
21
test/bus/common.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright 2022 Collabora Ltd.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef TEST_BUS_COMMON_H
|
||||
#define TEST_BUS_COMMON_H
|
||||
|
||||
#ifndef DBUS_ENABLE_EMBEDDED_TESTS
|
||||
#error This file is only relevant for the embedded tests
|
||||
#endif
|
||||
|
||||
#include "bus/test.h"
|
||||
#include "test/test-utils.h"
|
||||
|
||||
int bus_test_main (int argc,
|
||||
char **argv,
|
||||
size_t n_tests,
|
||||
const DBusTestCase *tests);
|
||||
|
||||
#endif
|
||||
|
|
@ -22,41 +22,12 @@
|
|||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "bus/test.h"
|
||||
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
|
||||
#include "bus/audit.h"
|
||||
#include "bus/selinux.h"
|
||||
#include "test/test-utils.h"
|
||||
|
||||
#ifndef DBUS_ENABLE_EMBEDDED_TESTS
|
||||
#error This file is only relevant for the embedded tests
|
||||
#endif
|
||||
|
||||
static void
|
||||
test_pre_hook (void)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
test_post_hook (void)
|
||||
{
|
||||
if (_dbus_getenv ("DBUS_TEST_SELINUX"))
|
||||
bus_selinux_shutdown ();
|
||||
|
||||
bus_audit_shutdown ();
|
||||
}
|
||||
#include "test/bus/common.h"
|
||||
|
||||
static DBusTestCase test = { "dispatch-sha1", bus_dispatch_sha1_test };
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
return _dbus_test_main (argc, argv, 1, &test,
|
||||
(DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS |
|
||||
DBUS_TEST_FLAGS_CHECK_FD_LEAKS |
|
||||
DBUS_TEST_FLAGS_REQUIRE_DATA),
|
||||
test_pre_hook, test_post_hook);
|
||||
return bus_test_main (argc, argv, 1, &test);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,41 +22,12 @@
|
|||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "bus/test.h"
|
||||
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
|
||||
#include "bus/audit.h"
|
||||
#include "bus/selinux.h"
|
||||
#include "test/test-utils.h"
|
||||
|
||||
#ifndef DBUS_ENABLE_EMBEDDED_TESTS
|
||||
#error This file is only relevant for the embedded tests
|
||||
#endif
|
||||
|
||||
static void
|
||||
test_pre_hook (void)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
test_post_hook (void)
|
||||
{
|
||||
if (_dbus_getenv ("DBUS_TEST_SELINUX"))
|
||||
bus_selinux_shutdown ();
|
||||
|
||||
bus_audit_shutdown ();
|
||||
}
|
||||
#include "test/bus/common.h"
|
||||
|
||||
static DBusTestCase test = { "dispatch", bus_dispatch_test };
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
return _dbus_test_main (argc, argv, 1, &test,
|
||||
(DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS |
|
||||
DBUS_TEST_FLAGS_CHECK_FD_LEAKS |
|
||||
DBUS_TEST_FLAGS_REQUIRE_DATA),
|
||||
test_pre_hook, test_post_hook);
|
||||
return bus_test_main (argc, argv, 1, &test);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,32 +23,7 @@
|
|||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "bus/test.h"
|
||||
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
|
||||
#include "bus/audit.h"
|
||||
#include "bus/selinux.h"
|
||||
#include "test/test-utils.h"
|
||||
|
||||
#ifndef DBUS_ENABLE_EMBEDDED_TESTS
|
||||
#error This file is only relevant for the embedded tests
|
||||
#endif
|
||||
|
||||
static void
|
||||
test_pre_hook (void)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
test_post_hook (void)
|
||||
{
|
||||
if (_dbus_getenv ("DBUS_TEST_SELINUX"))
|
||||
bus_selinux_shutdown ();
|
||||
|
||||
bus_audit_shutdown ();
|
||||
}
|
||||
#include "test/bus/common.h"
|
||||
|
||||
static DBusTestCase tests[] =
|
||||
{
|
||||
|
|
@ -63,9 +38,5 @@ static DBusTestCase tests[] =
|
|||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
return _dbus_test_main (argc, argv, _DBUS_N_ELEMENTS (tests), tests,
|
||||
(DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS |
|
||||
DBUS_TEST_FLAGS_CHECK_FD_LEAKS |
|
||||
DBUS_TEST_FLAGS_REQUIRE_DATA),
|
||||
test_pre_hook, test_post_hook);
|
||||
return bus_test_main (argc, argv, _DBUS_N_ELEMENTS (tests), tests);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -230,20 +230,20 @@ if embedded_tests
|
|||
tests += [
|
||||
{
|
||||
'name': 'bus',
|
||||
'srcs': [ 'bus/main.c' ],
|
||||
'srcs': [ 'bus/main.c', 'bus/common.c' ],
|
||||
'link': [ libdbus_testutils, libdbus_daemon_internal, ],
|
||||
'install': false,
|
||||
},
|
||||
{
|
||||
'name': 'bus-dispatch-sha1',
|
||||
'srcs': [ 'bus/dispatch-sha1.c' ],
|
||||
'srcs': [ 'bus/dispatch-sha1.c', 'bus/common.c' ],
|
||||
'link': [ libdbus_testutils, libdbus_daemon_internal, ],
|
||||
'install': false,
|
||||
'suite': ['slow'],
|
||||
},
|
||||
{
|
||||
'name': 'bus-dispatch',
|
||||
'srcs': [ 'bus/dispatch.c' ],
|
||||
'srcs': [ 'bus/dispatch.c', 'bus/common.c' ],
|
||||
'link': [ libdbus_testutils, libdbus_daemon_internal, ],
|
||||
'install': false,
|
||||
'suite': ['slow'],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue