#include "uhal/uhal.hpp"#include "uhal/tests/definitions.hpp"#include "uhal/tests/fixtures.hpp"#include "uhal/tests/tools.hpp"#include <boost/test/unit_test.hpp>#include <vector>#include <iostream>#include <cstdlib>#include <typeinfo>Go to the source code of this file.
Namespaces | |
| uhal | |
| uhal::tests | |
Macros | |
| #define | N_4B 1 |
| #define | N_1kB 1024/4 |
| #define | N_1MB 1024*1024/4 |
| #define | N_10MB 10*1024*1024/4 |
| #define | N_200MB 100*1024*1024/4 |
Functions | |
| std::vector< size_t > | uhal::tests::getBlockUnitTestDepths () |
| uhal::tests::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 | |
| lDepths | uhal::tests::push_back (N_200MB) |
| uhal::tests::for (size_t i=0;i< lDepths.size();i++) | |
| uhal::tests::UHAL_TESTS_DEFINE_CLIENT_TEST_CASES (BlockReadWriteTestSuite, block_offset_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);std::vector< uint32_t > yy;yy.reserve(N);for(size_t i=0;i!=N;++i) { xx.push_back(static_cast< uint32_t >(rand()));yy.push_back(static_cast< uint32_t >(rand()));} hw.getNode("LARGE_MEM").writeBlockOffset(xx, 0);ValVector< uint32_t > mem=hw.getNode("LARGE_MEM").readBlockOffset(N, 0);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);hw.getNode("LARGE_MEM").writeBlockOffset(yy, N);ValVector< uint32_t > mem2=hw.getNode("LARGE_MEM").readBlockOffset(N, N);BOOST_CHECK(!mem2.valid());BOOST_CHECK_EQUAL(mem2.size(), N);if(N > 0) { BOOST_CHECK_THROW(mem2.at(0), uhal::exception::NonValidatedMemory);} BOOST_CHECK_THROW(mem2.value(), uhal::exception::NonValidatedMemory);BOOST_CHECK_NO_THROW(hw.dispatch());BOOST_CHECK(mem.valid());BOOST_CHECK_EQUAL(mem.size(), N);BOOST_CHECK(mem2.valid());BOOST_CHECK_EQUAL(mem2.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);} j=yy.begin();for(ValVector< uint32_t >::const_iterator i(mem2.begin());i!=mem2.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 | |
| xx | uhal::tests::resize (N_4B) |
| uhal::tests::BOOST_CHECK_NO_THROW (hw.getNode("REG").writeBlock(xx)) | |
| uhal::tests::BOOST_CHECK_NO_THROW (ValVector< uint32_t > mem=hw.getNode("REG").readBlock(N_4B)) | |
| uhal::tests::BOOST_CHECK_THROW (hw.getNode("REG").writeBlockOffset(xx, 0), uhal::exception::BulkTransferOffsetRequestedForSingleRegister) | |
| uhal::tests::BOOST_CHECK_THROW (ValVector< uint32_t > mem=hw.getNode("REG").readBlockOffset(N_1kB, 0), uhal::exception::BulkTransferOffsetRequestedForSingleRegister) | |
| xx | uhal::tests::resize (N_1kB) |
| uhal::tests::BOOST_CHECK_THROW (hw.getNode("REG").writeBlock(xx), uhal::exception::BulkTransferOnSingleRegister) | |
| uhal::tests::BOOST_CHECK_THROW (ValVector< uint32_t > mem=hw.getNode("REG").readBlock(N_1kB), uhal::exception::BulkTransferOnSingleRegister) | |
| uhal::tests::BOOST_CHECK_THROW (hw.getNode("FIFO").writeBlockOffset(xx, 1), uhal::exception::BulkTransferOffsetRequestedForFifo) | |
| uhal::tests::BOOST_CHECK_THROW (ValVector< uint32_t > mem=hw.getNode("FIFO").readBlockOffset(N_1kB, 1), uhal::exception::BulkTransferOffsetRequestedForFifo) | |
| uhal::tests::UHAL_TESTS_DEFINE_CLIENT_TEST_CASES (BlockReadWriteTestSuite, block_bigger_than_size_attribute, MinimalFixture, { HwInterface hw=getHwInterface();std::vector< uint32_t > xx;xx.resize(N_1MB);BOOST_CHECK_THROW(hw.getNode("SMALL_MEM").writeBlock(xx), uhal::exception::BulkTransferRequestedTooLarge);BOOST_CHECK_THROW(ValVector< uint32_t > mem=hw.getNode("SMALL_MEM").readBlock(N_1MB), uhal::exception::BulkTransferRequestedTooLarge);}) UHAL_TESTS_DEFINE_CLIENT_TEST_CASES(BlockReadWriteTestSuite | |
| uhal::tests::BOOST_CHECK_THROW (hw.getNode("SMALL_MEM").writeBlockOffset(xx, 256), uhal::exception::BulkTransferRequestedTooLarge) | |
| uhal::tests::BOOST_CHECK_THROW (ValVector< uint32_t > mem=hw.getNode("SMALL_MEM").readBlockOffset(N_4B, 256), uhal::exception::BulkTransferRequestedTooLarge) | |
| uhal::tests::BOOST_CHECK_THROW (hw.getNode("SMALL_MEM").writeBlockOffset(xx, 1), uhal::exception::BulkTransferRequestedTooLarge) | |
| #define N_10MB 10*1024*1024/4 |
Definition at line 54 of file test_block.cpp.
Referenced by uhal::tests::for(), and uhal::tests::getBlockUnitTestDepths().
| #define N_1kB 1024/4 |
Definition at line 52 of file test_block.cpp.
Referenced by uhal::tests::getBlockUnitTestDepths().
| #define N_1MB 1024*1024/4 |
Definition at line 53 of file test_block.cpp.
Referenced by uhal::tests::getBlockUnitTestDepths().
| #define N_200MB 100*1024*1024/4 |
Definition at line 55 of file test_block.cpp.
| #define N_4B 1 |
Definition at line 51 of file test_block.cpp.
Referenced by uhal::tests::getBlockUnitTestDepths().
1.8.13