From 2967fb8ac9b5b213f514ddd83b585fa084cf5675 Mon Sep 17 00:00:00 2001 From: Niklas Eiling Date: Tue, 12 Dec 2023 11:40:12 +0100 Subject: [PATCH] fix fpga.cpp unit test failing due to changed DeviceList interface Signed-off-by: Niklas Eiling --- fpga/include/villas/fpga/utils.hpp | 3 ++- fpga/lib/pcie_card.cpp | 2 +- fpga/tests/unit/fpga.cpp | 23 ++++++++++++++--------- fpga/tests/unit/global.hpp | 4 ++-- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/fpga/include/villas/fpga/utils.hpp b/fpga/include/villas/fpga/utils.hpp index 649089a21..6de366f1c 100644 --- a/fpga/include/villas/fpga/utils.hpp +++ b/fpga/include/villas/fpga/utils.hpp @@ -7,8 +7,9 @@ #pragma once #include -#include #include +#include +#include namespace villas { namespace fpga { diff --git a/fpga/lib/pcie_card.cpp b/fpga/lib/pcie_card.cpp index f86852ac4..fa24a1de0 100644 --- a/fpga/lib/pcie_card.cpp +++ b/fpga/lib/pcie_card.cpp @@ -28,7 +28,7 @@ static const kernel::pci::Device defaultFilter((kernel::pci::Id(FPGA_PCI_VID_XIL std::shared_ptr PCIeCardFactory::make(json_t *json_card, std::string card_name, std::shared_ptr vc, - const std::filesystem::path &searchPath) { + const std::filesystem::path &searchPath) { auto logger = getStaticLogger(); json_t *json_ips = nullptr; diff --git a/fpga/tests/unit/fpga.cpp b/fpga/tests/unit/fpga.cpp index 909e69ab8..e3c9e6bf1 100644 --- a/fpga/tests/unit/fpga.cpp +++ b/fpga/tests/unit/fpga.cpp @@ -2,6 +2,8 @@ * * Author: Steffen Vogel * SPDX-FileCopyrightText: 2018 Steffen Vogel + * Author: Niklas Eiling + * SPDX-FileCopyrightText: 2023 Niklas Eiling * SPDX-License-Identifier: Apache-2.0 */ @@ -9,8 +11,8 @@ #include #include +#include #include -#include #include "global.hpp" @@ -25,7 +27,7 @@ using namespace villas; -static std::shared_ptr pciDevices; +static kernel::pci::DeviceList *pciDevices; FpgaState state; @@ -39,12 +41,12 @@ static void init() plugin::registry->dump(); - pciDevices = std::make_shared(); + pciDevices = kernel::pci::DeviceList::getInstance(); - auto vfioContainer = std::make_shared(); + auto vfioContainer = std::make_shared(); - // Parse FPGA configuration - char *fn = getenv("TEST_CONFIG"); + // Parse FPGA configuration + char *fn = getenv("TEST_CONFIG"); f = fopen(fn ? fn : TEST_CONFIG, "r"); cr_assert_not_null(f, "Cannot open config file"); @@ -62,11 +64,14 @@ static void init() cr_assert_not_null(fpgaCardFactory, "No plugin for FPGA card found"); // Create all FPGA card instances using the corresponding plugin - state.cards = fpgaCardFactory->make(fpgas, pciDevices, vfioContainer); + auto configDir = std::filesystem::path(fn).parent_path(); + auto cards = std::list>(); + fpga::createCards(json, cards, configDir); + state.cards = cards; - cr_assert(state.cards.size() != 0, "No FPGA cards found!"); + cr_assert(state.cards.size() != 0, "No FPGA cards found!"); - json_decref(json); + json_decref(json); } static void fini() diff --git a/fpga/tests/unit/global.hpp b/fpga/tests/unit/global.hpp index 202f49fe2..1b0ebd7ac 100644 --- a/fpga/tests/unit/global.hpp +++ b/fpga/tests/unit/global.hpp @@ -9,12 +9,12 @@ #include -#include +#include class FpgaState { public: // List of all available FPGA cards, only first will be tested at the moment - std::list> cards; + std::list> cards; }; // Global state to be shared by unittests