File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,8 +71,20 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
7171 target_precompile_headers (axi_dma_demo_cpp PRIVATE example/demo_cpp/inc/BoostPCH.hpp )
7272endif ()
7373
74- # cpp example tests
7574if (BUILD_TESTING)
75+ # library tests
76+ file (GLOB LIB_TESTS "tests/*.cpp" )
77+
78+ foreach (TEST_FILE ${LIB_TESTS} )
79+ get_filename_component (test_basename ${TEST_FILE} NAME_WE )
80+
81+ add_executable (${test_basename} ${TEST_FILE} )
82+ target_include_directories (${test_basename} PRIVATE inc )
83+ target_link_libraries (${test_basename} LINK_PUBLIC Boost::unit_test_framework Boost::log Boost::program_options Boost::dynamic_linking udmaio )
84+ add_test (NAME ${test_basename} COMMAND ${test_basename} )
85+ endforeach ()
86+
87+ # cpp example tests
7688 file (GLOB TEST_SOURCES "example/demo_cpp/src/*.cpp" )
7789 file (GLOB EXAMPLE_MAIN "example/demo_cpp/src/axi_dma_demo.cpp" )
7890 list (REMOVE_ITEM TEST_SOURCES ${EXAMPLE_MAIN} )
Original file line number Diff line number Diff line change 1+ #include < memory>
2+
3+ #include " udmaio/UioConfig.hpp"
4+ #define BOOST_TEST_MODULE UioMemSgdma
5+
6+ #define BOOST_TEST_DYN_LINK
7+
8+ #include " udmaio/FpgaMemBufferOverAxi.hpp"
9+ #include " udmaio/HwAccessor.hpp"
10+ #include " udmaio/UioMemSgdma.hpp"
11+ #include < boost/test/unit_test.hpp>
12+
13+ using namespace udmaio ;
14+
15+ struct Fx {
16+ HwAccessorPtr hw_sgdma;
17+ UioMemSgdma sgdma;
18+
19+ HwAccessorPtr hw_fpga_mem;
20+ FpgaMemBufferOverAxi fpga_mem;
21+
22+ Fx ()
23+ : hw_sgdma{std::make_shared<udmaio::HwAccessorMock>(16 * 1024 )}
24+ , sgdma{UioDeviceLocation{hw_sgdma}}
25+ , hw_fpga_mem{std::make_shared<HwAccessorMock>(16 * 1024 )}
26+ , fpga_mem{UioDeviceLocation{hw_fpga_mem}} {}
27+ ~Fx () {}
28+
29+ static constexpr size_t num_bufs = 8 , buf_size = 1024 ;
30+ };
31+
32+ BOOST_FIXTURE_TEST_CASE (init_buffers, Fx) {
33+ sgdma.init_buffers (fpga_mem, num_bufs, buf_size);
34+ BOOST_CHECK_MESSAGE (sgdma.get_first_desc_addr () == hw_sgdma->get_phys_region ().addr ,
35+ " Descriptor address mismatch" );
36+
37+ sgdma.print_descs ();
38+ }
39+
40+ BOOST_FIXTURE_TEST_CASE (foobar, Fx) {}
You can’t perform that action at this time.
0 commit comments