Skip to content

Commit

Permalink
test: install test executables if requested
Browse files Browse the repository at this point in the history
This introduces a new meson option 'install-tests' (disabled by default)
that allows installing built test executables along with regular stuff,
which can be used to ensure the installed dbus-broker works as expected.

The tests are installed into <prefix>/share/dbus-broker/tests directory,
and split into 'unit' and 'dbus' subdirectories, similarly as they're in
the source tree:

$ meson setup --prefix=/usr -Dselinux=true -Dreference-test=true -Dinstall-tests=true build
...
$ DESTDIR=$PWD/install-test ninja -C build install
...
$ tree install-test
install-test
└── usr
    ├── bin
    │   ├── dbus-broker
    │   └── dbus-broker-launch
    ├── lib
    │   └── systemd
    │       ├── catalog
    │       │   ├── dbus-broker.catalog
    │       │   └── dbus-broker-launch.catalog
    │       ├── system
    │       │   └── dbus-broker.service
    │       └── user
    │           └── dbus-broker.service
    └── share
        └── dbus-broker
            └── tests
                ├── dbus
                │   ├── bench-connect
                │   ├── bench-message
                │   ├── test-broker
                │   ├── test-driver
                │   ├── test-fdstream
                │   ├── test-lifetime
                │   └── test-matches
                └── unit
                    ├── test-address
                    ├── test-apparmor
...
                    ├── test-stitching
                    ├── test-systemd
                    └── test-user

13 directories, 36 files

$ install-test/usr/share/dbus-broker/tests/dbus/test-broker
Using dbus-broker binary /usr/bin/dbus-broker
Using dbus-broker binary /usr/bin/dbus-broker
Using dbus-broker binary /usr/bin/dbus-broker
Using dbus-broker binary /usr/bin/dbus-broker
  • Loading branch information
mrc0mmand committed Mar 22, 2024
1 parent 45fd9a3 commit 9b6e6ff
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 31 deletions.
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') / 'share/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')
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
120 changes: 97 additions & 23 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -173,75 +173,149 @@ 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)
41 changes: 33 additions & 8 deletions test/dbus/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ dep_test = declare_dependency(
version: meson.project_version(),
)

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

#
# target: tool-*
#
Expand All @@ -47,19 +52,39 @@ tool_flood = executable('tool-flood', ['tool-flood.c'], dependencies: [dep_test]
# target: bench-*
#

bench_connect = executable('bench-connect', ['bench-connect.c'], dependencies: [dep_test])
bench_message = executable('bench-message', ['bench-message.c'], dependencies: [dep_test])
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_driver = executable('test-driver', ['test-driver.c'], dependencies: [dep_test])
test_fdstream = executable('test-fdstream', ['test-fdstream.c'], dependencies: [dep_test])
test_lifetime = executable('test-lifetime', ['test-lifetime.c'], dependencies: [dep_test])
test_matches = executable('test-matches', ['test-matches.c'], dependencies: [dep_test])

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)

suites = [
{ 'suite': 'dbus-broker(1)', 'env': ['TEST_DBUS_BROKER=' + exe_dbus_broker.full_path()]},
Expand Down

0 comments on commit 9b6e6ff

Please sign in to comment.