aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorAaron Rossetto <aaron.rossetto@ni.com>2020-03-02 09:52:34 -0600
committerAaron Rossetto <aaron.rossetto@ni.com>2020-03-13 14:17:30 -0500
commit5fb585c328a45b022744e884ec9d52808a9354cb (patch)
tree77d836399868ac84787daa81fe3b09afb022beb7 /host
parent39158d18bd757111bd8356b46a7d53b971867559 (diff)
downloaduhd-5fb585c328a45b022744e884ec9d52808a9354cb.tar.gz
uhd-5fb585c328a45b022744e884ec9d52808a9354cb.tar.bz2
uhd-5fb585c328a45b022744e884ec9d52808a9354cb.zip
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.
Diffstat (limited to 'host')
-rw-r--r--host/tests/rfnoc_graph_mock_nodes.hpp10
1 files changed, 6 insertions, 4 deletions
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<std::string> expected_actions = {})
- : _num_ports(num_ports), _term_count(counter++)
+ mock_terminator_t(const size_t num_ports,
+ const std::vector<std::string> 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;