Skip to content

Commit

Permalink
Merge branch 'gh-action-pr-ci' of github.com:amboar/mctp
Browse files Browse the repository at this point in the history
CHANGELOG conflicts merged

Signed-off-by: Jeremy Kerr <[email protected]>
  • Loading branch information
jk-ozlabs committed Feb 1, 2024
2 parents 1561633 + 77d1714 commit 0070bc0
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 7 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: pull-request-ci
on: [push, pull_request]
jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install system build dependencies
run: >
sudo apt-get update &&
sudo apt-get install libsystemd-dev 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

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

- name: Test mctp
run: meson test -C build
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1. dbus interface: the NetworkID field is now a `u` rather than an `i`, to
match OpenBMC's MCTP endpoint specification

2. Use Github Actions for CI

Note that this bumps the meson requirement from >=0.47.0 to >=0.59.0. The
bump allows us to exploit some features helpful for chaining the solution
together.

### Fixed

1. mctpd: EID assignments now work in the case where a new endpoint has a
Expand Down
48 changes: 42 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
project(
'mctp', 'c',
meson_version: '>= 0.47.0',
meson_version: '>= 0.59.0',
version: 'v1.1',
license: 'GPLv2',
default_options: [
Expand All @@ -11,6 +11,7 @@ project(
)

cc = meson.get_compiler('c')

add_project_arguments('-Wno-unused-parameter', language : 'c')

libsystemd = dependency('libsystemd', version: '>=247', required: false)
Expand Down Expand Up @@ -80,11 +81,46 @@ configure_file(
configuration: test_conf_data,
)

pytest = find_program('pytest', required: false)

if pytest.found()
test('test-mctpd', pytest,
args: '--tap',
tests = get_option('tests')
if tests.allowed()
# The test suite contains integration-style tests that we wish to isolate.
# The tests drive mctpd's D-Bus interfaces and navigate relevant code paths
# by mocking kernel and MCTP device behaviour. The mock behaviours are
# implemented by encapsulating netlink and MCTP messages over Unix domain
# sockets bound to mock implementations in the test suite.
#
# Isolate the test suite under its own D-Bus session to prevent test
# behaviours impacting applications connected to the usual buses. To
# implement the isolation we need to work under some constraints:
#
# 1. mctpd's implementation connects to a bus by invoking `sd_bus_default()`,
# which uses a combination of environment variables and session
# properties to determine whether to connect to the system bus or the
# session bus
#
# 2. dbus-run-session configures an isolated session bus and controls the
# relevant environment variables for influencing the application to
# connect to this isolated bus instance.
#
# `sd_bus_default()` selects the system bus if the application is
# not running in a systemd user slice. From experience, in a Github
# Action environment the system bus is selected by `sd_bus_default()`,
# implying that they aren't exploiting systemd slices. However,
# `sd_bus_default()` can be influenced to select the user session by setting
# `DBUS_STARTER_BUS_TYPE=user` in the environment. At this point with a
# naive approach we run up against 2, where `dbus-run-session` sanitises
# that configuration away
#
# Invoke pytest via a shell script under `dbus-run-session` so we can
# override the sanitation of `DBUS_STARTER_BUS_TYPE`, ensuring `test-mctpd`
# connects to the isolated session bus prepared by `dbus-run-session`.
pytest = find_program('pytest', required: tests)
script = 'export DBUS_STARTER_BUS_TYPE=user ; @0@ --tap'.format(pytest.full_path())
sh = find_program('sh', required: tests)
dbus_run_session = find_program('dbus-run-session', required: tests)
test('test-mctpd', dbus_run_session,
depends: mctpd_test,
args: [ sh.full_path(), '-c', script ],
protocol: 'tap',
)
endif
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ option('unsafe-writable-connectivity',
type: 'boolean',
value: false,
description: 'Allow writes to the Connectivity member of the au.com.CodeConstruct.MCTP.Endpoint interface on endpoint objects')
option('tests', type: 'feature')
3 changes: 2 additions & 1 deletion tests/test-proto.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

#include <stdint.h>

#include <linux/mctp.h>
#include <linux/netlink.h>

#include "mctp.h"

enum {
CONTROL_OP_INIT,
CONTROL_OP_SOCKET_MCTP,
Expand Down

0 comments on commit 0070bc0

Please sign in to comment.