|
μHAL (v2.7.9)
Part of the IPbus software repository
|
Go to the documentation of this file.
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)
58 #define TIMEOUT_MULTIPLIER 50
65 void job_multiple (
const std::string& connection,
const std::string&
id,
const size_t timeout )
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() ) );
102 std::vector<boost::thread*> jobs;
107 jobs.push_back (
new boost::thread (
job_multiple, connectionFileURI, deviceId, timeout ) );
127 uint32_t
x =
static_cast<uint32_t
> ( rand() );
130 std::vector<uint32_t>
xx;
132 for (
size_t i=0; i!=
N_SIZE; ++i )
134 xx.push_back (
static_cast<uint32_t
> ( rand() ) );
153 std::vector<boost::thread*> jobs;
157 jobs.push_back (
new boost::thread ( job_single,
hw ) );
173 uint32_t
x =
static_cast<uint32_t
> ( rand() );
176 std::vector<uint32_t>
xx;
178 for (
size_t i=0; i!=
N_SIZE; ++i )
180 xx.push_back (
static_cast<uint32_t
> ( 0xDEADBEEF ) );
197 HwInterface
hw = getHwInterface();
198 std::vector<boost::thread*> jobs;
202 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...
HwInterface getDevice(const std::string &aId)
Retrieves protocol, host, and port from the connection file to create an IPbus Client Retrieves the a...
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.
#define TIMEOUT_MULTIPLIER
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())
void setTimeoutPeriod(const uint32_t &aTimeoutPeriod)
A method to modify the timeout period for any pending or future transactions.
void dispatch()
Make the IPbus client issue a dispatch.
void job_multiple(const std::string &connection, const std::string &id, const size_t timeout)
void log(FatalLevel &aFatal, const T0 &aArg0)
Function to add a log entry at Fatal level.
_Integer< T, IntFmt<> > Integer(const T &aT)
Forward declare a function which creates an instance of the ultra-lightweight wrapper from an integer...
std::vector< uint32_t > xx
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.
A class to open and manage XML connection files and wrap up the interfaces to the NodeTreeBuilder and...
std::size_t size() const
Return the size of the underlying memory.
BOOST_CHECK_NO_THROW(hw.getNode("REG").writeBlock(xx))
ValVector< uint32_t > mem
bool valid()
Return whether the Validated memory is marked as valid.
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.