aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests
diff options
context:
space:
mode:
Diffstat (limited to 'host/tests')
-rw-r--r--host/tests/CMakeLists.txt57
-rw-r--r--host/tests/common/CMakeLists.txt6
-rw-r--r--host/tests/common/mock_ctrl_iface_impl.cpp38
-rw-r--r--host/tests/common/mock_ctrl_iface_impl.hpp29
-rw-r--r--host/tests/common/mock_zero_copy.hpp2
-rw-r--r--host/tests/device3_test.cpp201
-rw-r--r--host/tests/graph.hpp47
-rw-r--r--host/tests/graph_search_test.cpp161
-rw-r--r--host/tests/nocscript_common.hpp30
-rw-r--r--host/tests/nocscript_expr_test.cpp405
-rw-r--r--host/tests/nocscript_ftable_test.cpp248
-rw-r--r--host/tests/nocscript_parser_test.cpp147
-rw-r--r--host/tests/node_connect_test.cpp127
-rw-r--r--host/tests/packet_handler_benchmark.cpp8
-rw-r--r--host/tests/rate_node_test.cpp136
-rw-r--r--host/tests/sid_t_test.cpp155
-rw-r--r--host/tests/stream_sig_test.cpp75
-rw-r--r--host/tests/tick_node_test.cpp116
18 files changed, 6 insertions, 1982 deletions
diff --git a/host/tests/CMakeLists.txt b/host/tests/CMakeLists.txt
index d790b214e..8a477b181 100644
--- a/host/tests/CMakeLists.txt
+++ b/host/tests/CMakeLists.txt
@@ -42,7 +42,6 @@ set(test_sources
property_test.cpp
ranges_test.cpp
scope_exit_test.cpp
- sid_t_test.cpp
sensors_test.cpp
soft_reg_test.cpp
sph_recv_test.cpp
@@ -53,29 +52,16 @@ set(test_sources
vrt_test.cpp
expert_test.cpp
fe_conn_test.cpp
- rfnoc_node_test.cpp
link_test.cpp
rx_streamer_test.cpp
tx_streamer_test.cpp
+ block_id_test.cpp
+ rfnoc_property_test.cpp
)
#turn each test cpp file into an executable with an int main() function
add_definitions(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
-if(ENABLE_RFNOC)
- list(APPEND test_sources
- block_id_test.cpp
- blockdef_test.cpp
- device3_test.cpp
- graph_search_test.cpp
- node_connect_test.cpp
- rate_node_test.cpp
- stream_sig_test.cpp
- tick_node_test.cpp
- rfnoc_property_test.cpp
- )
-endif(ENABLE_RFNOC)
-
if(ENABLE_C_API)
list(APPEND test_sources
eeprom_c_test.c
@@ -149,15 +135,6 @@ if(ENABLE_DPDK)
ENDIF(ENABLE_DPDK)
UHD_ADD_NONAPI_TEST(
- TARGET "nocscript_expr_test.cpp"
- EXTRA_SOURCES
- "${CMAKE_SOURCE_DIR}/lib/rfnoc/nocscript/expression.cpp"
- INCLUDE_DIRS
- ${CMAKE_BINARY_DIR}/lib/rfnoc/nocscript/
- ${CMAKE_SOURCE_DIR}/lib/rfnoc/nocscript/
-)
-
-UHD_ADD_NONAPI_TEST(
TARGET "system_time_test.cpp"
EXTRA_SOURCES
"${CMAKE_SOURCE_DIR}/lib/utils/system_time.cpp"
@@ -175,36 +152,6 @@ UHD_ADD_NONAPI_TEST(
NOAUTORUN # Don't register for auto-run
)
-#UHD_ADD_NONAPI_TEST(
- #TARGET "nocscript_expr_test.cpp"
- #EXTRA_SOURCES
- #"${CMAKE_SOURCE_DIR}/lib/rfnoc/nocscript/expression.cpp"
- #INCLUDE_DIRS
- #${CMAKE_BINARY_DIR}/lib/rfnoc/nocscript/
- #${CMAKE_SOURCE_DIR}/lib/rfnoc/nocscript/
-#)
-
-#UHD_ADD_NONAPI_TEST(
- #TARGET "nocscript_ftable_test.cpp"
- #EXTRA_SOURCES
- #${CMAKE_SOURCE_DIR}/lib/rfnoc/nocscript/function_table.cpp
- #${CMAKE_SOURCE_DIR}/lib/rfnoc/nocscript/expression.cpp
- #INCLUDE_DIRS
- #${CMAKE_BINARY_DIR}/lib/rfnoc/nocscript/
- #${CMAKE_SOURCE_DIR}/lib/rfnoc/nocscript/
-#)
-
-UHD_ADD_NONAPI_TEST(
- TARGET "nocscript_parser_test.cpp"
- EXTRA_SOURCES
- ${CMAKE_SOURCE_DIR}/lib/rfnoc/nocscript/parser.cpp
- ${CMAKE_SOURCE_DIR}/lib/rfnoc/nocscript/function_table.cpp
- ${CMAKE_SOURCE_DIR}/lib/rfnoc/nocscript/expression.cpp
- INCLUDE_DIRS
- ${CMAKE_BINARY_DIR}/lib/rfnoc/nocscript/
- ${CMAKE_SOURCE_DIR}/lib/rfnoc/nocscript/
-)
-
UHD_ADD_NONAPI_TEST(
TARGET "packet_handler_benchmark.cpp"
NOAUTORUN
diff --git a/host/tests/common/CMakeLists.txt b/host/tests/common/CMakeLists.txt
index 58299c688..7f31f3463 100644
--- a/host/tests/common/CMakeLists.txt
+++ b/host/tests/common/CMakeLists.txt
@@ -8,8 +8,6 @@
# Build uhd_test static lib
########################################################################
include_directories("${CMAKE_SOURCE_DIR}/lib/include")
-add_library(uhd_test ${CMAKE_CURRENT_SOURCE_DIR}/mock_ctrl_iface_impl.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/mock_zero_copy.cpp
- ${CMAKE_SOURCE_DIR}/lib/rfnoc/graph_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/rfnoc/async_msg_handler.cpp
+add_library(uhd_test
+ ${CMAKE_CURRENT_SOURCE_DIR}/mock_zero_copy.cpp
)
diff --git a/host/tests/common/mock_ctrl_iface_impl.cpp b/host/tests/common/mock_ctrl_iface_impl.cpp
deleted file mode 100644
index af32637df..000000000
--- a/host/tests/common/mock_ctrl_iface_impl.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// Copyright 2018 Ettus Research, a National Instruments Company
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-
-#include "mock_ctrl_iface_impl.hpp"
-static const uint64_t TEST_NOC_ID = 0xAAAABBBBCCCCDDDD;
-
-uint64_t mock_ctrl_iface_impl::send_cmd_pkt(const size_t addr,
- const size_t data,
- const bool readback,
- const uint64_t /* timestamp */
-)
-{
- if (not readback) {
- std::cout << str(boost::format("[MOCK] poke to addr: %016X, data == %016X") % addr
- % data)
- << std::endl;
- } else {
- std::cout << str(boost::format("[MOCK] peek64 to addr: %016X") % data)
- << std::endl;
- switch (data) {
- case uhd::rfnoc::SR_READBACK_REG_ID:
- return TEST_NOC_ID;
- case uhd::rfnoc::SR_READBACK_REG_FIFOSIZE:
- return 0x0000000000010000;
- case uhd::rfnoc::SR_READBACK_REG_USER:
- return 0x0123456789ABCDEF;
- case uhd::rfnoc::SR_READBACK_COMPAT:
- return uint64_t(uhd::rfnoc::NOC_SHELL_COMPAT_MAJOR) << 32
- | uint64_t(uhd::rfnoc::NOC_SHELL_COMPAT_MINOR);
- default:
- return 0;
- }
- }
- return 0;
-}
diff --git a/host/tests/common/mock_ctrl_iface_impl.hpp b/host/tests/common/mock_ctrl_iface_impl.hpp
deleted file mode 100644
index f20858b63..000000000
--- a/host/tests/common/mock_ctrl_iface_impl.hpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-// Copyright 2018 Ettus Research, a National Instruments Company
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-
-
-#ifndef INCLUDED_MOCK_CTRL_IFACE_IMPL_HPP
-#define INCLUDED_MOCK_CTRL_IFACE_IMPL_HPP
-
-#include <uhd/rfnoc/constants.hpp>
-#include <uhdlib/rfnoc/ctrl_iface.hpp>
-#include <boost/bind.hpp>
-#include <boost/format.hpp>
-#include <boost/make_shared.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/thread.hpp>
-#include <queue>
-
-class mock_ctrl_iface_impl : public uhd::rfnoc::ctrl_iface
-{
- uint64_t send_cmd_pkt(const size_t addr,
- const size_t data,
- const bool readback = false,
- const uint64_t timestamp = 0);
-
- void set_cmd_fifo_size(const size_t) {}
-};
-#endif /* INCLUDED_MOCK_CTRL_IFACE_IMPL_HPP */
diff --git a/host/tests/common/mock_zero_copy.hpp b/host/tests/common/mock_zero_copy.hpp
index 60e5f4659..515fde498 100644
--- a/host/tests/common/mock_zero_copy.hpp
+++ b/host/tests/common/mock_zero_copy.hpp
@@ -12,9 +12,7 @@
#include <uhd/transport/vrt_if_packet.hpp>
#include <uhd/transport/zero_copy.hpp>
#include <uhd/types/endianness.hpp>
-#include <uhd/types/sid.hpp>
#include <uhd/utils/byteswap.hpp>
-#include <uhdlib/rfnoc/xports.hpp>
#include <boost/make_shared.hpp>
#include <boost/shared_array.hpp>
#include <boost/shared_ptr.hpp>
diff --git a/host/tests/device3_test.cpp b/host/tests/device3_test.cpp
deleted file mode 100644
index b737e7012..000000000
--- a/host/tests/device3_test.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-//
-// Copyright 2014 Ettus Research LLC
-// Copyright 2018 Ettus Research, a National Instruments Company
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-
-
-#include "mock_ctrl_iface_impl.hpp"
-#include "mock_zero_copy.hpp"
-#include <uhd/device3.hpp>
-#include <uhd/property_tree.hpp>
-#include <uhd/rfnoc/block_ctrl.hpp>
-#include <uhd/rfnoc/graph.hpp>
-#include <uhdlib/rfnoc/graph_impl.hpp>
-#include <boost/enable_shared_from_this.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/test/unit_test.hpp>
-#include <exception>
-#include <iostream>
-
-
-using namespace uhd;
-using namespace uhd::rfnoc;
-using namespace uhd::transport::vrt;
-using uhd::transport::managed_recv_buffer;
-using uhd::transport::managed_send_buffer;
-
-static const sid_t TEST_SID0 = 0x00000200; // 0.0.2.0
-static const sid_t TEST_SID1 = 0x00000210; // 0.0.2.F
-
-uhd::both_xports_t make_mock_transport(const uhd::sid_t& tx_sid)
-{
- uhd::both_xports_t xports;
- xports.send_sid = tx_sid;
- xports.recv_sid = tx_sid.reversed();
- xports.send = boost::make_shared<mock_zero_copy>(if_packet_info_t::LINK_TYPE_CHDR);
- xports.recv = xports.send;
- xports.send_buff_size = xports.send->get_send_frame_size();
- xports.recv_buff_size = xports.recv->get_recv_frame_size();
- return xports;
-}
-
-// Mock-device
-class mock_device3_impl : public uhd::device3,
- public boost::enable_shared_from_this<mock_device3_impl>
-{
-public:
- mock_device3_impl()
- {
- _tree = uhd::property_tree::make();
- _tree->create<std::string>("/name").set("Test Mock-Device3");
- // We can re-use this:
- std::map<size_t, ctrl_iface::sptr> ctrl_ifaces{
- {0, ctrl_iface::sptr(new mock_ctrl_iface_impl())}};
-
- // Add two block controls:
- uhd::rfnoc::make_args_t make_args;
- make_args.ctrl_ifaces = ctrl_ifaces;
- make_args.base_address = TEST_SID0.get_dst();
- make_args.device_index = 0;
- make_args.tree = _tree;
- std::cout << "[MOCK] Generating block controls 1/2:" << std::endl;
- _rfnoc_block_ctrl.push_back(block_ctrl_base::make(make_args));
- std::cout << "[MOCK] Generating block controls 2/2:" << std::endl;
- make_args.base_address = TEST_SID1.get_dst();
- _rfnoc_block_ctrl.push_back(block_ctrl::make(make_args));
- }
-
- rx_streamer::sptr get_rx_stream(const stream_args_t& args)
- {
- throw uhd::not_implemented_error(args.args.to_string());
- }
-
- tx_streamer::sptr get_tx_stream(const stream_args_t& args)
- {
- throw uhd::not_implemented_error(args.args.to_string());
- }
-
- bool recv_async_msg(async_metadata_t& async_metadata, double timeout)
- {
- throw uhd::not_implemented_error(
- str(boost::format("%d %f") % async_metadata.channel % timeout));
- }
-
- rfnoc::graph::sptr create_graph(const std::string& name)
- {
- sid_t async_sid(0);
- async_sid.set_dst_addr(2);
- auto async_xports = make_mock_transport(async_sid);
-
- auto async_msg_handler = uhd::rfnoc::async_msg_handler::make(async_xports.recv,
- async_xports.send,
- async_xports.send_sid,
- async_xports.endianness);
- auto graph = boost::make_shared<uhd::rfnoc::graph_impl>(
- name, shared_from_this(), async_msg_handler);
- return graph;
- }
-};
-
-device3::sptr make_mock_device()
-{
- return device3::sptr(new mock_device3_impl());
-}
-
-class mock_block_ctrl : public block_ctrl
-{
- int foo;
-};
-
-BOOST_AUTO_TEST_CASE(test_device3)
-{
- device3::sptr my_device = make_mock_device();
-
- std::cout << "Checking block 0..." << std::endl;
- BOOST_REQUIRE(my_device->find_blocks("Block").size());
-
- std::cout << "Getting block 0..." << std::endl;
- block_ctrl_base::sptr block0 =
- my_device->get_block_ctrl(my_device->find_blocks("Block")[0]);
- BOOST_REQUIRE(block0);
- BOOST_CHECK_EQUAL(block0->get_block_id(), "0/Block#0");
-
- std::cout << "Checking block 1..." << std::endl;
- BOOST_REQUIRE(my_device->has_block(block_id_t("0/Block#1")));
-
- std::cout << "Getting block 1..." << std::endl;
- block_ctrl_base::sptr block1 = my_device->get_block_ctrl(block_id_t("0/Block#1"));
- BOOST_REQUIRE(block1);
- BOOST_CHECK_EQUAL(block1->get_block_id(), "0/Block#1");
-}
-
-
-BOOST_AUTO_TEST_CASE(test_device3_graph)
-{
- auto my_device = make_mock_device();
- std::cout << "Start device3 test graph.." << std::endl;
- std::cout << "Checking block 0..." << std::endl;
- BOOST_REQUIRE(my_device->find_blocks("Block").size());
- std::cout << "Getting block 0..." << std::endl;
- auto block0 = my_device->get_block_ctrl(my_device->find_blocks("Block")[0]);
- BOOST_REQUIRE(block0);
- BOOST_CHECK_EQUAL(block0->get_block_id(), "0/Block#0");
-
- std::cout << "Checking block 1..." << std::endl;
- BOOST_REQUIRE(my_device->has_block(block_id_t("0/Block#1")));
-
- std::cout << "Getting block 1..." << std::endl;
- auto block1 = my_device->get_block_ctrl(block_id_t("0/Block#1"));
- BOOST_REQUIRE(block1);
- BOOST_CHECK_EQUAL(block1->get_block_id(), "0/Block#1");
- std::cout << "Creating graph..." << std::endl;
- auto graph = my_device->create_graph("test_graph");
- BOOST_CHECK(graph);
- std::cout << "Connecting block_0 to block_1 ..." << std::endl;
- graph->connect(block_id_t("0/Block#0"), 0, block_id_t("0/Block#1"), 0);
-
- BOOST_CHECK_EQUAL(block0->list_upstream_nodes().size(), 0);
- BOOST_CHECK_EQUAL(block0->list_downstream_nodes().size(), 1);
- BOOST_CHECK_EQUAL(
- block0->list_downstream_nodes()[0].lock()->unique_id(), "0/Block#1");
- BOOST_CHECK_EQUAL(block1->list_upstream_nodes().size(), 1);
- BOOST_CHECK_EQUAL(block1->list_downstream_nodes().size(), 0);
- BOOST_CHECK_EQUAL(block1->list_upstream_nodes()[0].lock()->unique_id(), "0/Block#0");
-}
-
-BOOST_AUTO_TEST_CASE(test_device3_cast)
-{
- device3::sptr my_device = make_mock_device();
-
- std::cout << "Getting block 0..." << std::endl;
- block_ctrl::sptr block0 =
- my_device->get_block_ctrl<block_ctrl>(block_id_t("0/Block#0"));
- BOOST_REQUIRE(block0);
- BOOST_CHECK_EQUAL(block0->get_block_id(), "0/Block#0");
-
- std::cout << "Getting block 1..." << std::endl;
- block_ctrl_base::sptr block1 =
- my_device->get_block_ctrl<block_ctrl>(block_id_t("0/Block#1"));
- BOOST_CHECK_EQUAL(block1->get_block_id(), "0/Block#1");
-}
-
-BOOST_AUTO_TEST_CASE(test_device3_fail)
-{
- device3::sptr my_device = make_mock_device();
-
- BOOST_CHECK(not my_device->has_block(block_id_t("0/FooBarBlock#0")));
- BOOST_CHECK(not my_device->has_block<mock_block_ctrl>(block_id_t("0/Block#1")));
-
- BOOST_CHECK(my_device->find_blocks("FooBarBlock").size() == 0);
- BOOST_CHECK(my_device->find_blocks<block_ctrl>("FooBarBlock").size() == 0);
-
- BOOST_REQUIRE_THROW(
- my_device->get_block_ctrl(block_id_t("0/FooBarBlock#17")), uhd::lookup_error);
- BOOST_REQUIRE_THROW(
- my_device->get_block_ctrl<mock_block_ctrl>(block_id_t("0/Block#1")),
- uhd::lookup_error);
-}
-
-// vim: sw=4 et:
diff --git a/host/tests/graph.hpp b/host/tests/graph.hpp
deleted file mode 100644
index fb36ae510..000000000
--- a/host/tests/graph.hpp
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// Copyright 2014 Ettus Research LLC
-// Copyright 2018 Ettus Research, a National Instruments Company
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-
-#ifndef INCLUDED_TEST_GRAPH_HPP
-#define INCLUDED_TEST_GRAPH_HPP
-
-#include <uhd/rfnoc/node_ctrl_base.hpp>
-#include <uhd/rfnoc/sink_node_ctrl.hpp>
-#include <uhd/rfnoc/source_node_ctrl.hpp>
-
-#define MAKE_NODE(name) test_node::sptr name(new test_node(#name));
-
-// Smallest possible test class
-class test_node : virtual public uhd::rfnoc::sink_node_ctrl,
- virtual public uhd::rfnoc::source_node_ctrl
-{
-public:
- typedef boost::shared_ptr<test_node> sptr;
-
- test_node(const std::string& test_id) : _test_id(test_id){};
-
- void issue_stream_cmd(const uhd::stream_cmd_t&, const size_t){/* nop */};
-
- std::string get_test_id() const
- {
- return _test_id;
- };
-
-private:
- const std::string _test_id;
-
-}; /* class test_node */
-
-void connect_nodes(
- uhd::rfnoc::source_node_ctrl::sptr A, uhd::rfnoc::sink_node_ctrl::sptr B)
-{
- const size_t actual_src_port = A->connect_downstream(B);
- const size_t actual_dst_port = B->connect_upstream(A);
- A->set_downstream_port(actual_src_port, actual_dst_port);
- B->set_upstream_port(actual_dst_port, actual_src_port);
-}
-
-#endif /* INCLUDED_TEST_GRAPH_HPP */
diff --git a/host/tests/graph_search_test.cpp b/host/tests/graph_search_test.cpp
deleted file mode 100644
index 932647d98..000000000
--- a/host/tests/graph_search_test.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-//
-// Copyright 2014-2016 Ettus Research LLC
-// Copyright 2018 Ettus Research, a National Instruments Company
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-
-#include "graph.hpp"
-#include <boost/test/unit_test.hpp>
-#include <iostream>
-
-using namespace uhd::rfnoc;
-
-// test class derived, this is what we search for
-class result_node : public test_node
-{
-public:
- typedef boost::shared_ptr<result_node> sptr;
-
- result_node(const std::string& test_id) : test_node(test_id){};
-
-}; /* class result_node */
-
-#define MAKE_RESULT_NODE(name) result_node::sptr name(new result_node(#name));
-
-BOOST_AUTO_TEST_CASE(test_simplest_downstream_search)
-{
- MAKE_NODE(node_A);
- MAKE_NODE(node_B);
-
- // Simplest possible scenario: Connect B downstream of A and let
- // A find B
- connect_nodes(node_A, node_B);
-
- test_node::sptr result = node_A->find_downstream_node<test_node>()[0];
- BOOST_REQUIRE(result);
- BOOST_CHECK_EQUAL(result->get_test_id(), "node_B");
-}
-
-BOOST_AUTO_TEST_CASE(test_simple_downstream_search)
-{
- MAKE_NODE(node_A);
- MAKE_NODE(node_B0);
- MAKE_NODE(node_B1);
-
- // Simple scenario: Connect both B{1,2} downstream of A and let
- // it find them
- connect_nodes(node_A, node_B0);
- connect_nodes(node_A, node_B1);
-
- // We're still searching for test_node, so any downstream block will match
- std::vector<test_node::sptr> result = node_A->find_downstream_node<test_node>();
- BOOST_REQUIRE(result.size() == 2);
- BOOST_CHECK(
- (result[0]->get_test_id() == "node_B0" and result[1]->get_test_id() == "node_B1")
- or (result[1]->get_test_id() == "node_B0"
- and result[0]->get_test_id() == "node_B1"));
- BOOST_CHECK(result[0] == node_B0 or result[0] == node_B1);
-}
-
-BOOST_AUTO_TEST_CASE(test_linear_downstream_search)
-{
- MAKE_NODE(node_A);
- MAKE_RESULT_NODE(node_B);
- MAKE_RESULT_NODE(node_C);
-
- // Slightly more complex graph:
- connect_nodes(node_A, node_B);
- connect_nodes(node_B, node_C);
-
- // This time, we search for result_node
- std::vector<result_node::sptr> result = node_A->find_downstream_node<result_node>();
- std::cout << "size: " << result.size() << std::endl;
- BOOST_CHECK_EQUAL(result.size(), 1);
- BOOST_CHECK_EQUAL(result[0]->get_test_id(), "node_B");
- for (const result_node::sptr& node : result) {
- std::cout << node->get_test_id() << std::endl;
- }
-}
-
-BOOST_AUTO_TEST_CASE(test_multi_iter_downstream_search)
-{
- MAKE_NODE(node_A);
- MAKE_NODE(node_B0);
- MAKE_NODE(node_B1);
- MAKE_NODE(node_C0);
- MAKE_RESULT_NODE(node_C1);
- MAKE_RESULT_NODE(node_C2);
- MAKE_RESULT_NODE(node_C3);
- MAKE_RESULT_NODE(node_D0);
-
- // Slightly more complex graph:
- connect_nodes(node_A, node_B0);
- connect_nodes(node_A, node_B1);
- connect_nodes(node_B0, node_C0);
- connect_nodes(node_B0, node_C1);
- connect_nodes(node_B1, node_C2);
- connect_nodes(node_B1, node_C3);
- connect_nodes(node_C0, node_D0);
-
- // This time, we search for result_node
- std::vector<result_node::sptr> result = node_A->find_downstream_node<result_node>();
- BOOST_REQUIRE(result.size() == 4);
- for (const result_node::sptr& node : result) {
- std::cout << node->get_test_id() << std::endl;
- }
-}
-
-BOOST_AUTO_TEST_CASE(test_multi_iter_cycle_downstream_search)
-{
- MAKE_NODE(node_A);
- MAKE_NODE(node_B0);
- MAKE_NODE(node_B1);
- MAKE_NODE(node_C0);
- MAKE_RESULT_NODE(node_C1);
- MAKE_RESULT_NODE(node_C2);
- MAKE_RESULT_NODE(node_C3);
- MAKE_RESULT_NODE(node_D0);
-
- // Slightly more complex graph:
- connect_nodes(node_A, node_B0);
- // This connection goes both ways, causing a cycle
- connect_nodes(node_A, node_B1);
- connect_nodes(node_B1, node_A);
- connect_nodes(node_B0, node_C0);
- connect_nodes(node_B0, node_C1);
- connect_nodes(node_B1, node_C2);
- connect_nodes(node_B1, node_C3);
- connect_nodes(node_C0, node_D0);
-
- // This time, we search for result_node
- std::vector<result_node::sptr> result = node_A->find_downstream_node<result_node>();
- BOOST_REQUIRE(result.size() == 4);
- for (const result_node::sptr& node : result) {
- std::cout << node->get_test_id() << std::endl;
- }
-}
-
-BOOST_AUTO_TEST_CASE(test_mini_cycle_downstream_and_upstream)
-{
- MAKE_NODE(node_A);
- MAKE_NODE(node_B);
-
- // Connect them in a loop
- connect_nodes(node_A, node_B);
- connect_nodes(node_B, node_A);
-
- std::vector<test_node::sptr> result;
- result = node_A->find_downstream_node<test_node>();
- BOOST_REQUIRE_EQUAL(result.size(), 1);
- BOOST_REQUIRE(result[0] == node_B);
- result = node_B->find_downstream_node<test_node>();
- BOOST_REQUIRE_EQUAL(result.size(), 1);
- BOOST_REQUIRE(result[0] == node_A);
- result = node_A->find_upstream_node<test_node>();
- BOOST_REQUIRE_EQUAL(result.size(), 1);
- BOOST_REQUIRE(result[0] == node_B);
- result = node_B->find_upstream_node<test_node>();
- BOOST_REQUIRE_EQUAL(result.size(), 1);
- BOOST_REQUIRE(result[0] == node_A);
-}
diff --git a/host/tests/nocscript_common.hpp b/host/tests/nocscript_common.hpp
deleted file mode 100644
index ad254fa0e..000000000
--- a/host/tests/nocscript_common.hpp
+++ /dev/null
@@ -1,30 +0,0 @@
-//
-// Copyright 2015 Ettus Research LLC
-// Copyright 2018 Ettus Research, a National Instruments Company
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-
-#include "../lib/rfnoc/nocscript/expression.hpp"
-#include <boost/assign/list_of.hpp>
-
-using namespace uhd::rfnoc::nocscript;
-
-// Some global defs to make tests easier to write
-expression_function::argtype_list_type one_int_arg =
- boost::assign::list_of(expression::TYPE_INT);
-expression_function::argtype_list_type two_int_args =
- boost::assign::list_of(expression::TYPE_INT)(expression::TYPE_INT);
-expression_function::argtype_list_type one_double_arg =
- boost::assign::list_of(expression::TYPE_DOUBLE);
-expression_function::argtype_list_type two_double_args =
- boost::assign::list_of(expression::TYPE_DOUBLE)(expression::TYPE_DOUBLE);
-expression_function::argtype_list_type one_bool_arg =
- boost::assign::list_of(expression::TYPE_BOOL);
-expression_function::argtype_list_type two_bool_args =
- boost::assign::list_of(expression::TYPE_BOOL)(expression::TYPE_BOOL);
-expression_function::argtype_list_type no_args;
-
-expression_container::expr_list_type empty_arg_list;
-
-#define E(x) expression_literal::make(x)
diff --git a/host/tests/nocscript_expr_test.cpp b/host/tests/nocscript_expr_test.cpp
deleted file mode 100644
index ed5f6598d..000000000
--- a/host/tests/nocscript_expr_test.cpp
+++ /dev/null
@@ -1,405 +0,0 @@
-//
-// Copyright 2015 Ettus Research LLC
-// Copyright 2018 Ettus Research, a National Instruments Company
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-
-#include "../lib/rfnoc/nocscript/function_table.hpp"
-#include "nocscript_common.hpp"
-#include <boost/bind.hpp>
-#include <boost/format.hpp>
-#include <boost/make_shared.hpp>
-#include <boost/test/floating_point_comparison.hpp>
-#include <boost/test/unit_test.hpp>
-#include <algorithm>
-#include <iostream>
-
-// We need this global variable for one of the later tests
-int and_counter = 0;
-
-BOOST_AUTO_TEST_CASE(test_literals)
-{
- expression_literal literal_int("5", expression::TYPE_INT);
- BOOST_CHECK_EQUAL(literal_int.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(literal_int.get_int(), 5);
- BOOST_CHECK_EQUAL(literal_int.to_bool(), true);
- BOOST_REQUIRE_THROW(literal_int.get_string(), uhd::type_error);
- BOOST_REQUIRE_THROW(literal_int.get_bool(), uhd::type_error);
-
- expression_literal literal_int0("0", expression::TYPE_INT);
- BOOST_CHECK_EQUAL(literal_int0.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(literal_int0.to_bool(), false);
-
- expression_literal literal_double("2.3", expression::TYPE_DOUBLE);
- BOOST_CHECK_EQUAL(literal_double.infer_type(), expression::TYPE_DOUBLE);
- BOOST_CHECK_CLOSE(literal_double.get_double(), 2.3, 0.01);
- BOOST_CHECK_EQUAL(literal_double.to_bool(), true);
- BOOST_REQUIRE_THROW(literal_double.get_string(), uhd::type_error);
- BOOST_REQUIRE_THROW(literal_double.get_bool(), uhd::type_error);
-
- expression_literal literal_bool(true);
- BOOST_CHECK_EQUAL(literal_bool.infer_type(), expression::TYPE_BOOL);
- BOOST_CHECK_EQUAL(literal_bool.get_bool(), true);
- BOOST_CHECK_EQUAL(literal_bool.to_bool(), true);
- BOOST_CHECK_EQUAL(literal_bool.eval().get_bool(), true);
- BOOST_REQUIRE_THROW(literal_bool.get_string(), uhd::type_error);
- BOOST_REQUIRE_THROW(literal_bool.get_int(), uhd::type_error);
-
- expression_literal literal_bool_false(false);
- BOOST_CHECK_EQUAL(literal_bool_false.infer_type(), expression::TYPE_BOOL);
- BOOST_CHECK_EQUAL(literal_bool_false.get_bool(), false);
- BOOST_CHECK_EQUAL(literal_bool_false.to_bool(), false);
- BOOST_REQUIRE_EQUAL(literal_bool_false.eval().get_bool(), false);
- BOOST_REQUIRE_THROW(literal_bool_false.get_string(), uhd::type_error);
- BOOST_REQUIRE_THROW(literal_bool_false.get_int(), uhd::type_error);
-
- expression_literal literal_string("'foo bar'", expression::TYPE_STRING);
- BOOST_CHECK_EQUAL(literal_string.infer_type(), expression::TYPE_STRING);
- BOOST_CHECK_EQUAL(literal_string.get_string(), "foo bar");
- BOOST_REQUIRE_THROW(literal_string.get_bool(), uhd::type_error);
- BOOST_REQUIRE_THROW(literal_string.get_int(), uhd::type_error);
-
- expression_literal literal_int_vec("[1, 2, 3]", expression::TYPE_INT_VECTOR);
- BOOST_CHECK_EQUAL(literal_int_vec.infer_type(), expression::TYPE_INT_VECTOR);
- std::vector<int> test_data{1, 2, 3};
- std::vector<int> result = literal_int_vec.get_int_vector();
- BOOST_CHECK_EQUAL_COLLECTIONS(
- test_data.begin(), test_data.end(), result.begin(), result.end());
- BOOST_REQUIRE_THROW(literal_int_vec.get_bool(), uhd::type_error);
- BOOST_REQUIRE_THROW(literal_int_vec.get_int(), uhd::type_error);
-}
-
-
-// Need those for the variable testing:
-expression::type_t variable_get_type(const std::string& var_name)
-{
- if (var_name == "spp") {
- std::cout << "Returning type for $spp..." << std::endl;
- return expression::TYPE_INT;
- }
- if (var_name == "is_true") {
- std::cout << "Returning type for $is_true..." << std::endl;
- return expression::TYPE_BOOL;
- }
-
- throw uhd::syntax_error("Cannot infer type (unknown variable)");
-}
-
-expression_literal variable_get_value(const std::string& var_name)
-{
- if (var_name == "spp") {
- std::cout << "Returning value for $spp..." << std::endl;
- return expression_literal(5);
- }
- if (var_name == "is_true") {
- std::cout << "Returning value for $is_true..." << std::endl;
- return expression_literal(true);
- }
-
- throw uhd::syntax_error("Cannot read value (unknown variable)");
-}
-
-BOOST_AUTO_TEST_CASE(test_variables)
-{
- BOOST_REQUIRE_THROW(expression_variable v_fail("foo", // Invalid token
- boost::bind(&variable_get_type, _1),
- boost::bind(&variable_get_value, _1)),
- uhd::assertion_error);
-
- expression_variable v("$spp", // The token
- boost::bind(&variable_get_type, _1), // type-getter
- boost::bind(&variable_get_value, _1) // value-getter
- );
- BOOST_CHECK_EQUAL(v.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(v.eval().get_int(), 5);
-}
-
-BOOST_AUTO_TEST_CASE(test_container)
-{
- // Create some sub-expressions:
- expression_literal::sptr l_true = E(true);
- expression_literal::sptr l_false = E(false);
- expression_literal::sptr l_int = E(5);
- BOOST_REQUIRE_EQUAL(l_false->get_bool(), false);
- BOOST_REQUIRE_EQUAL(l_false->to_bool(), false);
- expression_variable::sptr l_boolvar =
- boost::make_shared<expression_variable>("$is_true",
- boost::bind(&variable_get_type, _1),
- boost::bind(&variable_get_value, _1));
-
- // This will throw anytime it's evaluated:
- expression_variable::sptr l_failvar =
- boost::make_shared<expression_variable>("$does_not_exist",
- boost::bind(&variable_get_type, _1),
- boost::bind(&variable_get_value, _1));
-
- expression_container c;
- std::cout << "One true, OR: " << std::endl;
- c.add(l_true);
- c.set_combiner_safe(expression_container::COMBINE_OR);
- expression_literal ret_val_1 = c.eval();
- BOOST_CHECK_EQUAL(ret_val_1.infer_type(), expression::TYPE_BOOL);
- BOOST_CHECK_EQUAL(ret_val_1.eval().get_bool(), true);
-
- std::cout << std::endl << std::endl << "Two true, one false, OR: " << std::endl;
- c.add(l_true);
- c.add(l_false);
- expression_literal ret_val_2 = c.eval();
- BOOST_CHECK_EQUAL(ret_val_2.infer_type(), expression::TYPE_BOOL);
- BOOST_CHECK_EQUAL(ret_val_2.eval().get_bool(), true);
-
- expression_container c2;
- c2.add(l_false);
- c2.add(l_false);
- c2.set_combiner(expression_container::COMBINE_AND);
- std::cout << std::endl << std::endl << "Two false, AND: " << std::endl;
- expression_literal ret_val_3 = c2.eval();
- BOOST_CHECK_EQUAL(ret_val_3.infer_type(), expression::TYPE_BOOL);
- BOOST_REQUIRE_EQUAL(ret_val_3.eval().get_bool(), false);
-
- c2.add(l_failvar);
- // Will not fail, because l_failvar never gets eval'd:
- expression_literal ret_val_4 = c2.eval();
- BOOST_CHECK_EQUAL(ret_val_4.infer_type(), expression::TYPE_BOOL);
- BOOST_CHECK_EQUAL(ret_val_4.eval().get_bool(), false);
-
- // Same here:
- c.add(l_failvar);
- expression_literal ret_val_5 = c.eval();
- BOOST_CHECK_EQUAL(ret_val_5.infer_type(), expression::TYPE_BOOL);
- BOOST_CHECK_EQUAL(ret_val_5.eval().get_bool(), true);
-
- // Now it'll throw:
- c.set_combiner(expression_container::COMBINE_ALL);
- BOOST_REQUIRE_THROW(c.eval(), uhd::syntax_error);
-
- std::cout << "Checking type inference on ',' sequences: " << std::endl;
- // Check types match
- BOOST_CHECK_EQUAL(c2.infer_type(), expression::TYPE_BOOL);
- expression_container c3;
- c3.set_combiner(expression_container::COMBINE_ALL);
- c3.add(l_false);
- c3.add(l_int);
- BOOST_CHECK_EQUAL(c3.infer_type(), expression::TYPE_INT);
-}
-
-
-// We'll define two functions here: ADD and XOR. The former shall
-// be defined for INT and DOUBLE
-class functable_mockup_impl : public function_table
-{
-public:
- functable_mockup_impl(void){};
-
- bool function_exists(const std::string& name) const
- {
- return name == "ADD" or name == "XOR" or name == "AND";
- }
-
- bool function_exists(const std::string& name,
- const expression_function::argtype_list_type& arg_types) const
- {
- if (name == "ADD") {
- if (arg_types.size() == 2 and arg_types[0] == expression::TYPE_DOUBLE
- and arg_types[1] == expression::TYPE_DOUBLE) {
- return true;
- }
- if (arg_types.size() == 2 and arg_types[0] == expression::TYPE_INT
- and arg_types[1] == expression::TYPE_INT) {
- return true;
- }
- return false;
- }
-
- if (name == "XOR" or name == "AND") {
- if (arg_types.size() == 2 and arg_types[0] == expression::TYPE_BOOL
- and arg_types[1] == expression::TYPE_BOOL) {
- return true;
- }
- return false;
- }
-
- return false;
- }
-
- expression::type_t get_type(const std::string& name,
- const expression_function::argtype_list_type& arg_types) const
- {
- if (not function_exists(name, arg_types)) {
- throw uhd::syntax_error(
- str(boost::format(
- "[EXPR_TEXT] get_type(): Unknown function: %s, %d arguments")
- % name % arg_types.size()));
- }
-
- if (name == "XOR" or name == "AND") {
- return expression::TYPE_BOOL;
- }
- if (name == "ADD") {
- return arg_types[0];
- }
- UHD_THROW_INVALID_CODE_PATH();
- }
-
- expression_literal eval(const std::string& name,
- const expression_function::argtype_list_type& arg_types,
- expression_container::expr_list_type& args)
- {
- if (name == "XOR") {
- if (arg_types.size() != 2 or args.size() != 2
- or arg_types[0] != expression::TYPE_BOOL
- or arg_types[1] != expression::TYPE_BOOL
- or args[0]->infer_type() != expression::TYPE_BOOL
- or args[1]->infer_type() != expression::TYPE_BOOL) {
- throw uhd::syntax_error("eval(): XOR type mismatch");
- }
- return expression_literal(
- bool(args[0]->eval().get_bool() xor args[1]->eval().get_bool()));
- }
-
- if (name == "AND") {
- if (arg_types.size() != 2 or args.size() != 2
- or arg_types[0] != expression::TYPE_BOOL
- or arg_types[1] != expression::TYPE_BOOL
- or args[0]->infer_type() != expression::TYPE_BOOL
- or args[1]->infer_type() != expression::TYPE_BOOL) {
- throw uhd::syntax_error("eval(): AND type mismatch");
- }
- std::cout << "Calling AND" << std::endl;
- and_counter++;
- return expression_literal(
- bool(args[0]->eval().get_bool() and args[1]->eval().get_bool()));
- }
-
- if (name == "ADD") {
- if (args.size() != 2) {
- throw uhd::syntax_error("eval(): ADD type mismatch");
- }
- if ((args[0]->infer_type() == expression::TYPE_INT)
- and (args[1]->infer_type() == expression::TYPE_INT)) {
- return expression_literal(
- int(args[0]->eval().get_int() + args[1]->eval().get_int()));
- } else if ((args[0]->infer_type() == expression::TYPE_DOUBLE)
- and (args[1]->infer_type() == expression::TYPE_DOUBLE)) {
- return expression_literal(
- double(args[0]->eval().get_double() + args[1]->eval().get_double()));
- }
- throw uhd::syntax_error("eval(): ADD type mismatch");
- }
- throw uhd::syntax_error("eval(): unknown function");
- }
-
- // We don't actually need this
- void register_function(const std::string&,
- const function_table::function_ptr&,
- const expression::type_t,
- const expression_function::argtype_list_type&){};
-};
-
-
-// The annoying part: Testing the test fixtures
-BOOST_AUTO_TEST_CASE(test_functable_mockup)
-{
- functable_mockup_impl functable;
-
- BOOST_CHECK(functable.function_exists("ADD"));
- BOOST_CHECK(functable.function_exists("XOR"));
- BOOST_CHECK(not functable.function_exists("FOOBAR"));
-
- BOOST_CHECK(functable.function_exists("ADD", two_int_args));
- BOOST_CHECK(functable.function_exists("ADD", two_double_args));
- BOOST_CHECK(functable.function_exists("XOR", two_bool_args));
- BOOST_CHECK(not functable.function_exists("ADD", two_bool_args));
- BOOST_CHECK(not functable.function_exists("ADD", no_args));
- BOOST_CHECK(not functable.function_exists("XOR", no_args));
-
- BOOST_CHECK_EQUAL(functable.get_type("ADD", two_int_args), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(
- functable.get_type("ADD", two_double_args), expression::TYPE_DOUBLE);
- BOOST_CHECK_EQUAL(functable.get_type("XOR", two_bool_args), expression::TYPE_BOOL);
-
- expression_container::expr_list_type add_args_int{E(2), E(3)};
- expression_container::expr_list_type add_args_dbl{E(2.25), E(5.0)};
- expression_container::expr_list_type xor_args_bool{E(true), E(false)};
-
- BOOST_CHECK_EQUAL(
- functable.eval("ADD", two_int_args, add_args_int), expression_literal(5));
- BOOST_CHECK_EQUAL(
- functable.eval("ADD", two_double_args, add_args_dbl), expression_literal(7.25));
- BOOST_CHECK_EQUAL(
- functable.eval("XOR", two_bool_args, xor_args_bool), expression_literal(true));
-}
-
-BOOST_AUTO_TEST_CASE(test_function_expression)
-{
- function_table::sptr ft = boost::make_shared<functable_mockup_impl>();
-
- // Very simple function: ADD(2, 3)
- expression_function func1("ADD", ft);
- func1.add(E(2));
- func1.add(E(3));
-
- BOOST_CHECK_EQUAL(func1.eval(), expression_literal(5));
-
- // More elaborate: ADD(ADD(2, 3), ADD(ADD(4, 5), 6)) ?= 20
- // f4 f1 f3 f2
- expression_function f1("ADD", ft);
- f1.add(E(2));
- f1.add(E(3));
- expression_function f2("ADD", ft);
- f2.add(E(4));
- f2.add(E(5));
- expression_function f3("ADD", ft);
- f3.add(boost::make_shared<expression_function>(f2));
- f3.add(E(6));
- expression_function f4("ADD", ft);
- f4.add(boost::make_shared<expression_function>(f1));
- f4.add(boost::make_shared<expression_function>(f3));
-
- BOOST_CHECK_EQUAL(f4.eval().get_int(), 20);
-}
-
-BOOST_AUTO_TEST_CASE(test_function_expression_laziness)
-{
- function_table::sptr ft = boost::make_shared<functable_mockup_impl>();
-
- // We run AND(AND(false, false), AND(false, false)).
- // f1 f2 f3
- // That makes three ANDs
- // in total. However, we will only see AND being evaluated twice, because
- // the outcome is clear after running the first AND in the argument list.
- expression_function::sptr f2 = boost::make_shared<expression_function>("AND", ft);
- f2->add(E(false));
- f2->add(E(false));
- BOOST_CHECK(not f2->eval().get_bool());
-
- expression_function::sptr f3 = boost::make_shared<expression_function>("AND", ft);
- f3->add(E(false));
- f3->add(E(false));
- BOOST_CHECK(not f3->eval().get_bool());
-
- and_counter = 0;
- expression_function::sptr f1 = boost::make_shared<expression_function>("AND", ft);
- f1->add(f2);
- f1->add(f3);
-
- BOOST_CHECK(not f1->eval().get_bool());
- BOOST_CHECK_EQUAL(and_counter, 2);
-}
-
-BOOST_AUTO_TEST_CASE(test_sptrs)
-{
- expression_container::sptr c = expression_container::make();
- BOOST_CHECK_EQUAL(c->infer_type(), expression::TYPE_BOOL);
- BOOST_CHECK(c->eval().get_bool());
-
- expression_variable::sptr v = expression_variable::make("$spp",
- boost::bind(&variable_get_type, _1), // type-getter
- boost::bind(&variable_get_value, _1) // value-getter
- );
-
- c->add(v);
- BOOST_REQUIRE_EQUAL(c->infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(c->eval().get_int(), 5);
-}
diff --git a/host/tests/nocscript_ftable_test.cpp b/host/tests/nocscript_ftable_test.cpp
deleted file mode 100644
index 36aa314f2..000000000
--- a/host/tests/nocscript_ftable_test.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-//
-// Copyright 2015 Ettus Research LLC
-// Copyright 2018 Ettus Research, a National Instruments Company
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-
-#include "../lib/rfnoc/nocscript/function_table.hpp"
-#include "nocscript_common.hpp"
-#include <boost/bind.hpp>
-#include <boost/make_shared.hpp>
-#include <boost/test/floating_point_comparison.hpp>
-#include <boost/test/unit_test.hpp>
-#include <algorithm>
-#include <iostream>
-
-BOOST_AUTO_TEST_CASE(test_basic_funcs)
-{
- function_table::sptr ft = function_table::make();
- BOOST_CHECK(ft->function_exists("ADD"));
- BOOST_CHECK(ft->function_exists("ADD", two_int_args));
- BOOST_CHECK(ft->function_exists("LE", two_int_args));
- BOOST_CHECK(ft->function_exists("GE"));
- BOOST_CHECK(ft->function_exists("GE", two_int_args));
- BOOST_CHECK(ft->function_exists("TRUE"));
- BOOST_CHECK(ft->function_exists("FALSE"));
-
- // Math
- expression_container::expr_list_type two_int_values{E(2), E(3)};
- expression_container::expr_list_type two_int_values2{E(3), E(2)};
- expression_container::expr_list_type two_double_values{E(2.0), E(3.0)};
-
- BOOST_REQUIRE_EQUAL(ft->get_type("ADD", two_int_args), expression::TYPE_INT);
- expression_literal e_add = ft->eval("ADD", two_int_args, two_int_values);
- BOOST_REQUIRE_EQUAL(e_add.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(e_add.get_int(), 5);
-
- BOOST_REQUIRE_EQUAL(ft->get_type("MULT", two_int_args), expression::TYPE_INT);
- expression_literal e_mult_i = ft->eval("MULT", two_int_args, two_int_values);
- BOOST_REQUIRE_EQUAL(e_mult_i.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(e_mult_i.get_int(), 6);
-
- BOOST_REQUIRE_EQUAL(ft->get_type("MULT", two_double_args), expression::TYPE_DOUBLE);
- expression_literal e_mult_d = ft->eval("MULT", two_double_args, two_double_values);
- BOOST_REQUIRE_EQUAL(e_mult_d.infer_type(), expression::TYPE_DOUBLE);
- BOOST_CHECK_CLOSE(e_mult_d.get_double(), 6.0, 0.01);
-
- BOOST_REQUIRE_EQUAL(ft->get_type("DIV", two_double_args), expression::TYPE_DOUBLE);
- expression_literal e_div_d = ft->eval("DIV", two_double_args, two_double_values);
- BOOST_REQUIRE_EQUAL(e_div_d.infer_type(), expression::TYPE_DOUBLE);
- BOOST_CHECK_CLOSE(e_div_d.get_double(), 2.0 / 3.0, 0.01);
-
- BOOST_REQUIRE_EQUAL(ft->get_type("MODULO", two_int_args), expression::TYPE_INT);
- expression_literal e_modulo_i = ft->eval("MODULO", two_int_args, two_int_values);
- BOOST_REQUIRE_EQUAL(e_modulo_i.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(e_modulo_i.get_int(), 2 % 3);
-
- BOOST_REQUIRE_EQUAL(ft->get_type("LE", two_int_args), expression::TYPE_BOOL);
- expression_literal e_le = ft->eval("LE", two_int_args, two_int_values);
- BOOST_REQUIRE_EQUAL(e_le.infer_type(), expression::TYPE_BOOL);
- BOOST_CHECK_EQUAL(e_le.get_bool(), true);
- BOOST_CHECK_EQUAL(ft->eval("LE", two_int_args, two_int_values2).get_bool(), false);
- expression_literal e_ge = ft->eval("GE", two_int_args, two_int_values);
- BOOST_REQUIRE_EQUAL(ft->get_type("GE", two_int_args), expression::TYPE_BOOL);
- BOOST_REQUIRE_EQUAL(e_ge.infer_type(), expression::TYPE_BOOL);
- BOOST_CHECK_EQUAL(e_ge.get_bool(), false);
-
- expression_container::expr_list_type sixty_four{E(64)};
- expression_literal e_pwr2 = ft->eval("IS_PWR_OF_2", one_int_arg, sixty_four);
- BOOST_REQUIRE_EQUAL(e_pwr2.infer_type(), expression::TYPE_BOOL);
- BOOST_CHECK_EQUAL(e_pwr2.get_bool(), true);
- expression_literal e_log2 = ft->eval("LOG2", one_int_arg, sixty_four);
- BOOST_REQUIRE_EQUAL(e_log2.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(e_log2.get_int(), 6);
-
- // Boolean Logic
- expression_container::expr_list_type e_true{E(true)};
- expression_container::expr_list_type e_false{E(false)};
- BOOST_CHECK(ft->eval("TRUE", no_args, empty_arg_list).to_bool());
- BOOST_CHECK(ft->eval("TRUE", no_args, empty_arg_list).get_bool());
- BOOST_CHECK_EQUAL(ft->eval("FALSE", no_args, empty_arg_list).to_bool(), false);
- BOOST_CHECK_EQUAL(ft->eval("FALSE", no_args, empty_arg_list).get_bool(), false);
- BOOST_CHECK(ft->eval("NOT", one_bool_arg, e_false).to_bool());
-
- // Control
- std::cout << "Checking ~1s sleep until... ";
- expression_container::expr_list_type e_sleeptime{E(.999)};
- BOOST_CHECK(ft->eval("SLEEP", one_double_arg, e_sleeptime).get_bool());
- std::cout << "Now." << std::endl;
-}
-
-// Some bogus function to test the registry
-expression_literal add_plus2_int(expression_container::expr_list_type args)
-{
- return expression_literal(args[0]->eval().get_int() + args[1]->eval().get_int() + 2);
-}
-
-BOOST_AUTO_TEST_CASE(test_add_funcs)
-{
- function_table::sptr ft = function_table::make();
-
- BOOST_CHECK(not ft->function_exists("ADD_PLUS_2"));
-
- expression_function::argtype_list_type add_int_args{
- expression::TYPE_INT, expression::TYPE_INT};
- ft->register_function("ADD_PLUS_2",
- boost::bind(&add_plus2_int, _1),
- expression::TYPE_INT,
- add_int_args);
-
- BOOST_CHECK(ft->function_exists("ADD_PLUS_2"));
- BOOST_CHECK(ft->function_exists("ADD_PLUS_2", add_int_args));
-
- expression_container::expr_list_type add_int_values{E(2), E(3)};
- expression_literal e = ft->eval("ADD_PLUS_2", two_int_args, add_int_values);
- BOOST_REQUIRE_EQUAL(e.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(e.get_int(), 7);
-}
-
-int dummy_true_counter = 0;
-// Some bogus function to test the registry
-expression_literal dummy_true(expression_container::expr_list_type)
-{
- dummy_true_counter++;
- std::cout << "Running dummy/true statement." << std::endl;
- return expression_literal(true);
-}
-
-int dummy_false_counter = 0;
-// Some bogus function to test the registry
-expression_literal dummy_false(expression_container::expr_list_type)
-{
- dummy_false_counter++;
- std::cout << "Running dummy/false statement." << std::endl;
- return expression_literal(false);
-}
-
-BOOST_AUTO_TEST_CASE(test_conditionals)
-{
- function_table::sptr ft = function_table::make();
- ft->register_function(
- "DUMMY", boost::bind(&dummy_true, _1), expression::TYPE_BOOL, no_args);
- ft->register_function(
- "DUMMY_F", boost::bind(&dummy_false, _1), expression::TYPE_BOOL, no_args);
- BOOST_REQUIRE(ft->function_exists("DUMMY", no_args));
- BOOST_REQUIRE(ft->function_exists("DUMMY_F", no_args));
-
- expression_function::sptr dummy_statement =
- boost::make_shared<expression_function>("DUMMY", ft);
- expression_function::sptr if_statement =
- boost::make_shared<expression_function>("IF", ft);
- if_statement->add(E(true));
- if_statement->add(dummy_statement);
-
- std::cout << "Dummy statement should run once until END:" << std::endl;
- dummy_true_counter = 0;
- BOOST_CHECK(if_statement->eval().get_bool());
- BOOST_CHECK_EQUAL(dummy_true_counter, 1);
- std::cout << "END." << std::endl;
-
- std::cout << "Dummy statement should not run until END:" << std::endl;
- expression_function::sptr if_statement2 =
- boost::make_shared<expression_function>("IF", ft);
- if_statement2->add(E(false));
- if_statement2->add(dummy_statement);
- dummy_true_counter = 0;
- BOOST_CHECK(not if_statement2->eval().get_bool());
- BOOST_CHECK_EQUAL(dummy_true_counter, 0);
- std::cout << "END." << std::endl;
-
- expression_function::sptr if_else_statement =
- boost::make_shared<expression_function>("IF_ELSE", ft);
- expression_function::sptr dummy_statement_f =
- boost::make_shared<expression_function>("DUMMY_F", ft);
- if_else_statement->add(E(true));
- if_else_statement->add(dummy_statement);
- if_else_statement->add(dummy_statement_f);
- dummy_true_counter = 0;
- dummy_false_counter = 0;
- std::cout << "Should execute dummy/true statement before END:" << std::endl;
- BOOST_CHECK(if_else_statement->eval().get_bool());
- BOOST_CHECK_EQUAL(dummy_true_counter, 1);
- BOOST_CHECK_EQUAL(dummy_false_counter, 0);
- std::cout << "END." << std::endl;
-
- expression_function::sptr if_else_statement2 =
- boost::make_shared<expression_function>("IF_ELSE", ft);
- if_else_statement2->add(E(false));
- if_else_statement2->add(dummy_statement);
- if_else_statement2->add(dummy_statement_f);
- dummy_true_counter = 0;
- dummy_false_counter = 0;
- std::cout << "Should execute dummy/false statement before END:" << std::endl;
- BOOST_CHECK(not if_else_statement2->eval().get_bool());
- BOOST_CHECK_EQUAL(dummy_true_counter, 0);
- BOOST_CHECK_EQUAL(dummy_false_counter, 1);
- std::cout << "END." << std::endl;
-}
-
-BOOST_AUTO_TEST_CASE(test_bitwise_funcs)
-{
- function_table::sptr ft = function_table::make();
- BOOST_CHECK(ft->function_exists("SHIFT_RIGHT"));
- BOOST_CHECK(ft->function_exists("SHIFT_RIGHT", two_int_args));
- BOOST_CHECK(ft->function_exists("SHIFT_LEFT"));
- BOOST_CHECK(ft->function_exists("SHIFT_LEFT", two_int_args));
- BOOST_CHECK(ft->function_exists("BITWISE_AND"));
- BOOST_CHECK(ft->function_exists("BITWISE_AND", two_int_args));
- BOOST_CHECK(ft->function_exists("BITWISE_OR"));
- BOOST_CHECK(ft->function_exists("BITWISE_OR", two_int_args));
- BOOST_CHECK(ft->function_exists("BITWISE_XOR"));
- BOOST_CHECK(ft->function_exists("BITWISE_XOR", two_int_args));
-
- // Bitwise Math
- int int_value1 = 0x2;
- int int_value2 = 0x3;
- expression_container::expr_list_type two_int_values{E(int_value1), E(int_value2)};
-
- BOOST_REQUIRE_EQUAL(ft->get_type("SHIFT_RIGHT", two_int_args), expression::TYPE_INT);
- expression_literal e_shift_right =
- ft->eval("SHIFT_RIGHT", two_int_args, two_int_values);
- BOOST_REQUIRE_EQUAL(e_shift_right.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(e_shift_right.get_int(), int_value1 >> int_value2);
-
- BOOST_REQUIRE_EQUAL(ft->get_type("SHIFT_LEFT", two_int_args), expression::TYPE_INT);
- expression_literal e_shift_left =
- ft->eval("SHIFT_LEFT", two_int_args, two_int_values);
- BOOST_REQUIRE_EQUAL(e_shift_left.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(e_shift_left.get_int(), int_value1 << int_value2);
-
- BOOST_REQUIRE_EQUAL(ft->get_type("BITWISE_AND", two_int_args), expression::TYPE_INT);
- expression_literal e_bitwise_and =
- ft->eval("BITWISE_AND", two_int_args, two_int_values);
- BOOST_REQUIRE_EQUAL(e_bitwise_and.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(e_bitwise_and.get_int(), int_value1 & int_value2);
-
- BOOST_REQUIRE_EQUAL(ft->get_type("BITWISE_OR", two_int_args), expression::TYPE_INT);
- expression_literal e_bitwise_or =
- ft->eval("BITWISE_OR", two_int_args, two_int_values);
- BOOST_REQUIRE_EQUAL(e_bitwise_or.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(e_bitwise_or.get_int(), int_value1 | int_value2);
-
- BOOST_REQUIRE_EQUAL(ft->get_type("BITWISE_XOR", two_int_args), expression::TYPE_INT);
- expression_literal e_bitwise_xor =
- ft->eval("BITWISE_XOR", two_int_args, two_int_values);
- BOOST_REQUIRE_EQUAL(e_bitwise_xor.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(e_bitwise_xor.get_int(), int_value1 ^ int_value2);
-}
diff --git a/host/tests/nocscript_parser_test.cpp b/host/tests/nocscript_parser_test.cpp
deleted file mode 100644
index eb9352995..000000000
--- a/host/tests/nocscript_parser_test.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-//
-// Copyright 2015 Ettus Research LLC
-// Copyright 2018 Ettus Research, a National Instruments Company
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-
-#include "../lib/rfnoc/nocscript/function_table.hpp"
-#include "../lib/rfnoc/nocscript/parser.hpp"
-#include "nocscript_common.hpp"
-#include <uhd/exception.hpp>
-#include <boost/assign/list_of.hpp>
-#include <boost/bind.hpp>
-#include <boost/make_shared.hpp>
-#include <boost/test/floating_point_comparison.hpp>
-#include <boost/test/unit_test.hpp>
-#include <algorithm>
-#include <iostream>
-
-const int SPP_VALUE = 64;
-
-// Need those for the variable testing:
-expression::type_t variable_get_type(const std::string& var_name)
-{
- if (var_name == "spp") {
- std::cout << "Returning type for $spp..." << std::endl;
- return expression::TYPE_INT;
- }
- if (var_name == "is_true") {
- std::cout << "Returning type for $is_true..." << std::endl;
- return expression::TYPE_BOOL;
- }
-
- throw uhd::syntax_error("Cannot infer type (unknown variable)");
-}
-
-expression_literal variable_get_value(const std::string& var_name)
-{
- if (var_name == "spp") {
- std::cout << "Returning value for $spp..." << std::endl;
- return expression_literal(SPP_VALUE);
- }
- if (var_name == "is_true") {
- std::cout << "Returning value for $is_true..." << std::endl;
- return expression_literal(true);
- }
-
- throw uhd::syntax_error("Cannot read value (unknown variable)");
-}
-
-#define SETUP_FT_AND_PARSER() \
- function_table::sptr ft = function_table::make(); \
- parser::sptr p = parser::make( \
- ft, boost::bind(&variable_get_type, _1), boost::bind(&variable_get_value, _1));
-
-BOOST_AUTO_TEST_CASE(test_fail)
-{
- SETUP_FT_AND_PARSER();
-
- // Missing closing parens:
- BOOST_REQUIRE_THROW(p->create_expr_tree("ADD1(1, "), uhd::syntax_error);
- // Double comma:
- BOOST_REQUIRE_THROW(p->create_expr_tree("ADD(1,, 2)"), uhd::syntax_error);
- // No comma:
- BOOST_REQUIRE_THROW(p->create_expr_tree("ADD(1 2)"), uhd::syntax_error);
- // Double closing parens:
- BOOST_REQUIRE_THROW(p->create_expr_tree("ADD(1, 2))"), uhd::syntax_error);
- // Unknown function:
- BOOST_REQUIRE_THROW(p->create_expr_tree("GLORPGORP(1, 2)"), uhd::syntax_error);
-}
-
-BOOST_AUTO_TEST_CASE(test_adds_no_vars)
-{
- SETUP_FT_AND_PARSER();
- BOOST_REQUIRE(ft->function_exists("ADD"));
-
- const std::string line("ADD(1, ADD(2, ADD(3, 4)))");
- expression::sptr e = p->create_expr_tree(line);
- expression_literal result = e->eval();
-
- BOOST_REQUIRE_EQUAL(result.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(result.get_int(), 1 + 2 + 3 + 4);
-}
-
-BOOST_AUTO_TEST_CASE(test_adds_with_vars)
-{
- SETUP_FT_AND_PARSER();
-
- const std::string line("ADD(1, ADD(2, $spp))");
- expression::sptr e = p->create_expr_tree(line);
- expression_literal result = e->eval();
-
- BOOST_REQUIRE_EQUAL(result.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(result.get_int(), 1 + 2 + SPP_VALUE);
-}
-
-BOOST_AUTO_TEST_CASE(test_fft_check)
-{
- SETUP_FT_AND_PARSER();
-
- const std::string line("GE($spp, 16) AND LE($spp, 4096) AND IS_PWR_OF_2($spp)");
- expression::sptr e = p->create_expr_tree(line);
- expression_literal result = e->eval();
-
- BOOST_REQUIRE_EQUAL(result.infer_type(), expression::TYPE_BOOL);
- BOOST_CHECK(result.get_bool());
-}
-
-BOOST_AUTO_TEST_CASE(test_pure_string)
-{
- SETUP_FT_AND_PARSER();
-
- // Eval all, return last expression
- const std::string line("'foo foo', \"bar\"");
- expression_literal result = p->create_expr_tree(line)->eval();
-
- BOOST_REQUIRE_EQUAL(result.infer_type(), expression::TYPE_STRING);
- BOOST_CHECK_EQUAL(result.get_string(), "bar");
-}
-
-int dummy_false_counter = 0;
-expression_literal dummy_false(expression_container::expr_list_type)
-{
- dummy_false_counter++;
- std::cout << "Running dummy/false statement." << std::endl;
- return expression_literal(false);
-}
-
-BOOST_AUTO_TEST_CASE(test_multi_commmand)
-{
- SETUP_FT_AND_PARSER();
-
- ft->register_function(
- "DUMMY", boost::bind(&dummy_false, _1), expression::TYPE_BOOL, no_args);
-
- dummy_false_counter = 0;
- p->create_expr_tree("DUMMY(), DUMMY(), DUMMY()")->eval();
- BOOST_CHECK_EQUAL(dummy_false_counter, 3);
-
- dummy_false_counter = 0;
- p->create_expr_tree("DUMMY() AND DUMMY() AND DUMMY()")->eval();
- BOOST_CHECK_EQUAL(dummy_false_counter, 1);
-
- dummy_false_counter = 0;
- p->create_expr_tree("DUMMY() OR DUMMY() OR DUMMY()")->eval();
- BOOST_CHECK_EQUAL(dummy_false_counter, 3);
-}
diff --git a/host/tests/node_connect_test.cpp b/host/tests/node_connect_test.cpp
deleted file mode 100644
index 97d052a06..000000000
--- a/host/tests/node_connect_test.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-//
-// Copyright 2014 Ettus Research LLC
-// Copyright 2018 Ettus Research, a National Instruments Company
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-
-#include "graph.hpp"
-#include <boost/test/unit_test.hpp>
-#include <iostream>
-
-using namespace uhd::rfnoc;
-
-class source_node : public test_node
-{
-public:
- typedef boost::shared_ptr<source_node> sptr;
-
- source_node(const std::string& test_id, size_t output_port)
- : test_node(test_id), active_rx_streamer_on_port(0), _output_port(output_port){};
-
- void set_rx_streamer(bool active, const size_t port)
- {
- if (active) {
- std::cout << "[source_node] Someone is registering a rx streamer on port "
- << port << std::endl;
- active_rx_streamer_on_port = port;
- }
- }
- size_t active_rx_streamer_on_port;
-
-protected:
- size_t _request_output_port(const size_t, const uhd::device_addr_t&) const
- {
- return _output_port;
- }
-
- const size_t _output_port;
-
-}; /* class result_node */
-
-class sink_node : public test_node
-{
-public:
- typedef boost::shared_ptr<sink_node> sptr;
-
- sink_node(const std::string& test_id, size_t input_port)
- : test_node(test_id), active_tx_streamer_on_port(0), _input_port(input_port){};
-
- void set_tx_streamer(bool active, const size_t port)
- {
- if (active) {
- std::cout << "[sink_node] Someone is registering a tx streamer on port "
- << port << std::endl;
- active_tx_streamer_on_port = port;
- }
- }
- size_t active_tx_streamer_on_port;
-
-protected:
- size_t _request_input_port(const size_t, const uhd::device_addr_t&) const
- {
- return _input_port;
- }
-
- const size_t _input_port;
-
-}; /* class result_node */
-
-#define MAKE_SOURCE_NODE(name, port) source_node::sptr name(new source_node(#name, port));
-#define MAKE_SINK_NODE(name, port) sink_node::sptr name(new sink_node(#name, port));
-
-BOOST_AUTO_TEST_CASE(test_simple_connect)
-{
- MAKE_SOURCE_NODE(node_A, 42);
- MAKE_SINK_NODE(node_B, 23);
-
- size_t src_port = node_A->connect_downstream(node_B, 1);
- size_t dst_port = node_B->connect_upstream(node_A, 2);
-
- BOOST_CHECK_EQUAL(src_port, 42);
- BOOST_CHECK_EQUAL(dst_port, 23);
-
- node_A->set_downstream_port(src_port, dst_port);
- node_B->set_upstream_port(dst_port, src_port);
- BOOST_CHECK_EQUAL(node_A->get_downstream_port(src_port), dst_port);
- BOOST_CHECK_EQUAL(node_B->get_upstream_port(dst_port), src_port);
-
- BOOST_REQUIRE_THROW(node_A->get_downstream_port(999), uhd::value_error);
-}
-
-BOOST_AUTO_TEST_CASE(test_fail)
-{
- MAKE_SOURCE_NODE(node_A, 42);
- MAKE_SINK_NODE(node_B, ANY_PORT);
-
- node_A->connect_downstream(node_B, 1);
- BOOST_REQUIRE_THROW(node_B->connect_upstream(node_A, 2), uhd::type_error);
-}
-
-BOOST_AUTO_TEST_CASE(test_set_streamers)
-{
- MAKE_SOURCE_NODE(node_A, 0);
- MAKE_NODE(node_B);
- MAKE_SINK_NODE(node_C, 0);
-
- size_t src_port_A = node_A->connect_downstream(node_B, 0);
- size_t src_port_B = node_B->connect_downstream(node_C, 0);
- size_t dst_port_B = node_B->connect_upstream(node_A, 0);
- size_t dst_port_C = node_C->connect_upstream(node_B, 0);
-
- std::cout << "src_port_A: " << src_port_A << std::endl;
- std::cout << "src_port_B: " << src_port_B << std::endl;
- std::cout << "dst_port_B: " << dst_port_B << std::endl;
- std::cout << "dst_port_C: " << dst_port_C << std::endl;
-
- node_A->set_downstream_port(src_port_A, dst_port_B);
- node_B->set_upstream_port(dst_port_B, src_port_A);
- node_B->set_downstream_port(src_port_B, dst_port_C);
- node_C->set_upstream_port(dst_port_C, src_port_B);
-
- node_A->set_tx_streamer(true, 0);
- node_C->set_rx_streamer(true, 0);
-
- BOOST_CHECK_EQUAL(node_A->active_rx_streamer_on_port, src_port_A);
- BOOST_CHECK_EQUAL(node_C->active_tx_streamer_on_port, dst_port_C);
-}
diff --git a/host/tests/packet_handler_benchmark.cpp b/host/tests/packet_handler_benchmark.cpp
index 6d4849831..d0a28bdc2 100644
--- a/host/tests/packet_handler_benchmark.cpp
+++ b/host/tests/packet_handler_benchmark.cpp
@@ -13,13 +13,11 @@
#include "../lib/transport/super_recv_packet_handler.hpp"
#include "../lib/transport/super_send_packet_handler.hpp"
-#include "../lib/usrp/device3/device3_flow_ctrl.hpp"
#include "common/mock_zero_copy.hpp"
#include <uhd/convert.hpp>
#include <uhd/transport/chdr.hpp>
#include <uhd/transport/zero_copy.hpp>
#include <uhd/transport/zero_copy_flow_ctrl.hpp>
-#include <uhd/types/sid.hpp>
#include <uhd/utils/safe_main.hpp>
#include <uhd/utils/thread.hpp>
#include <boost/program_options.hpp>
@@ -47,7 +45,6 @@ struct rx_fc_cache_t
uint32_t total_packets_consumed = 0;
//! Sequence number of next flow control packet
uint64_t seq_num = 0;
- uhd::sid_t sid;
uhd::transport::zero_copy_if::sptr xport;
std::function<uint32_t(uint32_t)> to_host;
std::function<uint32_t(uint32_t)> from_host;
@@ -155,8 +152,7 @@ inline bool tx_flow_ctrl(boost::shared_ptr<tx_fc_cache_t> fc_cache,
}
inline void tx_flow_ctrl_ack(boost::shared_ptr<tx_fc_cache_t> fc_cache,
- uhd::transport::zero_copy_if::sptr /*send_xport*/,
- uhd::sid_t /*send_sid*/)
+ uhd::transport::zero_copy_if::sptr /*send_xport*/)
{
if (not fc_cache->fc_received) {
return;
@@ -296,7 +292,7 @@ void benchmark_send_packet_handler(
// Configure flow control ack
streamer->set_xport_chan_post_send_cb(0, [fc_cache, zero_copy_xport]() {
- tx_flow_ctrl_ack(fc_cache, zero_copy_xport, 0);
+ tx_flow_ctrl_ack(fc_cache, zero_copy_xport);
});
// Allocate buffer
diff --git a/host/tests/rate_node_test.cpp b/host/tests/rate_node_test.cpp
deleted file mode 100644
index 85502c325..000000000
--- a/host/tests/rate_node_test.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-//
-// Copyright 2014 Ettus Research LLC
-// Copyright 2018 Ettus Research, a National Instruments Company
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-
-#include "graph.hpp"
-#include <uhd/rfnoc/rate_node_ctrl.hpp>
-#include <boost/test/unit_test.hpp>
-#include <iostream>
-
-using namespace uhd::rfnoc;
-
-// test class derived, knows about rates
-class rate_aware_node : public test_node, public rate_node_ctrl
-{
-public:
- typedef boost::shared_ptr<rate_aware_node> sptr;
-
- rate_aware_node(const std::string& test_id) : test_node(test_id){};
-
-}; /* class rate_aware_node */
-
-// test class derived, sets rates
-class rate_setting_node : public test_node, public rate_node_ctrl
-{
-public:
- typedef boost::shared_ptr<rate_setting_node> sptr;
-
- rate_setting_node(const std::string& test_id, double samp_rate)
- : test_node(test_id), _samp_rate(samp_rate){};
-
- double get_input_samp_rate(size_t)
- {
- return _samp_rate;
- };
- double get_output_samp_rate(size_t)
- {
- return _samp_rate;
- };
-
-private:
- double _samp_rate;
-
-}; /* class rate_setting_node */
-
-#define MAKE_RATE_NODE(name) rate_aware_node::sptr name(new rate_aware_node(#name));
-#define MAKE_RATE_SETTING_NODE(name, rate) \
- rate_setting_node::sptr name(new rate_setting_node(#name, rate));
-
-BOOST_AUTO_TEST_CASE(test_simplest_downstream_search)
-{
- const double test_rate = 0.25;
- MAKE_RATE_NODE(node_A);
- MAKE_RATE_SETTING_NODE(node_B, test_rate);
-
- // Simplest possible scenario: Connect B downstream of A and let
- // it find B
- connect_nodes(node_A, node_B);
-
- double result_rate = node_A->get_input_samp_rate();
- BOOST_CHECK_EQUAL(result_rate, test_rate);
-}
-
-BOOST_AUTO_TEST_CASE(test_skip_downstream_search)
-{
- const double test_rate = 0.25;
- MAKE_RATE_NODE(node_A);
- MAKE_NODE(node_B);
- MAKE_RATE_SETTING_NODE(node_C, test_rate);
-
- // Slightly more elaborate: Add another block in between that has no
- // clue about rates
- connect_nodes(node_A, node_B);
- connect_nodes(node_B, node_C);
-
- double result_rate = node_A->get_input_samp_rate();
- BOOST_CHECK_EQUAL(result_rate, test_rate);
-}
-
-BOOST_AUTO_TEST_CASE(test_tree_downstream_search)
-{
- const double test_rate = 0.25;
- MAKE_RATE_NODE(node_A);
- MAKE_NODE(node_B0);
- MAKE_RATE_SETTING_NODE(node_B1, test_rate);
- MAKE_RATE_SETTING_NODE(node_C0, test_rate);
- MAKE_RATE_SETTING_NODE(node_C1, rate_node_ctrl::RATE_UNDEFINED);
-
- // Tree: Downstream of our first node are 3 rate setting blocks.
- // Two set the same rate, the third does not care.
- connect_nodes(node_A, node_B0);
- connect_nodes(node_A, node_B1);
- connect_nodes(node_B0, node_C0);
- connect_nodes(node_B0, node_C1);
-
- double result_rate = node_A->get_input_samp_rate();
- BOOST_CHECK_EQUAL(result_rate, test_rate);
-}
-
-BOOST_AUTO_TEST_CASE(test_tree_downstream_search_throw)
-{
- const double test_rate = 0.25;
- MAKE_RATE_NODE(node_A);
- MAKE_NODE(node_B0);
- MAKE_RATE_SETTING_NODE(node_B1, test_rate);
- MAKE_RATE_SETTING_NODE(node_C0, test_rate);
- MAKE_RATE_SETTING_NODE(node_C1, test_rate * 2);
-
- // Tree: Downstream of our first node are 3 rate setting blocks.
- // Two set the same rate, the third has a different rate.
- // This will cause a throw.
- connect_nodes(node_A, node_B0);
- connect_nodes(node_A, node_B1);
- connect_nodes(node_B0, node_C0);
- connect_nodes(node_B0, node_C1);
-
- BOOST_CHECK_THROW(node_A->get_input_samp_rate(), uhd::runtime_error);
-}
-
-BOOST_AUTO_TEST_CASE(test_skip_upstream_search)
-{
- const double test_rate = 0.25;
- MAKE_RATE_SETTING_NODE(node_A, test_rate);
- MAKE_NODE(node_B);
- MAKE_RATE_NODE(node_C);
-
- // Slightly more elaborate: Add another block in between that has no
- // clue about rates
- connect_nodes(node_A, node_B);
- connect_nodes(node_B, node_C);
-
- double result_rate = node_C->get_output_samp_rate();
- BOOST_CHECK_EQUAL(result_rate, test_rate);
-}
diff --git a/host/tests/sid_t_test.cpp b/host/tests/sid_t_test.cpp
deleted file mode 100644
index 2a13995df..000000000
--- a/host/tests/sid_t_test.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-//
-// Copyright 2014 Ettus Research LLC
-// Copyright 2018 Ettus Research, a National Instruments Company
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-
-#include <uhd/exception.hpp>
-#include <uhd/types/sid.hpp>
-#include <boost/test/unit_test.hpp>
-#include <iostream>
-#include <sstream>
-
-using uhd::sid_t;
-
-BOOST_AUTO_TEST_CASE(test_sid_t)
-{
- uint32_t sid_value = 0x01020310;
- sid_t sid(sid_value);
-
- BOOST_CHECK_EQUAL(sid.is_set(), true);
- BOOST_CHECK_EQUAL(sid.to_pp_string(), "1.2>3.16");
- BOOST_CHECK_EQUAL(sid.to_pp_string_hex(), "01:02>03:10");
- BOOST_CHECK_EQUAL(sid.get_src(), (uint32_t)0x0102);
- BOOST_CHECK_EQUAL(sid.get_dst(), (uint32_t)0x0310);
- BOOST_CHECK_EQUAL(sid.get_src_addr(), (uint32_t)0x01);
- BOOST_CHECK_EQUAL(sid.get_src_endpoint(), (uint32_t)0x02);
- BOOST_CHECK_EQUAL(sid.get_dst_addr(), (uint32_t)0x03);
- BOOST_CHECK_EQUAL(sid.get_dst_endpoint(), (uint32_t)0x10);
- BOOST_CHECK_EQUAL(sid == sid, true);
- BOOST_CHECK_EQUAL(sid == sid_value, true);
-
- uint32_t check_sid_val = (uint32_t)sid;
- BOOST_CHECK_EQUAL(check_sid_val, sid_value);
-
- std::stringstream ss_dec;
- ss_dec << sid;
- BOOST_CHECK_EQUAL(ss_dec.str(), "1.2>3.16");
-
- std::stringstream ss_hex;
- ss_hex << std::hex << sid;
- BOOST_CHECK_EQUAL(ss_hex.str(), "01:02>03:10");
-
- sid_t empty_sid;
- BOOST_CHECK_EQUAL(empty_sid.is_set(), false);
- BOOST_CHECK_EQUAL(empty_sid.to_pp_string(), "x.x>x.x");
- BOOST_CHECK_EQUAL(empty_sid.to_pp_string_hex(), "xx:xx>xx:xx");
- BOOST_CHECK_EQUAL(empty_sid == sid, false);
- BOOST_CHECK_EQUAL(empty_sid == sid_value, false);
- BOOST_CHECK_EQUAL((bool)empty_sid, false);
-
- empty_sid = sid_value; // No longer empty
- BOOST_CHECK_EQUAL(empty_sid.is_set(), true);
- BOOST_CHECK_EQUAL(empty_sid == sid, true);
-}
-
-BOOST_AUTO_TEST_CASE(test_sid_t_set)
-{
- uint32_t sid_value = 0x0;
- sid_t sid(sid_value);
-
- sid.set(0x01020304);
- BOOST_CHECK_EQUAL(sid.get(), (uint32_t)0x01020304);
- BOOST_CHECK_EQUAL(sid.get_src_addr(), (uint32_t)0x01);
- BOOST_CHECK_EQUAL(sid.get_src_endpoint(), (uint32_t)0x02);
- BOOST_CHECK_EQUAL(sid.get_dst_addr(), (uint32_t)0x03);
- BOOST_CHECK_EQUAL(sid.get_dst_endpoint(), (uint32_t)0x04);
- BOOST_CHECK_EQUAL(sid.get_dst_xbarport(), (uint32_t)0x0);
- BOOST_CHECK_EQUAL(sid.get_dst_blockport(), (uint32_t)0x4);
-
- sid.set_src_addr(0x0a);
- BOOST_CHECK_EQUAL(sid.get(), (uint32_t)0x0a020304);
- BOOST_CHECK_EQUAL(sid.get_src_addr(), (uint32_t)0x0a);
- BOOST_CHECK_EQUAL(sid.get_src_endpoint(), (uint32_t)0x02);
- BOOST_CHECK_EQUAL(sid.get_dst_addr(), (uint32_t)0x03);
- BOOST_CHECK_EQUAL(sid.get_dst_endpoint(), (uint32_t)0x04);
-
- sid.set_src_endpoint(0x0b);
- BOOST_CHECK_EQUAL(sid.get(), (uint32_t)0x0a0b0304);
- BOOST_CHECK_EQUAL(sid.get_src_addr(), (uint32_t)0x0a);
- BOOST_CHECK_EQUAL(sid.get_src_endpoint(), (uint32_t)0x0b);
- BOOST_CHECK_EQUAL(sid.get_dst_addr(), (uint32_t)0x03);
- BOOST_CHECK_EQUAL(sid.get_dst_endpoint(), (uint32_t)0x04);
-
- sid.set_dst_addr(0x0c);
- BOOST_CHECK_EQUAL(sid.get(), (uint32_t)0x0a0b0c04);
- BOOST_CHECK_EQUAL(sid.get_src_addr(), (uint32_t)0x0a);
- BOOST_CHECK_EQUAL(sid.get_src_endpoint(), (uint32_t)0x0b);
- BOOST_CHECK_EQUAL(sid.get_dst_addr(), (uint32_t)0x0c);
- BOOST_CHECK_EQUAL(sid.get_dst_endpoint(), (uint32_t)0x04);
-
- sid.set_dst_endpoint(0x0d);
- BOOST_CHECK_EQUAL(sid.get(), (uint32_t)0x0a0b0c0d);
- BOOST_CHECK_EQUAL(sid.get_src_addr(), (uint32_t)0x0a);
- BOOST_CHECK_EQUAL(sid.get_src_endpoint(), (uint32_t)0x0b);
- BOOST_CHECK_EQUAL(sid.get_dst_addr(), (uint32_t)0x0c);
- BOOST_CHECK_EQUAL(sid.get_dst_endpoint(), (uint32_t)0x0d);
-
- sid.set_dst_xbarport(0xb);
- BOOST_CHECK_EQUAL(sid.get(), (uint32_t)0x0a0b0cbd);
- BOOST_CHECK_EQUAL(sid.get_src_addr(), (uint32_t)0x0a);
- BOOST_CHECK_EQUAL(sid.get_src_endpoint(), (uint32_t)0x0b);
- BOOST_CHECK_EQUAL(sid.get_dst_addr(), (uint32_t)0x0c);
- BOOST_CHECK_EQUAL(sid.get_dst_endpoint(), (uint32_t)0xbd);
-
- sid.set_dst_blockport(0xc);
- BOOST_CHECK_EQUAL(sid.get(), (uint32_t)0x0a0b0cbc);
- BOOST_CHECK_EQUAL(sid.get_src_addr(), (uint32_t)0x0a);
- BOOST_CHECK_EQUAL(sid.get_src_endpoint(), (uint32_t)0x0b);
- BOOST_CHECK_EQUAL(sid.get_dst_addr(), (uint32_t)0x0c);
- BOOST_CHECK_EQUAL(sid.get_dst_endpoint(), (uint32_t)0xbc);
-
- const sid_t flipped_sid = sid.reversed();
- BOOST_CHECK_EQUAL(flipped_sid.get(), (uint32_t)0x0cbc0a0b);
- BOOST_CHECK_EQUAL(flipped_sid.reversed(), sid);
-
- const sid_t sid2 = sid_t(sid.get_sid());
- BOOST_CHECK_EQUAL(sid2, sid);
-
- // In-place
- sid.reverse();
- BOOST_CHECK_EQUAL(sid.get(), (uint32_t)0x0cbc0a0b);
-}
-
-BOOST_AUTO_TEST_CASE(test_sid_t_from_str)
-{
- sid_t sid("1.2>3.4");
- BOOST_CHECK_EQUAL(sid.get_src_addr(), (uint32_t)1);
- BOOST_CHECK_EQUAL(sid.get_src_endpoint(), (uint32_t)2);
- BOOST_CHECK_EQUAL(sid.get_dst_addr(), (uint32_t)3);
- BOOST_CHECK_EQUAL(sid.get_dst_endpoint(), (uint32_t)4);
-
- sid = "01:02>03:10";
- BOOST_CHECK_EQUAL(sid.get_src_addr(), (uint32_t)1);
- BOOST_CHECK_EQUAL(sid.get_src_endpoint(), (uint32_t)2);
- BOOST_CHECK_EQUAL(sid.get_dst_addr(), (uint32_t)3);
- BOOST_CHECK_EQUAL(sid.get_dst_endpoint(), (uint32_t)16);
-
- sid = "01:06/03:10";
- BOOST_CHECK_EQUAL(sid.get_src_addr(), (uint32_t)1);
- BOOST_CHECK_EQUAL(sid.get_src_endpoint(), (uint32_t)6);
- BOOST_CHECK_EQUAL(sid.get_dst_addr(), (uint32_t)3);
- BOOST_CHECK_EQUAL(sid.get_dst_endpoint(), (uint32_t)16);
-
- sid = "01:02:04:10";
- BOOST_CHECK_EQUAL(sid.get_src_addr(), (uint32_t)1);
- BOOST_CHECK_EQUAL(sid.get_src_endpoint(), (uint32_t)2);
- BOOST_CHECK_EQUAL(sid.get_dst_addr(), (uint32_t)4);
- BOOST_CHECK_EQUAL(sid.get_dst_endpoint(), (uint32_t)16);
-
- BOOST_REQUIRE_THROW(sid_t fail_sid("foobar"), uhd::value_error);
- BOOST_REQUIRE_THROW(sid_t fail_sid("01:02:03:4"), uhd::value_error);
- BOOST_REQUIRE_THROW(sid_t fail_sid("01:02:03:004"), uhd::value_error);
- BOOST_REQUIRE_THROW(sid_t fail_sid("1.2.3.0004"), uhd::value_error);
-}
diff --git a/host/tests/stream_sig_test.cpp b/host/tests/stream_sig_test.cpp
deleted file mode 100644
index 41c07c14f..000000000
--- a/host/tests/stream_sig_test.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-// Copyright 2014-2015 Ettus Research LLC
-// Copyright 2018 Ettus Research, a National Instruments Company
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-
-#include <uhd/exception.hpp>
-#include <uhd/rfnoc/stream_sig.hpp>
-#include <boost/test/unit_test.hpp>
-#include <iostream>
-
-using namespace uhd::rfnoc;
-
-BOOST_AUTO_TEST_CASE(test_stream_sig)
-{
- stream_sig_t stream_sig;
-
- BOOST_CHECK_EQUAL(stream_sig.item_type, "");
- BOOST_CHECK_EQUAL(stream_sig.vlen, 0);
- BOOST_CHECK_EQUAL(stream_sig.packet_size, 0);
- BOOST_CHECK_EQUAL(stream_sig.is_bursty, false);
-
- std::stringstream ss;
- ss << stream_sig;
- // Eventually actually test the contents
- std::cout << ss.str() << std::endl;
-}
-
-BOOST_AUTO_TEST_CASE(test_stream_sig_compat)
-{
- stream_sig_t upstream_sig;
- stream_sig_t downstream_sig;
-
- BOOST_CHECK(stream_sig_t::is_compatible(upstream_sig, downstream_sig));
- upstream_sig.vlen = 32;
- BOOST_CHECK(stream_sig_t::is_compatible(upstream_sig, downstream_sig));
- downstream_sig.vlen = 32;
- BOOST_CHECK(stream_sig_t::is_compatible(upstream_sig, downstream_sig));
- upstream_sig.vlen = 16;
- BOOST_CHECK(not stream_sig_t::is_compatible(upstream_sig, downstream_sig));
- upstream_sig.vlen = 32;
- BOOST_CHECK(stream_sig_t::is_compatible(upstream_sig, downstream_sig));
- upstream_sig.packet_size = 8;
- BOOST_CHECK(stream_sig_t::is_compatible(upstream_sig, downstream_sig));
- downstream_sig.packet_size = 12;
- BOOST_CHECK(not stream_sig_t::is_compatible(upstream_sig, downstream_sig));
- upstream_sig.packet_size = 0;
- BOOST_CHECK(stream_sig_t::is_compatible(upstream_sig, downstream_sig));
- downstream_sig.item_type = "";
- BOOST_CHECK(stream_sig_t::is_compatible(upstream_sig, downstream_sig));
- upstream_sig.item_type = "sc16";
- downstream_sig.item_type = "s8";
- BOOST_CHECK(not stream_sig_t::is_compatible(upstream_sig, downstream_sig));
-}
-
-BOOST_AUTO_TEST_CASE(test_stream_sig_types)
-{
- stream_sig_t stream_sig;
- BOOST_CHECK_EQUAL(stream_sig.get_bytes_per_item(), 0);
- stream_sig.item_type = "sc16";
- BOOST_CHECK_EQUAL(stream_sig.get_bytes_per_item(), 4);
- stream_sig.item_type = "sc12";
- BOOST_CHECK_EQUAL(stream_sig.get_bytes_per_item(), 3);
- stream_sig.item_type = "sc8";
- BOOST_CHECK_EQUAL(stream_sig.get_bytes_per_item(), 2);
- stream_sig.item_type = "s16";
- BOOST_CHECK_EQUAL(stream_sig.get_bytes_per_item(), 2);
- stream_sig.item_type = "s8";
- BOOST_CHECK_EQUAL(stream_sig.get_bytes_per_item(), 1);
- stream_sig.item_type = "fc32";
- BOOST_CHECK_EQUAL(stream_sig.get_bytes_per_item(), 8);
- stream_sig.item_type = "not_a_type";
- BOOST_REQUIRE_THROW(stream_sig.get_bytes_per_item(), uhd::key_error);
-}
diff --git a/host/tests/tick_node_test.cpp b/host/tests/tick_node_test.cpp
deleted file mode 100644
index ccec67c43..000000000
--- a/host/tests/tick_node_test.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-//
-// Copyright 2014 Ettus Research LLC
-// Copyright 2018 Ettus Research, a National Instruments Company
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-
-#include "graph.hpp"
-#include <uhd/rfnoc/tick_node_ctrl.hpp>
-#include <boost/test/unit_test.hpp>
-#include <iostream>
-
-using namespace uhd::rfnoc;
-
-// test class derived, knows about rates
-class tick_aware_node : public test_node, public tick_node_ctrl
-{
-public:
- typedef boost::shared_ptr<tick_aware_node> sptr;
-
- tick_aware_node(const std::string& test_id) : test_node(test_id){};
-
-}; /* class tick_aware_node */
-
-// test class derived, sets rates
-class tick_setting_node : public test_node, public tick_node_ctrl
-{
-public:
- typedef boost::shared_ptr<tick_setting_node> sptr;
-
- tick_setting_node(const std::string& test_id, double tick_rate)
- : test_node(test_id), _tick_rate(tick_rate){};
-
-protected:
- double _get_tick_rate()
- {
- return _tick_rate;
- };
-
-private:
- const double _tick_rate;
-
-}; /* class tick_setting_node */
-
-#define MAKE_TICK_NODE(name) tick_aware_node::sptr name(new tick_aware_node(#name));
-#define MAKE_TICK_SETTING_NODE(name, rate) \
- tick_setting_node::sptr name(new tick_setting_node(#name, rate));
-
-BOOST_AUTO_TEST_CASE(test_simplest_downstream_search)
-{
- const double test_rate = 0.25;
- MAKE_TICK_NODE(node_A);
- MAKE_TICK_SETTING_NODE(node_B, test_rate);
-
- // Simplest possible scenario: Connect B downstream of A and let
- // it find B
- connect_nodes(node_A, node_B);
- node_A->set_tx_streamer(true, 0);
- node_B->set_rx_streamer(true, 0);
-
- double result_rate = node_A->get_tick_rate();
- BOOST_CHECK_EQUAL(result_rate, test_rate);
-}
-
-BOOST_AUTO_TEST_CASE(test_both_ways_search)
-{
- const double test_rate = 0.25;
- MAKE_TICK_SETTING_NODE(node_A, tick_node_ctrl::RATE_UNDEFINED);
- MAKE_TICK_NODE(node_B);
- MAKE_TICK_SETTING_NODE(node_C, test_rate);
-
- connect_nodes(node_A, node_B);
- connect_nodes(node_B, node_C);
- node_A->set_tx_streamer(true, 0);
- node_B->set_tx_streamer(true, 0);
- node_B->set_rx_streamer(true, 0);
- node_C->set_rx_streamer(true, 0);
-
- double result_rate = node_B->get_tick_rate();
- BOOST_CHECK_EQUAL(result_rate, test_rate);
-}
-
-BOOST_AUTO_TEST_CASE(test_both_ways_search_reversed)
-{
- const double test_rate = 0.25;
- MAKE_TICK_SETTING_NODE(node_A, test_rate);
- MAKE_TICK_NODE(node_B);
- MAKE_TICK_SETTING_NODE(node_C, tick_node_ctrl::RATE_UNDEFINED);
-
- connect_nodes(node_A, node_B);
- connect_nodes(node_B, node_C);
- node_A->set_tx_streamer(true, 0);
- node_B->set_tx_streamer(true, 0);
- node_B->set_rx_streamer(true, 0);
- node_C->set_rx_streamer(true, 0);
-
- double result_rate = node_B->get_tick_rate();
- BOOST_CHECK_EQUAL(result_rate, test_rate);
-}
-
-BOOST_AUTO_TEST_CASE(test_both_ways_search_fail)
-{
- const double test_rate = 0.25;
- MAKE_TICK_SETTING_NODE(node_A, test_rate);
- MAKE_TICK_NODE(node_B);
- MAKE_TICK_SETTING_NODE(node_C, 2 * test_rate);
-
- connect_nodes(node_A, node_B);
- connect_nodes(node_B, node_C);
- node_A->set_tx_streamer(true, 0);
- node_B->set_tx_streamer(true, 0);
- node_B->set_rx_streamer(true, 0);
- node_C->set_rx_streamer(true, 0);
-
- BOOST_CHECK_THROW(node_B->get_tick_rate(), uhd::runtime_error);
-}