conftest.py 747 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11
"""
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: 2020 CERN
"""

import pytest
from PySPEC import PySPEC


@pytest.fixture(scope="function")
def spec():
12 13
    spec_dev = PySPEC(pytest.pci_id)
    yield spec_dev
14 15 16 17

def pytest_addoption(parser):
    parser.addoption("--pci-id",
                     required=True, help="SPEC PCI Identifier")
18
    parser.addoption("--bitstream",
19
                     default=None, help="SPEC bitstream to be tested")
20 21 22

def pytest_configure(config):
    pytest.pci_id = config.getoption("--pci-id")
23 24
    pytest.cfg_bitstream = config.getoption("--bitstream")

25 26 27 28
    if pytest.cfg_bitstream is not None:
        spec = PySPEC(pytest.pci_id)
        spec.program_fpga(pytest.cfg_bitstream)
        del spec