|
μHAL (v2.7.9)
Part of the IPbus software repository
|
Go to the documentation of this file.
40 #include <boost/test/unit_test.hpp>
48 #define N_1MB uint32_t(1024*1024/4)
57 HwInterface
hw = getHwInterface();
63 uint32_t x1 =
static_cast<uint32_t
> ( rand() );
66 uint32_t x2 =
static_cast<uint32_t
> ( rand() );
69 std::vector<uint32_t> xx1;
71 for (
size_t i=0; i!=
N_1MB; ++i )
73 xx1.push_back (
static_cast<uint32_t
> ( rand() ) );
78 std::vector<uint32_t> xx2;
80 for (
size_t i=0; i!=
N_1MB; ++i )
82 xx2.
push_back (
static_cast<uint32_t
> ( rand() ) );
96 bool correct_block_write_read_subsystem1 =
true;
98 std::vector< uint32_t >::const_iterator j1=xx1.begin();
100 for ( ; i1!=mem1.
end(); ++i1 , ++j1 )
102 correct_block_write_read_subsystem1 = correct_block_write_read_subsystem1 && ( *i1 == *j1 );
106 BOOST_CHECK ( correct_block_write_read_subsystem1 );
108 bool correct_block_write_read_subsystem2 =
true;
110 std::vector< uint32_t >::const_iterator j2=xx2.begin();
112 for ( ; i2!=mem2.
end(); ++i2 , ++j2 )
114 correct_block_write_read_subsystem2 = correct_block_write_read_subsystem2 && ( *i2 == *j2 );
118 BOOST_CHECK ( correct_block_write_read_subsystem2 );
const T & at(std::size_t aIndex) const
If the memory has previously been marked as valid, give random access into memory.
void push_back(const T &aValue)
If the memory has not previously been marked as valid, add an entry to the end of it.
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.
ValHeader writeBlock(const std::vector< uint32_t > &aValues) const
Write a block of data to a block of registers or a block-write port.
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)
T value() const
Return the value of the validated memory with check on validity.
void dispatch()
Make the IPbus client issue a dispatch.
const uint32_t & getAddress() const
Return the register address with which this node is associated.
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
ValWord< uint32_t > read() const
Read a single, unmasked, unsigned word.
std::vector< uint32_t >::const_iterator const_iterator
typedef iterator to be that of the underlying storage type
std::size_t size() const
Return the size of the underlying memory.
BOOST_CHECK_NO_THROW(hw.getNode("REG").writeBlock(xx))
BOOST_CHECK_EQUAL(mem.size(), N)
ValHeader write(const uint32_t &aValue) const
Write a single, unmasked word to a register.
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 ...