39 #include "uhal/log/log.hpp" 41 #include <boost/thread.hpp> 42 #include <boost/date_time/posix_time/posix_time.hpp> 43 #include <boost/thread/mutex.hpp> 44 #include <boost/thread/condition_variable.hpp> 45 #include <boost/test/unit_test.hpp> 56 #define N_ITERATIONS 5 57 #define N_SIZE uint32_t(10*1024/4) 65 void job_multiple (
const std::string& connection,
const std::string&
id )
76 uint32_t
x =
static_cast<uint32_t
> ( rand() );
79 std::vector<uint32_t>
xx;
81 for (
size_t i=0; i!=
N_SIZE; ++i )
83 xx.push_back ( static_cast<uint32_t> ( rand() ) );
104 std::vector<boost::thread*> jobs;
109 jobs.push_back (
new boost::thread (
job_multiple, connectionFileURI, deviceId ) );
124 std::cout <<
" ** Skipping multiple HwInterface test for PCIe **" << std::endl;
132 uint32_t
x = static_cast<uint32_t> ( rand() );
135 std::vector<uint32_t>
xx;
137 for (
size_t i=0; i!=
N_SIZE; ++i )
139 xx.push_back ( static_cast<uint32_t> ( rand() ) );
158 std::vector<boost::thread*> jobs;
162 jobs.push_back (
new boost::thread ( job_single,hw ) );
178 uint32_t
x = static_cast<uint32_t> ( rand() );
181 std::vector<uint32_t>
xx;
183 for (
size_t i=0; i!=
N_SIZE; ++i )
185 xx.push_back ( static_cast<uint32_t> ( 0xDEADBEEF ) );
203 std::vector<boost::thread*> jobs;
207 jobs.push_back (
new boost::thread ( job_single_copied,hw ) );
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
void dispatch()
Make the IPbus client issue a dispatch.
HwInterface getDevice(const std::string &aId)
Retrieves protocol, host, and port from the connection file to create an IPbus Client Retrieves the a...
BOOST_CHECK(!mem.valid())
void job_multiple(const std::string &connection, const std::string &id)
ValHeader write(const uint32_t &aValue) const
Write a single, unmasked word to a register.
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.
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))
bool valid()
Return whether the Validated memory is marked as valid.
std::vector< uint32_t > xx
void setTimeoutPeriod(const uint32_t &aTimeoutPeriod)
A method to modify the timeout period for any pending or future transactions.
std::size_t size() const
Return the size of the underlying memory.
ValVector< uint32_t > mem
ValWord< uint32_t > read() const
Read a single, unmasked, unsigned word.
const Node & getNode() const
Ping the target for this client.
A class to open and manage XML connection files and wrap up the interfaces to the NodeTreeBuilder and...
_Integer< T, IntFmt<> > Integer(const T &aT)
Forward declare a function which creates an instance of the ultra-lightweight wrapper from an integer...
ValHeader writeBlock(const std::vector< uint32_t > &aValues) const
Write a block of data to a block of registers or a block-write port.