Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: allow installing built test executables #351

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ if use_docs
prog_rst2man = find_program('rst2man', 'rst2man.py')
endif

#
# Config: install-tests
#
install_tests = get_option('install-tests')
test_install_dir = get_option('prefix') / 'lib/dbus-broker/tests'

#
# Config: launcher
#
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
option('apparmor', type: 'boolean', value: false, description: 'AppArmor support')
option('audit', type: 'boolean', value: false, description: 'Audit support')
option('docs', type: 'boolean', value: false, description: 'Build documentation')
option('install-tests', type: 'boolean', value: false, description: 'Install test executables')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just tests similar to docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue here is that the docs option controls whether we build the docs at all, but introducing tests in its current form would control only the installation of the tests since we build most of the tests by default - i.e. -Dtests=false would still build tests. Maybe the current behavior should change, so the tests aren't build by default, and let it be controlled by -Dtests=?

option('launcher', type: 'boolean', value: true, description: 'Build compatibility launcher')
option('linux-4-17', type: 'boolean', value: false, description: 'Require linux-4.17 at runtime and make use of its features')
option('reference-test', type: 'boolean', value: false, description: 'Run test suite against reference implementation')
Expand Down
166 changes: 143 additions & 23 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -173,75 +173,195 @@ endif
# target: test-*
#

test_address = executable('test-address', ['dbus/test-address.c'], dependencies: dep_bus)
test_unit_install_kwargs = {
'install': install_tests,
'install_dir': test_install_dir / 'unit',
}

