From 39158d18bd757111bd8356b46a7d53b971867559 Mon Sep 17 00:00:00 2001 From: Aaron Rossetto Date: Mon, 2 Mar 2020 09:49:42 -0600 Subject: tests: Allow custom mock_reg_iface_t in mock block Allow clients to pass a custom instance of a mock_reg_iface_t for use with mock_block_container. This is especially useful when a block test subclasses mock_reg_iface_t to implement specialized behaviors. --- host/include/uhd/rfnoc/mock_block.hpp | 12 ++++++------ host/lib/rfnoc/mock_block.cpp | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/host/include/uhd/rfnoc/mock_block.hpp b/host/include/uhd/rfnoc/mock_block.hpp index ab7a79f42..a388a9359 100644 --- a/host/include/uhd/rfnoc/mock_block.hpp +++ b/host/include/uhd/rfnoc/mock_block.hpp @@ -180,12 +180,12 @@ struct UHD_API mock_block_container /*! Factory function for mock block controllers */ UHD_API mock_block_container get_mock_block(const noc_id_t noc_id, - const size_t num_inputs = 1, - const size_t num_outputs = 1, - const uhd::device_addr_t& args = uhd::device_addr_t(), - const size_t mtu = 8000, - const device_type_t device_id = ANY_DEVICE); - + const size_t num_inputs = 1, + const size_t num_outputs = 1, + const uhd::device_addr_t& args = uhd::device_addr_t(), + const size_t mtu = 8000, + const device_type_t device_id = ANY_DEVICE, + std::shared_ptr client_reg_iface = nullptr); }}; // namespace uhd::rfnoc diff --git a/host/lib/rfnoc/mock_block.cpp b/host/lib/rfnoc/mock_block.cpp index ee35eae7e..834803bd5 100644 --- a/host/lib/rfnoc/mock_block.cpp +++ b/host/lib/rfnoc/mock_block.cpp @@ -18,13 +18,15 @@ uhd::rfnoc::mock_block_container uhd::rfnoc::get_mock_block(const noc_id_t noc_i const size_t num_outputs, const device_addr_t& args, const size_t mtu, - const device_type_t device_id) + const device_type_t device_id, + std::shared_ptr client_reg_iface) { block_factory_info_t fac_info = factory::get_block_factory(noc_id, device_id); mock_block_container ret_val; ret_val.factory = fac_info.factory_fn; - ret_val.reg_iface = std::make_shared(); + ret_val.reg_iface = (client_reg_iface) ? client_reg_iface + : std::make_shared(); ret_val.tree = uhd::property_tree::make(); // Create make args ret_val.make_args = std::make_unique(); -- cgit v1.2.3