aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests
diff options
context:
space:
mode:
Diffstat (limited to 'host/tests')
-rw-r--r--host/tests/common/mock_transport.hpp25
-rw-r--r--host/tests/offload_io_srv_test.cpp24
2 files changed, 31 insertions, 18 deletions
diff --git a/host/tests/common/mock_transport.hpp b/host/tests/common/mock_transport.hpp
index 321f22830..a8dc761f1 100644
--- a/host/tests/common/mock_transport.hpp
+++ b/host/tests/common/mock_transport.hpp
@@ -40,12 +40,13 @@ public:
uint16_t src_addr,
uint32_t credits)
: _credits(credits)
+ , _frame_size(send_link->get_send_frame_size())
{
_send_addr = (dst_addr << 16) | (src_addr << 0);
_recv_addr = (src_addr << 16) | (dst_addr << 0);
/* Make message client for sending side-band messages */
- send_io_if::send_callback_t msg_send_cb = [this](frame_buff::uptr& buff,
+ send_io_if::send_callback_t msg_send_cb = [this](frame_buff::uptr buff,
send_link_if* link) {
uint32_t* data = (uint32_t*)buff->data();
data[ADDR_OFFSET] = this->_send_addr;
@@ -53,21 +54,25 @@ public:
link->release_send_buff(std::move(buff));
};
_msg_if = io_srv->make_send_client(
- send_link, MSG_BUFFS, msg_send_cb, recv_link_if::sptr(), 0, nullptr);
+ send_link, MSG_BUFFS, msg_send_cb, recv_link_if::sptr(), 0, nullptr, nullptr);
/* Make client for sending streaming data */
- send_io_if::send_callback_t send_cb = [this](frame_buff::uptr& buff,
+ send_io_if::send_callback_t send_cb = [this](frame_buff::uptr buff,
send_link_if* link) {
- this->send_buff(buff, link);
+ this->send_buff(std::move(buff), link);
};
recv_callback_t recv_cb = [this](frame_buff::uptr& buff,
recv_link_if* link,
send_link_if* /*send_link*/) {
return this->recv_buff(buff, link);
};
+ send_io_if::fc_callback_t fc_cb = [this](size_t) {
+ return this->_seqno < this->_ackno + this->_credits;
+ };
+
/* Pretend get 1 flow control message per sent packet */
_send_if = io_srv->make_send_client(
- send_link, credits, send_cb, recv_link, credits, recv_cb);
+ send_link, credits, send_cb, recv_link, credits, recv_cb, fc_cb);
}
~mock_send_transport() {}
@@ -99,6 +104,10 @@ public:
*/
frame_buff::uptr get_data_buff(int32_t timeout_ms)
{
+ if (!_send_if->wait_for_dest_ready(_frame_size, timeout_ms)) {
+ return frame_buff::uptr();
+ }
+
frame_buff::uptr buff = _send_if->get_send_buff(timeout_ms);
if (!buff) {
return frame_buff::uptr();
@@ -138,11 +147,8 @@ public:
* Callbacks execute on the I/O thread! Be careful about what state is
* touched. In addition, this callback should NOT sleep.
*/
- void send_buff(frame_buff::uptr& buff, send_link_if* send_link)
+ void send_buff(frame_buff::uptr buff, send_link_if* send_link)
{
- if (_seqno >= _ackno + _credits) {
- return;
- }
uint32_t* data = (uint32_t*)buff->data();
data[ADDR_OFFSET] = _send_addr;
data[SEQNO_OFFSET] = _seqno;
@@ -202,6 +208,7 @@ private:
send_io_if::sptr _send_if;
uint32_t _seqno = 0;
uint32_t _ackno = 0;
+ size_t _frame_size;
};
/*!
diff --git a/host/tests/offload_io_srv_test.cpp b/host/tests/offload_io_srv_test.cpp
index fbf9668be..806d4a3dc 100644
--- a/host/tests/offload_io_srv_test.cpp
+++ b/host/tests/offload_io_srv_test.cpp
@@ -76,6 +76,11 @@ public:
return _link->get_send_buff(timeout_ms);
}
+ bool wait_for_dest_ready(size_t, int32_t)
+ {
+ return true;
+ }
+
void release_send_buff(frame_buff::uptr buff)
{
_link->release_send_buff(std::move(buff));
@@ -108,7 +113,8 @@ public:
send_io_if::send_callback_t /*cb*/,
recv_link_if::sptr /*recv_link*/,
size_t /*num_recv_frames*/,
- recv_callback_t /*recv_cb*/)
+ recv_callback_t /*recv_cb*/,
+ send_io_if::fc_callback_t /*fc_cb*/)
{
return std::make_shared<mock_send_io>(send_link);
}
@@ -156,7 +162,7 @@ BOOST_AUTO_TEST_CASE(test_construction)
auto send_link = make_send_link(5);
io_srv->attach_send_link(send_link);
auto send_client =
- io_srv->make_send_client(send_link, 5, nullptr, nullptr, 0, nullptr);
+ io_srv->make_send_client(send_link, 5, nullptr, nullptr, 0, nullptr, nullptr);
}
for (const auto wait_mode : wait_modes) {
params_t params{{}, RECV_ONLY, wait_mode};
@@ -181,7 +187,7 @@ BOOST_AUTO_TEST_CASE(test_construction_with_options)
auto recv_link = make_recv_link(5);
io_srv->attach_recv_link(recv_link);
auto send_client =
- io_srv->make_send_client(send_link, 5, nullptr, nullptr, 0, nullptr);
+ io_srv->make_send_client(send_link, 5, nullptr, nullptr, 0, nullptr, nullptr);
auto recv_client =
io_srv->make_recv_client(recv_link, 5, nullptr, nullptr, 0, nullptr);
}
@@ -195,7 +201,7 @@ BOOST_AUTO_TEST_CASE(test_send)
auto send_link = make_send_link(5);
io_srv->attach_send_link(send_link);
auto send_client =
- io_srv->make_send_client(send_link, 1, nullptr, nullptr, 0, nullptr);
+ io_srv->make_send_client(send_link, 1, nullptr, nullptr, 0, nullptr, nullptr);
for (size_t i = 0; i < 10; i++) {
auto buff = send_client->get_send_buff(100);
@@ -244,7 +250,7 @@ BOOST_AUTO_TEST_CASE(test_send_recv)
io_srv->attach_recv_link(recv_link);
auto send_client =
- io_srv->make_send_client(send_link, 1, nullptr, nullptr, 0, nullptr);
+ io_srv->make_send_client(send_link, 1, nullptr, nullptr, 0, nullptr, nullptr);
auto recv_client =
io_srv->make_recv_client(recv_link, 1, nullptr, nullptr, 0, nullptr);
@@ -262,7 +268,7 @@ BOOST_AUTO_TEST_CASE(test_send_recv)
auto recv_client2 =
io_srv->make_recv_client(recv_link, 1, nullptr, nullptr, 0, nullptr);
auto send_client2 =
- io_srv->make_send_client(send_link, 1, nullptr, nullptr, 0, nullptr);
+ io_srv->make_send_client(send_link, 1, nullptr, nullptr, 0, nullptr, nullptr);
for (size_t i = 0; i < 5; i++) {
mock_io_srv->allocate_recv_frames(1, 1);
recv_client2->release_recv_buff(recv_client2->get_recv_buff(100));
@@ -297,11 +303,11 @@ BOOST_AUTO_TEST_CASE(test_attach_detach)
auto recv_client0 =
io_srv->make_recv_client(recv_link0, 1, nullptr, nullptr, 0, nullptr);
auto send_client0 =
- io_srv->make_send_client(send_link0, 1, nullptr, nullptr, 0, nullptr);
+ io_srv->make_send_client(send_link0, 1, nullptr, nullptr, 0, nullptr, nullptr);
auto recv_client1 =
io_srv->make_recv_client(recv_link1, 1, nullptr, nullptr, 0, nullptr);
auto send_client1 =
- io_srv->make_send_client(send_link1, 1, nullptr, nullptr, 0, nullptr);
+ io_srv->make_send_client(send_link1, 1, nullptr, nullptr, 0, nullptr, nullptr);
recv_link0->push_back_recv_packet(
boost::shared_array<uint8_t>(new uint8_t[FRAME_SIZE]), FRAME_SIZE);
@@ -337,7 +343,7 @@ BOOST_AUTO_TEST_CASE(test_attach_detach)
auto recv_client2 =
io_srv->make_recv_client(recv_link0, 1, nullptr, nullptr, 0, nullptr);
auto send_client2 =
- io_srv->make_send_client(send_link0, 1, nullptr, nullptr, 0, nullptr);
+ io_srv->make_send_client(send_link0, 1, nullptr, nullptr, 0, nullptr, nullptr);
recv_link0->push_back_recv_packet(
boost::shared_array<uint8_t>(new uint8_t[FRAME_SIZE]), FRAME_SIZE);