41 #include <boost/test/unit_test.hpp> 53 #define N_1MB 1024*1024/4 54 #define N_10MB 10*1024*1024/4 55 #define N_200MB 100*1024*1024/4 63 std::vector<size_t> lDepths;
65 lDepths.push_back(
N_4B);
66 lDepths.push_back(
N_1kB);
67 lDepths.push_back(
N_1MB);
77 for(
size_t i=0; i<lDepths.size(); i++) {
78 const size_t N = lDepths.at(i);
79 BOOST_TEST_MESSAGE(
" N = " << N);
83 std::vector<uint32_t>
xx;
85 for (
size_t i=0; i!= N; ++i )
87 xx.push_back ( static_cast<uint32_t> ( rand() ) );
107 std::vector< uint32_t >::const_iterator
j=xx.begin();
111 correct_block_write_read = correct_block_write_read && ( *i == *
j );
126 for(
size_t i=0; i<lDepths.size(); i++) {
127 const size_t N = lDepths.at(i);
128 BOOST_TEST_MESSAGE(
" N = " << N);
132 std::vector<uint32_t>
xx;
135 for (
size_t i=0; i!= N; ++i )
137 xx.push_back ( static_cast<uint32_t> ( rand() ) );
162 for(
size_t i=0; i<lDepths.size(); i++) {
163 const size_t N = lDepths.at(i);
164 BOOST_TEST_MESSAGE(
" N = " << N);
168 std::vector<uint32_t>
xx;
170 std::vector<uint32_t> yy;
172 for (
size_t i=0; i!= N; ++i )
174 xx.push_back ( static_cast<uint32_t> ( rand() ) );
175 yy.push_back ( static_cast<uint32_t> ( rand() ) );
216 std::vector< uint32_t >::const_iterator
j=xx.begin();
220 correct_block_write_read = correct_block_write_read && ( *i == *
j );
227 correct_block_write_read = correct_block_write_read && ( *i == *
j );
240 std::vector<uint32_t>
xx;
265 std::vector<uint32_t>
xx;
276 std::vector<uint32_t>
xx;
ValHeader writeBlockOffset(const std::vector< uint32_t > &aValues, const uint32_t &aOffset) const
Write a block of data to a block of registers or a block-write port.
bool correct_block_write_read
A class which bundles a node tree and an IPbus client interface together providing everything you nee...
std::vector< uint32_t >::const_iterator j
UHAL_TESTS_DEFINE_CLIENT_TEST_CASES(BlockReadWriteTestSuite, block_write_read, DummyHardwareFixture, { std::vector< size_t > lDepths=getBlockUnitTestDepths();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
void dispatch()
Make the IPbus client issue a dispatch.
BOOST_CHECK(!mem.valid())
ValVector< uint32_t > readBlockOffset(const uint32_t &aSize, const uint32_t &aOffset) const
Read a block of unsigned data from a block of registers or a block-read port.
BOOST_CHECK_THROW(hw.getNode("REG").writeBlockOffset(xx, 0), uhal::exception::BulkTransferOffsetRequestedForSingleRegister)
std::vector< size_t > getBlockUnitTestDepths()
const_iterator end() const
If the memory has previously been marked as valid, return a const iterator to the end (one past last ...
bool valid()
Return whether the Validated memory is marked as valid.
ValVector< uint32_t > readBlock(const uint32_t &aSize) const
Read a block of unsigned data from a block of registers or a block-read port.
block_access_type_violations
BOOST_CHECK_EQUAL(hw.getNode("SUBSYSTEM1.SUBMODULE.REG").getAddress(), hw.getNode("SUBSYSTEM1").getNode("SUBMODULE").getNode("REG").getAddress())
BOOST_CHECK_NO_THROW(hw.getNode("REG").writeBlock(xx))
const_iterator begin() const
If the memory has previously been marked as valid, return a const iterator to the beginning of the un...
std::vector< uint32_t > xx
std::size_t size() const
Return the size of the underlying memory.
ValVector< uint32_t > mem
std::vector< T > value() const
Return the value of the validated memory with check on validity.
block_offset_bigger_than_size_attribute
const T & at(std::size_t aIndex) const
If the memory has previously been marked as valid, give random access into memory.
const Node & getNode() const
Ping the target for this client.
ValHeader writeBlock(const std::vector< uint32_t > &aValues) const
Write a block of data to a block of registers or a block-write port.