Skip to content

meson: mctpd_test is only required for mctpd-enabled builds #104

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
29 changes: 27 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: pull-request-ci
on: [push, pull_request]
jobs:
run-tests:
default:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -27,4 +27,29 @@ jobs:
run: ninja -C build clang-format-check

- name: Test mctp
run: meson test -C build
run: meson test -C build --verbose

no-libsystemd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install system build dependencies
run: >
sudo apt-get update &&
sudo apt-get install ninja-build

- name: Install meson
run: pip install --user meson

- name: Install python dependencies for mctp tests
run: pip install --user -r tests/requirements.txt

- name: Configure mctp build
run: meson setup build -Db_sanitize=address

- name: Build mctp
run: meson compile -C build

- name: Test mctp
run: meson test -C build --verbose
44 changes: 28 additions & 16 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -137,24 +137,36 @@ if tests
# to allow pytest to print output directly onto the terminal without
# redirecting to a file. We can detect this if stdout is an terminal, and
# disable TAP protocol.
pytest = find_program('pytest')
script = '''export DBUS_STARTER_BUS_TYPE=user; if [ ! -t 1 ]; then PYTEST_FLAGS="--tap"; fi; @0@ $PYTEST_FLAGS $@'''.format(pytest.full_path())
sh = find_program('sh')
dbus_run_session = find_program('dbus-run-session')
test_dir = join_paths(meson.current_source_dir(), 'tests')
pytest_conf = join_paths(test_dir, 'pytest.ini')

test_conf_data = configuration_data()
test_conf_data.set('testpaths',
join_paths(meson.current_source_dir(), 'tests')
)
configure_file(
input: 'tests/pytest.ini.in',
output: 'pytest.ini',
configuration: test_conf_data,
pytest = find_program('pytest')
script = 'if [ ! -t 1 ]; then PFL="--tap"; fi; DBUS_STARTER_BUS_TYPE=user "@0@" $PFL --config-file "@1@" $@'.format(
pytest.full_path(),
pytest_conf,
)

test('test-mctpd', dbus_run_session,
depends: [mctpd_test, mctp_test],
args: [ sh.full_path(), '-c', script, '--' ],
sh = find_program('sh')
test_args = [ '-c', script, '--' ]

if libsystemd.found()
dbus_run_session = find_program('dbus-run-session')

test('test-mctpd', dbus_run_session,
depends: [mctpd_test],
args: [sh.full_path()] + test_args + [test_dir / 'test_mctpd.py'],
protocol: 'tap',
)

test('test-mctpd-endpoint', dbus_run_session,
depends: [mctpd_test],
args: [sh.full_path()] + test_args + [test_dir / 'test_mctpd_endpoint.py'],
protocol: 'tap',
)
endif

test('test-mctp', sh,
depends: [mctp_test],
args: test_args + [test_dir / 'test_mctp.py'],
protocol: 'tap',
)

Expand Down
1 change: 0 additions & 1 deletion tests/pytest.ini.in → tests/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[pytest]
trio_mode = true
testpaths = @testpaths@
filterwarnings =
ignore:.*wait_readable:DeprecationWarning:asyncdbus
ignore:.*wait_writable:DeprecationWarning:asyncdbus