41 #include <boost/test/unit_test.hpp> 62 lAddr = lIt->getAddress();
70 std::vector<std::string> ids = hw.
getNodes();
71 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"REG" ) != ids.end() );
72 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"MEM" ) != ids.end() );
73 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"SUBSYSTEM1.REG" ) != ids.end() );
74 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"SUBSYSTEM1.MEM" ) != ids.end() );
75 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"SUBSYSTEM1.SUBMODULE.REG" ) != ids.end() );
76 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"SUBSYSTEM1.SUBMODULE.MEM" ) != ids.end() );
77 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"SUBSYSTEM2.REG" ) != ids.end() );
78 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"SUBSYSTEM2.MEM" ) != ids.end() );
79 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"SUBSYSTEM2.SUBMODULE.REG" ) != ids.end() );
80 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"SUBSYSTEM2.SUBMODULE.MEM" ) != ids.end() );
82 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"MEM" ) != ids.end() );
83 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"LARGE_MEM" ) != ids.end() );
84 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"SMALL_MEM" ) != ids.end() );
85 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"SUBSYSTEM1.MEM" ) != ids.end() );
86 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"SUBSYSTEM2.MEM" ) != ids.end() );
87 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"SUBSYSTEM1.SUBMODULE.MEM" ) != ids.end() );
88 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"SUBSYSTEM2.SUBMODULE.MEM" ) != ids.end() );
90 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"REG" ) != ids.end() );
91 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"MEM" ) != ids.end() );
92 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"SUBMODULE.REG" ) != ids.end() );
93 BOOST_CHECK ( std::find ( ids.begin(),ids.end(),
"SUBMODULE.MEM" ) != ids.end() );
117 uint32_t
x =
static_cast<uint32_t
> ( rand() );
std::vector< std::string > getNodes() const
Return all node IDs known to this HwInterface.
void iteration(const uhal::Node &parentNode)
const std::string & getId() const
Return the unique ID of the current node.
T value() const
Return the value of the validated memory with check on validity.
const defs::BlockReadWriteMode & getMode() const
Return whether the node represents a single register, a block of registers or a block-read/write port...
A class which bundles a node tree and an IPbus client interface together providing everything you nee...
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.
const std::string & getTags() const
Return the optional tags string which the user can specify for the current node.
const uint32_t & getMask() const
Return the mask to be applied if this node is a sub-field, rather than an entire register.
void dispatch()
Make the IPbus client issue a dispatch.
const uint32_t & getSize() const
Return the maximum size available to a block read/write.
const_iterator end() const
BOOST_CHECK(!mem.valid())
const_iterator begin() const
ValHeader write(const uint32_t &aValue) const
Write a single, unmasked word to a register.
A heirarchical node for navigating heirarchical firmwares.
BOOST_CHECK_EQUAL(hw.getNode("SUBSYSTEM1.SUBMODULE.REG").getAddress(), hw.getNode("SUBSYSTEM1").getNode("SUBMODULE").getNode("REG").getAddress())
const Node & getNode(const std::string &aId) const
Retrieve the Node given by a full-stop delimeted name path relative, to the current node...
BOOST_CHECK_NO_THROW(hw.getNode("REG").writeBlock(xx))
std::vector< std::string > getNodes() const
Return all node IDs known to this HwInterface.
ValWord< uint32_t > read() const
Read a single, unmasked, unsigned word.
const Node & getNode() const
Ping the target for this client.