This series implements a scriptable test infrastructure for mctpd, mocking both the netlink and AF_MCTP interfaces, to allow arbitrary kernel and external network state.
The majority of the code is a new pytest fixture, which provides small socket interface to an external program (in our case, mctpd), over which the netlink and MCTP communication can be simulated. This allows us to write fairly straightforward tests, including the example in this change:
""" Test the SetupEndpoint dbus call
Using the default system & network ojects, call SetupEndpoint on our mock
endpoint. We expect the dbus call to return the endpoint details, and
the new kernel neighbour and route entries.
"""
async def test_setup_endpoint(dbus, mctpd):
# shortcuts to the default system/network configuration
iface = mctpd.system.interfaces[0]
ep = mctpd.network.endpoints[0]
# our proxy dbus object for mctpd
mctp = await mctpd_mctp_obj(dbus)
# call SetupEndpoint. This will raise an exception on any dbus error.
(eid, net, path, new) = await mctp.call_setup_endpoint(iface.name, ep.lladdr)
# ep.eid will be updated (through the Set Endpoint ID message); this
# should match the returned EID
assert eid == ep.eid
# we should have a neighbour for the new endpoint
assert len(mctpd.system.neighbours) == 1
neigh = mctpd.system.neighbours[0]
assert neigh.lladdr == ep.lladdr
assert neigh.eid == ep.eid
# we should have a route for the new endpoint too
assert len(mctpd.system.routes) == 2
This series implements a scriptable test infrastructure for mctpd, mocking both the netlink and AF_MCTP interfaces, to allow arbitrary kernel and external network state.
The majority of the code is a new pytest fixture, which provides small socket interface to an external program (in our case, mctpd), over which the netlink and MCTP communication can be simulated. This allows us to write fairly straightforward tests, including the example in this change: