41 #include <boost/shared_ptr.hpp> 42 #include <boost/test/unit_test.hpp> 58 HwInterface
hw = getHwInterface();
60 ClientInterface*
c = &hw.getClient();
61 uint32_t
x =
static_cast<uint32_t
> ( rand() );
62 uint32_t
addr = hw.getNode (
"REG" ).getAddress();
70 BOOST_CHECK_THROW ( c->write ( addr,0xF0000000, 0xF0 ) ,uhal::exception::BitsSetWhichAreForbiddenByBitMask );
71 BOOST_CHECK_THROW ( c->write ( addr,0xFF, 0x0F ) ,uhal::exception::BitsSetWhichAreForbiddenByBitMask );
72 uint32_t y =
static_cast<uint32_t
> ( rand() ) & 0xF;
73 c->write ( addr,y, 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();
116 correct_block_write_read = correct_block_write_read && ( *i == *
j );
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() );
132 c->
write ( addr,x1 );
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() );
193 c->
write ( addr,xx[0] );
196 for (
size_t i=1; i!= N; ++i )
198 reg = c->
rmw_sum ( addr,xx[i] );
ValWord< uint32_t > read(const uint32_t &aAddr)
Read a single, unmasked, unsigned word.
void dispatch()
Method to dispatch all IPbus packets which are in the queue of IPbusPacketInfo's and wait until all q...
T value() const
Return the value of the validated memory with check on validity.
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
const uint32_t & getAddress() const
Return the register address with which this node is associated.
std::string uri() const
Return the url of the target for this client.
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...
BOOST_CHECK(!mem.valid())
ValHeader write(const uint32_t &aAddr, const uint32_t &aValue)
Write a single, unmasked word to a register.
BOOST_CHECK_THROW(hw.getNode("REG").writeBlockOffset(xx, 0), uhal::exception::BulkTransferOffsetRequestedForSingleRegister)
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.
BOOST_CHECK_EQUAL(hw.getNode("SUBSYSTEM1.SUBMODULE.REG").getAddress(), hw.getNode("SUBSYSTEM1").getNode("SUBMODULE").getNode("REG").getAddress())
bool valid()
Return whether the Validated memory is marked as valid.
const_iterator begin() const
If the memory has previously been marked as valid, return a const iterator to the beginning of the un...
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.
ClientInterface & getClient()
Get the underlying IPbus client.
std::vector< uint32_t > xx
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.
std::size_t size() const
Return the size of the underlying memory.
ValVector< uint32_t > mem
An abstract base class for defining the interface to the various IPbus clients as well as providing t...
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...
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.