diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 42b47fc..b1a966b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -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 @@ -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 diff --git a/meson.build b/meson.build index 1a88f37..f93d28c 100644 --- a/meson.build +++ b/meson.build @@ -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', ) diff --git a/tests/pytest.ini.in b/tests/pytest.ini similarity index 86% rename from tests/pytest.ini.in rename to tests/pytest.ini index 3185622..30a9412 100644 --- a/tests/pytest.ini.in +++ b/tests/pytest.ini @@ -1,6 +1,5 @@ [pytest] trio_mode = true -testpaths = @testpaths@ filterwarnings = ignore:.*wait_readable:DeprecationWarning:asyncdbus ignore:.*wait_writable:DeprecationWarning:asyncdbus