|
μHAL (v2.7.9)
Part of the IPbus software repository
|
Go to the documentation of this file.
41 #include <boost/shared_ptr.hpp>
42 #include <boost/test/unit_test.hpp>
61 uint32_t
x =
static_cast<uint32_t
> ( rand() );
72 uint32_t y =
static_cast<uint32_t
> ( rand() ) & 0xF;
92 const uint32_t N =1024*1024/4;
95 std::vector<uint32_t>
xx;
97 for (
size_t i=0; i!= N; ++i )
99 xx.push_back (
static_cast<uint32_t
> ( rand() ) );
113 std::vector< uint32_t >::const_iterator
j=
xx.begin();
129 uint32_t x1 =
static_cast<uint32_t
> ( rand() );
130 uint32_t x2 =
static_cast<uint32_t
> ( rand() );
131 uint32_t x3 =
static_cast<uint32_t
> ( rand() );
139 if (
hw.
uri().find (
"ipbusudp-1.3://" ) != std::string::npos ||
140 hw.
uri().find (
"ipbustcp-1.3://" ) != std::string::npos ||
141 hw.
uri().find (
"chtcp-1.3://" ) != std::string::npos )
155 const uint32_t N =1024;
159 std::vector<uint32_t>
xx;
163 if (
hw.
uri().find (
"ipbusudp-1.3://" ) != std::string::npos ||
164 hw.
uri().find (
"ipbustcp-1.3://" ) != std::string::npos ||
165 hw.
uri().find (
"chtcp-1.3://" ) != std::string::npos )
174 uint32_t
x ( 0x00000000 );
176 for (
size_t i=0; i!= N; ++i )
181 x =
static_cast<uint32_t
> ( rand() );
185 x =
static_cast<uint32_t
> ( rand() );
196 for (
size_t i=1; i!= N; ++i )
const T & at(std::size_t aIndex) const
If the memory has previously been marked as valid, give random access into memory.
A class which bundles a node tree and an IPbus client interface together providing everything you nee...
ValHeader writeBlock(const uint32_t &aAddr, const std::vector< uint32_t > &aValues, const defs::BlockReadWriteMode &aMode=defs::INCREMENTAL)
Write a block of data to a block of registers or a block-write port.
void dispatch()
Method to dispatch all queued transactions, and wait until all corresponding responses have been rece...
bool correct_block_write_read
bool valid()
Return whether the Validated memory is marked as valid.
BOOST_CHECK(!mem.valid())
const_iterator begin() const
If the memory has previously been marked as valid, return a const iterator to the beginning of the un...
BOOST_CHECK_THROW(hw.getNode("REG").writeBlockOffset(xx, 0), uhal::exception::BulkTransferOffsetRequestedForSingleRegister)
std::vector< uint32_t >::const_iterator j
An abstract base class for defining the interface to the various IPbus clients as well as providing t...
T value() const
Return the value of the validated memory with check on validity.
const uint32_t & getAddress() const
Return the register address with which this node is associated.
ValWord< uint32_t > read(const uint32_t &aAddr)
Read a single, unmasked, unsigned word.
std::vector< uint32_t > xx
ClientInterface & getClient()
Get the underlying IPbus client.
UHAL_TESTS_DEFINE_CLIENT_TEST_CASES(BlockReadWriteTestSuite, block_write_read, DummyHardwareFixture, { std::vector< size_t > lDepths=getBlockUnitTestDepths(quickTest ? N_1MB :N_10MB);for(size_t i=0;i< lDepths.size();i++) { const size_t N=lDepths.at(i);BOOST_TEST_MESSAGE(" N = "<< N);HwInterface hw=getHwInterface();std::vector< uint32_t > xx;xx.reserve(N);for(size_t i=0;i!=N;++i) { xx.push_back(static_cast< uint32_t >(rand()));} hw.getNode("LARGE_MEM").writeBlock(xx);ValVector< uint32_t > mem=hw.getNode("LARGE_MEM").readBlock(N);BOOST_CHECK(!mem.valid());BOOST_CHECK_EQUAL(mem.size(), N);if(N > 0) { BOOST_CHECK_THROW(mem.at(0), uhal::exception::NonValidatedMemory);} BOOST_CHECK_THROW(mem.value(), uhal::exception::NonValidatedMemory);BOOST_CHECK_NO_THROW(hw.dispatch());BOOST_CHECK(mem.valid());BOOST_CHECK_EQUAL(mem.size(), N);if(N< N_10MB) { bool correct_block_write_read=true;std::vector< uint32_t >::const_iterator j=xx.begin();for(ValVector< uint32_t >::const_iterator i(mem.begin());i!=mem.end();++i,++j) { correct_block_write_read=correct_block_write_read &&(*i== *j);} BOOST_CHECK(correct_block_write_read);} } }) UHAL_TESTS_DEFINE_CLIENT_TEST_CASES(BlockReadWriteTestSuite
ValVector< uint32_t > readBlock(const uint32_t &aAddr, const uint32_t &aSize, const defs::BlockReadWriteMode &aMode=defs::INCREMENTAL)
Read a block of unsigned data from a block of registers or a block-read port.
ValWord< uint32_t > rmw_bits(const uint32_t &aAddr, const uint32_t &aANDterm, const uint32_t &aORterm)
Read the value of a register, apply the AND-term, apply the OR-term, set the register to this new val...
ValWord< uint32_t > rmw_sum(const uint32_t &aAddr, const int32_t &aAddend)
Read the value of a register, add the addend, set the register to this new value and return a copy of...
const std::string & uri() const
Return the url of the target for this client.
std::size_t size() const
Return the size of the underlying memory.
ValVector< uint32_t > mem
bool valid()
Return whether the Validated memory is marked as valid.
BOOST_CHECK_EQUAL(mem.size(), N)
const Node & getNode() const
Retrieve the top-level node.
const_iterator end() const
If the memory has previously been marked as valid, return a const iterator to the end (one past last ...
ValHeader write(const uint32_t &aAddr, const uint32_t &aValue)
Write a single, unmasked word to a register.