Skip to content
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
6 changes: 6 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ jobs:
- name: Test mctp
run: meson test -C build --verbose

- name: Check python tests
run: ruff check tests/

- name: Format python tests
run: ruff format --diff tests/

- uses: actions/upload-artifact@v4
if: always()
with:
Expand Down
22 changes: 13 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@

import sys

import pytest
import asyncdbus
import trio.testing

import mctpenv

"""Simple system & network.

Contains one interface (lladdr 0x10, local EID 8), and one endpoint (lladdr
0x1d), that reports support for MCTP control and PLDM.
"""
@pytest.fixture
async def sysnet():
"""Simple system & network.

Contains one interface (lladdr 0x10, local EID 8), and one endpoint (lladdr
0x1d), that reports support for MCTP control and PLDM.
"""
return await mctpenv.default_sysnet()


@pytest.fixture
async def dbus():
async with asyncdbus.MessageBus().connect() as bus:
yield bus


@pytest.fixture
def config():
return None


@pytest.fixture
async def mctpd(nursery, dbus, sysnet, config):
m = mctpenv.MctpdWrapper(dbus, sysnet, config = config)
m = mctpenv.MctpdWrapper(dbus, sysnet, config=config)
await m.start_mctpd(nursery)
yield m
res = await m.stop_mctpd()
assert res == 0


@pytest.fixture
async def mctp(nursery, sysnet):
return mctpenv.MctpWrapper(nursery, sysnet)


@pytest.fixture
def autojump_clock():
"""
Custom autojump clock with a reasonable threshold for non-time I/O waits
"""
return trio.testing.MockClock(autojump_threshold=0.01)


@pytest.fixture
async def routed_ep(mctpd):
"""
Expand All @@ -54,7 +58,7 @@ async def routed_ep(mctpd):
iface = mctpd.system.interfaces[0]

ep.eid = 9
route = mctpd.system.Route(ep.eid, 1, iface = iface)
route = mctpd.system.Route(ep.eid, 1, iface=iface)
neigh = mctpd.system.Neighbour(iface, ep.lladdr, ep.eid)
await mctpd.system.add_route(route)
await mctpd.system.add_neighbour(neigh)
Expand Down
47 changes: 24 additions & 23 deletions tests/mctp_test_utils.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
async def mctpd_mctp_base_iface_obj(dbus):
obj = await dbus.get_proxy_object(
'au.com.codeconstruct.MCTP1',
'/au/com/codeconstruct/mctp1'
)
'au.com.codeconstruct.MCTP1', '/au/com/codeconstruct/mctp1'
)
return await obj.get_interface('au.com.codeconstruct.MCTP1')


async def mctpd_mctp_iface_obj(dbus, iface):
obj = await dbus.get_proxy_object(
'au.com.codeconstruct.MCTP1',
'/au/com/codeconstruct/mctp1/interfaces/' + iface.name
)
'au.com.codeconstruct.MCTP1',
'/au/com/codeconstruct/mctp1/interfaces/' + iface.name,
)
return await obj.get_interface('au.com.codeconstruct.MCTP.BusOwner1')


async def mctpd_mctp_iface_control_obj(dbus, iface):
obj = await dbus.get_proxy_object(
"au.com.codeconstruct.MCTP1",
"/au/com/codeconstruct/mctp1/interfaces/" + iface.name,
)
"au.com.codeconstruct.MCTP1",
"/au/com/codeconstruct/mctp1/interfaces/" + iface.name,
)
return await obj.get_interface("au.com.codeconstruct.MCTP.Interface1")


async def mctpd_mctp_endpoint_obj(dbus, path, iface):
obj = await dbus.get_proxy_object(
'au.com.codeconstruct.MCTP1',
path,
)
'au.com.codeconstruct.MCTP1',
path,
)
return await obj.get_interface(iface)


async def mctpd_mctp_network_obj(dbus, net):
obj = await dbus.get_proxy_object(
'au.com.codeconstruct.MCTP1',
f'/au/com/codeconstruct/mctp1/networks/{net:d}'
)
'au.com.codeconstruct.MCTP1',
f'/au/com/codeconstruct/mctp1/networks/{net:d}',
)
iface = await obj.get_interface('au.com.codeconstruct.MCTP.Network1')
# fixup autogenerated snake-case names
iface.get_local_eids = iface.get_local_ei_ds
iface.set_local_eids = iface.set_local_ei_ds
return iface


async def mctpd_mctp_endpoint_control_obj(dbus, path):
return await mctpd_mctp_endpoint_obj(
dbus,
path,
'au.com.codeconstruct.MCTP.Endpoint1'
)
dbus, path, 'au.com.codeconstruct.MCTP.Endpoint1'
)


async def mctpd_mctp_endpoint_common_obj(dbus, path):
return await mctpd_mctp_endpoint_obj(
dbus,
path,
'xyz.openbmc_project.MCTP.Endpoint'
)
dbus, path, 'xyz.openbmc_project.MCTP.Endpoint'
)
Loading