mctp/server: add mock-transport test suite
Add a comprehensive set of integration and unit tests for the MCTP server
that run without the I2C transport layer. A BufferSender mock replaces
the real I2C sender; no transport hardware or system linker is required.
New files:
- tests/common/mod.rs -- shared fixtures: BufferSender, DroppingBufferSender,
DirectClient, DirectListener, DirectRespChannel,
DirectReqChannel, transfer()
- tests/server_unit.rs -- unit tests for Server methods: EID management,
handle alloc/free, try_recv, inbound routing,
oversized payload, register_recv + timeout
- tests/integration.rs -- multi-fragment reassembly, concurrent listeners,
echo via MctpListener+MctpRespChannel traits,
MctpReqChannel, drop_handle mid-flight,
response EID/tag threading
Updated files:
- tests/echo.rs -- refactored to use common/ (no duplicated fixtures)
- tests/dispatch.rs -- refactored to use common/; added edge-case tests:
malformed request, unknown opcode, Recv with no
message, Unbind
- BUILD.bazel -- four new rust_test targets, one per test file
- README.md -- document new test layout and Bazel invocations
All four Bazel test targets pass:
bazel test //services/mctp/server:mctp_server_{echo,dispatch,unit,integration}_test
The OpenPRoT Technical Charter can be found at https://github.com/OpenPRoT/.github/blob/main/GOVERNANCE.md
This project uses cargo-xtask for build automation and project management.
You can run tasks using cargo xtask <task-name>:
cargo xtask build - Build the projectcargo xtask test - Run all testscargo xtask check - Run cargo checkcargo xtask clippy - Run clippy lintscargo xtask fmt - Format code with rustfmtcargo xtask clean - Clean build artifactscargo xtask dist - Build a distribution (release build)cargo xtask docs - Build documentation with mdbookcargo xtask cargo-lock - Manage Cargo.lock filecargo xtask precheckin - Run all pre-checkin validation checkscargo xtask header-check - Check license headers in source filescargo xtask header-fix - Fix missing license headers in source files# Build the project cargo xtask build # Run tests cargo xtask test # Create a distribution cargo xtask dist # Format code cargo xtask fmt # Run clippy cargo xtask clippy # Build documentation cargo xtask docs # Run all pre-checkin validation checks cargo xtask precheckin # Check license headers cargo xtask header-check # Fix missing license headers cargo xtask header-fix
The project is structured as a Cargo workspace with two main components:
openprot/ - The main applicationxtask/ - Build automation scriptsThe xtask workflow allows you to add custom build steps, automation, and project management tasks written in Rust, making them cross-platform and easy to maintain.
No additional tools are required - everything is handled through Cargo and the xtask scripts.