test_address = executable(
'test-address',
sources: ['dbus/test-address.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('Address Handling', test_address)

test_apparmor = executable('test-apparmor', ['util/test-apparmor.c'], dependencies: dep_bus)
test_apparmor = executable(
'test-apparmor',
sources: ['util/test-apparmor.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('AppArmor Handling', test_apparmor)

if use_launcher
test_config = executable('test-config', ['launch/test-config.c'], dependencies: dep_bus)
test_config = executable(
'test-config',
sources: ['launch/test-config.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('Configuration Parser', test_config)
endif

test_dirwatch = executable('test-dirwatch', ['util/test-dirwatch.c'], dependencies: dep_bus)
test_dirwatch = executable(
'test-dirwatch',
sources: ['util/test-dirwatch.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('Directory Watch', test_dirwatch)

test_dispatch = executable('test-dispatch', ['util/test-dispatch.c'], dependencies: dep_bus)
test_dispatch = executable(
'test-dispatch',
sources: ['util/test-dispatch.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('Event Dispatcher', test_dispatch)

test_error = executable('test-error', ['util/test-error.c'], dependencies: dep_bus)
test_error = executable(
'test-error',
sources: ['util/test-error.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('Error Handling', test_error)

test_fdlist = executable('test-fdlist', ['util/test-fdlist.c'], dependencies: dep_bus)
test_fdlist = executable(
'test-fdlist',
sources: ['util/test-fdlist.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('Utility File-Desciptor Lists', test_fdlist)

test_fs = executable('test-fs', ['util/test-fs.c'], dependencies: dep_bus)
test_fs = executable(
'test-fs',
sources: ['util/test-fs.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('File System Helpers', test_fs)

test_match = executable('test-match', ['bus/test-match.c'], dependencies: dep_bus)
test_match = executable(
'test-match',
sources: ['bus/test-match.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('D-Bus Match Handling', test_match)

test_message = executable('test-message', ['dbus/test-message.c'], dependencies: dep_bus)
test_message = executable(
'test-message',
sources: ['dbus/test-message.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('D-Bus Message Abstraction', test_message)

test_misc = executable('test-misc', ['util/test-misc.c'], dependencies: dep_bus)
test_misc = executable(
'test-misc',
sources: ['util/test-misc.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('Miscellaneous Helpers', test_misc)

test_name = executable('test-name', ['bus/test-name.c'], dependencies: dep_bus)
test_name = executable(
'test-name',
sources: ['bus/test-name.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('Name Registry', test_name)

if use_launcher
test_nss_cache = executable('test-nss-cache', ['launch/test-nss-cache.c'], dependencies: dep_bus)
test_nss_cache = executable(
'test-nss-cache',
sources: ['launch/test-nss-cache.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('NSS Cache', test_nss_cache)
endif

test_peersec = executable('test-peersec', ['util/test-peersec.c'], dependencies: dep_bus)
test_peersec = executable(
'test-peersec',
sources: ['util/test-peersec.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('SO_PEERSEC Queries', test_peersec)

test_proc = executable('test-proc', ['util/test-proc.c'], dependencies: dep_bus)
test_proc = executable(
'test-proc',
sources: ['util/test-proc.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('Proc Utilities', test_proc)

test_queue = executable('test-queue', ['dbus/test-queue.c'], dependencies: dep_bus)
test_queue = executable(
'test-queue',
sources: ['dbus/test-queue.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('D-Bus I/O Queues', test_queue)

test_reply = executable('test-reply', ['bus/test-reply.c'], dependencies: dep_bus)
test_reply = executable(
'test-reply',
sources: ['bus/test-reply.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('Reply Tracking', test_reply)

test_sasl = executable('test-sasl', ['dbus/test-sasl.c'], dependencies: dep_bus)
test_sasl = executable(
'test-sasl',
sources: ['dbus/test-sasl.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('D-Bus SASL Parser', test_sasl)

test_socket = executable('test-socket', ['dbus/test-socket.c'], dependencies: dep_bus)
test_socket = executable(
'test-socket',
sources: ['dbus/test-socket.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('D-Bus Socket Abstraction', test_socket)

test_sockopt = executable('test-sockopt', ['util/test-sockopt.c'], dependencies: dep_bus)
test_sockopt = executable(
'test-sockopt',
sources: ['util/test-sockopt.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('D-Bus Socket Options', test_sockopt)

test_stitching = executable('test-stitching', ['dbus/test-stitching.c'], dependencies: dep_bus)
test_stitching = executable(
'test-stitching',
sources: ['dbus/test-stitching.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('Message Sender Stitching', test_stitching)

test_systemd = executable('test-systemd', ['util/test-systemd.c'], dependencies: dep_bus)
test_systemd = executable(
'test-systemd',
sources: ['util/test-systemd.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('Systemd Utilities', test_systemd)

test_user = executable('test-user', ['util/test-user.c'], dependencies: dep_bus)
test_user = executable(
'test-user',
sources: ['util/test-user.c'],
dependencies: dep_bus,
kwargs: test_unit_install_kwargs
)
test('User Accounting', test_user)
111 changes: 66 additions & 45 deletions test/dbus/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -37,66 +37,87 @@ dep_test = declare_dependency(
version: meson.project_version(),
)

test_dbus_install_kwargs = {
'install': install_tests,
'install_dir': test_install_dir / 'dbus',
}

#
# target: tool-*
#

tool_flood = executable('tool-flood', ['tool-flood.c'], dependencies: [ dep_test ])
tool_flood = executable('tool-flood', ['tool-flood.c'], dependencies: [dep_test])

#
# target: bench-*
#

bench_connect = executable('bench-connect', ['bench-connect.c'], dependencies: [ dep_test ])
benchmark('Connection', bench_connect)

bench_message = executable('bench-message', ['bench-message.c'], dependencies: [ dep_test ])
benchmark('Message passing', bench_message)
bench_connect = executable(
'bench-connect',
sources: ['bench-connect.c'],
dependencies: [dep_test],
kwargs: test_dbus_install_kwargs
)
bench_message = executable(
'bench-message',
sources: ['bench-message.c'],
dependencies: [dep_test],
kwargs: test_dbus_install_kwargs
)

#
# target: test-*
#

test_broker = executable('test-broker', ['test-broker.c'], dependencies: [ dep_test ])
test('Broker API', test_broker)

test_driver = executable('test-driver', ['test-driver.c'], dependencies: [ dep_test ])
test('Driver API', test_driver)

test_fdstream = executable('test-fdstream', ['test-fdstream.c'], dependencies: [ dep_test ])
test('FD Stream Constraints', test_fdstream)

test_lifetime = executable('test-lifetime', ['test-lifetime.c'], dependencies: [ dep_test ])
test('Client Lifetime', test_lifetime)
test_broker = executable(
'test-broker',
sources: ['test-broker.c'],
dependencies: [dep_test],
kwargs: test_dbus_install_kwargs
)
test_driver = executable(
'test-driver',
sources: ['test-driver.c'],
dependencies: [dep_test],
kwargs: test_dbus_install_kwargs
)
test_fdstream = executable(
'test-fdstream',
sources: ['test-fdstream.c'],
dependencies: [dep_test],
kwargs: test_dbus_install_kwargs
)
test_lifetime = executable(
'test-lifetime',
sources: ['test-lifetime.c'],
dependencies: [dep_test],
kwargs: test_dbus_install_kwargs
)
test_matches = executable(
'test-matches',
sources: ['test-matches.c'],
dependencies: [dep_test],
kwargs: test_dbus_install_kwargs
)

test_matches = executable('test-matches', ['test-matches.c'], dependencies: [ dep_test ])
test('Signals and Matches', test_matches)
suites = [
{ 'suite': 'dbus-broker(1)', 'env': ['DBUS_BROKER_TEST_BROKER=' + exe_dbus_broker.full_path()]},
]

if use_reference_test
dbus_bin = dep_dbus.get_variable(pkgconfig: 'bindir') + '/dbus-daemon'

benchmark('Connection', bench_connect,
suite: 'dbus-daemon(1)',
env: [ 'DBUS_BROKER_TEST_DAEMON=' + dbus_bin ],
timeout: 60)
benchmark('Message passing', bench_message,
suite: 'dbus-daemon(1)',
env: [ 'DBUS_BROKER_TEST_DAEMON=' + dbus_bin ],
timeout: 120)

test('Broker API', test_broker,
suite: 'dbus-daemon(1)',
env: [ 'DBUS_BROKER_TEST_DAEMON=' + dbus_bin ])
test('Driver API', test_driver,
suite: 'dbus-daemon(1)',
env: [ 'DBUS_BROKER_TEST_DAEMON=' + dbus_bin ])
test('FD Stream Constraints', test_fdstream,
suite: 'dbus-daemon(1)',
env: [ 'DBUS_BROKER_TEST_DAEMON=' + dbus_bin ])
test('Client Lifetime', test_lifetime,
suite: 'dbus-daemon(1)',
env: [ 'DBUS_BROKER_TEST_DAEMON=' + dbus_bin ])
test('Signals and Matches', test_matches,
suite: 'dbus-daemon(1)',
env: [ 'DBUS_BROKER_TEST_DAEMON=' + dbus_bin ])
dbus_daemon_bin = dep_dbus.get_variable(pkgconfig: 'bindir') + '/dbus-daemon'
suites += [
{ 'suite': 'dbus-daemon(1)', 'env': ['DBUS_BROKER_TEST_DAEMON=' + dbus_daemon_bin]},
]
endif

foreach suite : suites
benchmark('Connection', bench_connect, timeout: 60, kwargs: suite)
benchmark('Message passing', bench_message, timeout: 120, kwargs: suite)

test('Broker API', test_broker, kwargs: suite)
test('Driver API', test_driver, kwargs: suite)
test('FD Stream Constraints', test_fdstream, kwargs: suite)
test('Client Lifetime', test_lifetime, kwargs: suite)
test('Signals and Matches', test_matches, kwargs: suite)
endforeach
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for that!

Loading
Loading