From 0738580e6ef03f9676632ffc3bc7e8d9fb0bc09f Mon Sep 17 00:00:00 2001 From: Trung Tran Date: Tue, 9 Oct 2018 11:22:28 -0700 Subject: tests: device3_test: add graph impl test --- host/tests/common/mock_zero_copy.hpp | 88 ++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 host/tests/common/mock_zero_copy.hpp (limited to 'host/tests/common/mock_zero_copy.hpp') diff --git a/host/tests/common/mock_zero_copy.hpp b/host/tests/common/mock_zero_copy.hpp new file mode 100644 index 000000000..838975129 --- /dev/null +++ b/host/tests/common/mock_zero_copy.hpp @@ -0,0 +1,88 @@ +// +// Copyright 2018 Ettus Research, a National Instruments Company +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_MOCK_XPORT_HPP +#define INCLUDED_MOCK_XPORT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +/*********************************************************************** + * Transport mockups + **********************************************************************/ +/*! A single transport class that implements send() and recv() + * + * Tx and Rx are separate. We can access the other end of the FIFOs from + * this class. + */ +static constexpr size_t SEND_BUFF_SIZE = 1024; +static constexpr size_t RECV_BUFF_SIZE = 1024; + +/*********************************************************************** + * Dummy managed buffers for testing + **********************************************************************/ +class mock_msb : public uhd::transport::managed_send_buffer { + public: + void release(void) { /* nop */ + } + + sptr get_new(boost::shared_array mem, size_t* len) { + _mem = mem; + return make(this, mem.get(), *len); + } + + private: + boost::shared_array _mem; +}; + + +class mock_mrb : public uhd::transport::managed_recv_buffer { + public: + void release(void) { /* nop */ + } + + sptr get_new(boost::shared_array mem, size_t len) { + _mem = mem; + return make(this, _mem.get(), len); + } + + private: + boost::shared_array _mem; +}; + +class mock_zero_copy : public uhd::transport::zero_copy_if { + public: + typedef boost::shared_ptr sptr; + uhd::transport::managed_recv_buffer::sptr get_recv_buff(double); + + uhd::transport::managed_send_buffer::sptr get_send_buff(double); + + size_t get_num_recv_frames(void) const { return 1; } + size_t get_num_send_frames(void) const { return 1; } + size_t get_recv_frame_size(void) const { return RECV_BUFF_SIZE; } + size_t get_send_frame_size(void) const { return SEND_BUFF_SIZE; } + + private: + std::list> _tx_mems; + std::list _tx_lens; + + std::list> _rx_mems; + std::list _rx_lens; + + std::vector> _msbs; + std::vector> _mrbs; +}; + +#endif /*INCLUDED_MOCK_XPORT_HPP*/ \ No newline at end of file -- cgit v1.2.3