mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-30 00:00:11 +01:00
tests/dma: add test for DMA driver
This commit is contained in:
parent
507ea77ad6
commit
e28345b992
2 changed files with 64 additions and 1 deletions
|
@ -2,7 +2,7 @@ set(SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
fpga.cpp
|
fpga.cpp
|
||||||
logging.cpp
|
logging.cpp
|
||||||
# dma.c
|
dma.cpp
|
||||||
fifo.cpp
|
fifo.cpp
|
||||||
# hls.c
|
# hls.c
|
||||||
# intc.c
|
# intc.c
|
||||||
|
|
63
fpga/tests/dma.cpp
Normal file
63
fpga/tests/dma.cpp
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#include <criterion/criterion.h>
|
||||||
|
|
||||||
|
#include <villas/log.hpp>
|
||||||
|
#include <villas/fpga/card.hpp>
|
||||||
|
#include <villas/fpga/ips/dma.hpp>
|
||||||
|
|
||||||
|
#include <villas/utils.h>
|
||||||
|
|
||||||
|
#include "global.hpp"
|
||||||
|
|
||||||
|
#include <villas/memory.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
Test(fpga, dma, .description = "DMA")
|
||||||
|
{
|
||||||
|
auto logger = loggerGetOrCreate("unittest:dma");
|
||||||
|
|
||||||
|
size_t count = 0;
|
||||||
|
for(auto& ip : state.cards.front()->ips) {
|
||||||
|
// skip non-dma IPs
|
||||||
|
if(*ip != villas::fpga::Vlnv("xilinx.com:ip:axi_dma:"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
logger->info("Testing {}", *ip);
|
||||||
|
|
||||||
|
auto dma = reinterpret_cast<villas::fpga::ip::Dma&>(*ip);
|
||||||
|
|
||||||
|
if(not dma.connectLoopback()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
count++;
|
||||||
|
|
||||||
|
if(not dma.loopbackPossible()) {
|
||||||
|
logger->info("Loopback test not possible for {}", *ip);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simple DMA can only transfer up to 4 kb due to PCIe page size burst
|
||||||
|
// limitation
|
||||||
|
size_t len = 4 * (1 << 10);
|
||||||
|
|
||||||
|
/* Allocate memory to use with DMA */
|
||||||
|
auto src = villas::HostRam::allocate<char>(len);
|
||||||
|
auto dst = villas::HostRam::allocate<char>(len);
|
||||||
|
|
||||||
|
/* Get new random data */
|
||||||
|
const size_t lenRandom = read_random(&src, len);
|
||||||
|
cr_assert(len == lenRandom, "Failed to get random data");
|
||||||
|
|
||||||
|
/* Start transfer */
|
||||||
|
cr_assert(dma.pingPong(src, dst, len), "DMA ping pong failed");
|
||||||
|
|
||||||
|
/* Compare data */
|
||||||
|
cr_assert(memcmp(&src, &dst, len) == 0, "Data not equal");
|
||||||
|
|
||||||
|
logger->info(TXT_GREEN("Passed"));
|
||||||
|
}
|
||||||
|
|
||||||
|
villas::MemoryManager::get().dump();
|
||||||
|
|
||||||
|
cr_assert(count > 0, "No Dma found");
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue