From 5fb585c328a45b022744e884ec9d52808a9354cb Mon Sep 17 00:00:00 2001 From: Aaron Rossetto Date: Mon, 2 Mar 2020 09:52:34 -0600 Subject: tests: Allow custom name for mock terminator Allow a unit test to instantiate a mock_terminator_t and provide a custom name to be displayed when get_unique_id() is called (generally for logging purposes). The custom name is optional and the generic 'MOCK_TERMINATOR' is used if unset. --- host/tests/rfnoc_graph_mock_nodes.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'host/tests') diff --git a/host/tests/rfnoc_graph_mock_nodes.hpp b/host/tests/rfnoc_graph_mock_nodes.hpp index 564858916..63e542e40 100644 --- a/host/tests/rfnoc_graph_mock_nodes.hpp +++ b/host/tests/rfnoc_graph_mock_nodes.hpp @@ -360,9 +360,10 @@ class mock_terminator_t : public node_t public: static size_t counter; - mock_terminator_t( - const size_t num_ports, const std::vector expected_actions = {}) - : _num_ports(num_ports), _term_count(counter++) + mock_terminator_t(const size_t num_ports, + const std::vector expected_actions = {}, + const std::string name = "MOCK_TERMINATOR") + : _num_ports(num_ports), _term_count(counter++), _name(name) { set_prop_forwarding_policy(forwarding_policy_t::DROP); set_action_forwarding_policy(forwarding_policy_t::DROP); @@ -380,7 +381,7 @@ public: std::string get_unique_id() const { - return "MOCK_TERMINATOR" + std::to_string(_term_count); + return _name + std::to_string(_term_count); } size_t get_num_input_ports() const @@ -423,6 +424,7 @@ public: private: const size_t _num_ports; const size_t _term_count; + const std::string _name; }; size_t mock_terminator_t::counter = 0; -- cgit v1.2.3