Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit ac95922

Browse files
committed
fix fpga.cpp unit test failing due to changed DeviceList interface
Signed-off-by: Niklas Eiling <[email protected]>
1 parent 2834a45 commit ac95922

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

include/villas/fpga/utils.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
#pragma once
88

99
#include <string>
10-
#include <villas/fpga/pcie_card.hpp>
1110
#include <villas/fpga/ips/aurora_xilinx.hpp>
11+
#include <villas/fpga/ips/dma.hpp>
12+
#include <villas/fpga/pcie_card.hpp>
1213

1314
namespace villas {
1415
namespace fpga {

lib/pcie_card.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static const kernel::pci::Device defaultFilter((kernel::pci::Id(FPGA_PCI_VID_XIL
2828
std::shared_ptr<PCIeCard>
2929
PCIeCardFactory::make(json_t *json_card, std::string card_name,
3030
std::shared_ptr<kernel::vfio::Container> vc,
31-
const std::filesystem::path &searchPath) {
31+
const std::filesystem::path &searchPath) {
3232
auto logger = getStaticLogger();
3333

3434
json_t *json_ips = nullptr;

tests/unit/fpga.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
*
33
* Author: Steffen Vogel <[email protected]>
44
* SPDX-FileCopyrightText: 2018 Steffen Vogel <[email protected]>
5+
* Author: Niklas Eiling <[email protected]>
6+
* SPDX-FileCopyrightText: 2023 Niklas Eiling <[email protected]>
57
* SPDX-License-Identifier: Apache-2.0
68
*/
79

810
#include <criterion/criterion.h>
911

1012
#include <villas/fpga/core.hpp>
1113
#include <villas/fpga/pcie_card.hpp>
14+
#include <villas/fpga/utils.hpp>
1215
#include <villas/fpga/vlnv.hpp>
13-
#include <villas/utils.hpp>
1416

1517
#include "global.hpp"
1618

@@ -25,7 +27,7 @@
2527

2628
using namespace villas;
2729

28-
static std::shared_ptr<kernel::pci::DeviceList> pciDevices;
30+
static kernel::pci::DeviceList *pciDevices;
2931

3032
FpgaState state;
3133

@@ -39,12 +41,12 @@ static void init()
3941

4042
plugin::registry->dump();
4143

42-
pciDevices = std::make_shared<kernel::pci::DeviceList>();
44+
pciDevices = kernel::pci::DeviceList::getInstance();
4345

44-
auto vfioContainer = std::make_shared<kernel::vfio::Container>();
46+
auto vfioContainer = std::make_shared<kernel::vfio::Container>();
4547

46-
// Parse FPGA configuration
47-
char *fn = getenv("TEST_CONFIG");
48+
// Parse FPGA configuration
49+
char *fn = getenv("TEST_CONFIG");
4850
f = fopen(fn ? fn : TEST_CONFIG, "r");
4951
cr_assert_not_null(f, "Cannot open config file");
5052

@@ -62,11 +64,14 @@ static void init()
6264
cr_assert_not_null(fpgaCardFactory, "No plugin for FPGA card found");
6365

6466
// Create all FPGA card instances using the corresponding plugin
65-
state.cards = fpgaCardFactory->make(fpgas, pciDevices, vfioContainer);
67+
auto configDir = std::filesystem::path(fn).parent_path();
68+
auto cards = std::list<std::shared_ptr<fpga::Card>>();
69+
fpga::createCards(json, cards, configDir);
70+
state.cards = cards;
6671

67-
cr_assert(state.cards.size() != 0, "No FPGA cards found!");
72+
cr_assert(state.cards.size() != 0, "No FPGA cards found!");
6873

69-
json_decref(json);
74+
json_decref(json);
7075
}
7176

7277
static void fini()

tests/unit/global.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
#include <cstdlib>
1111

12-
#include <villas/fpga/pcie_card.hpp>
12+
#include <villas/fpga/card.hpp>
1313

1414
class FpgaState {
1515
public:
1616
// List of all available FPGA cards, only first will be tested at the moment
17-
std::list<std::shared_ptr<villas::fpga::PCIeCard>> cards;
17+
std::list<std::shared_ptr<villas::fpga::Card>> cards;
1818
};
1919

2020
// Global state to be shared by unittests

0 commit comments

Comments
 (0)