Skip to content

Commit

Permalink
Merge pull request #639 from analogdevicesinc/tfcollins/jesd-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tfcollins authored Feb 17, 2025
2 parents 56230aa + ff37f1d commit bcadbe8
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/dev/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pyadi-iio has a large set of parameterizable fixtures for testing different devi
test_attr
test_dma
test_generics
test_jesd


Set Up Isolated Environment
Expand Down
7 changes: 7 additions & 0 deletions doc/source/dev/test_jesd.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
JESD204 Tests
=================

Functions used by test fixtures for evaluating JESD204 link states.

.. automodule:: test.jesd_tests
:members:
1 change: 1 addition & 0 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def pytest_configure(config):
)
config.addinivalue_line("markers", "lvds_test: mark tests for LVDS")
config.addinivalue_line("markers", "cmos_test: mark tests for CMOS")
config.addinivalue_line("markers", "jesd204: mark tests for JESD204")


def pytest_collection_modifyitems(items):
Expand Down
15 changes: 15 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from test.generics import iio_attribute_single_value
from test.globals import *
from test.html import pytest_html_report_title, pytest_runtest_makereport
from test.jesd_tests import *

import numpy as np
import pytest
Expand Down Expand Up @@ -302,3 +303,17 @@ def test_attribute_check_range_singleval_with_depends(request):
@pytest.fixture()
def test_attribute_single_value_boolean_readonly(request):
yield attribute_single_value_boolean_readonly


#########################################
# JESD204 Fixtures


@pytest.fixture()
def test_verify_links(request):
yield verify_links


@pytest.fixture()
def test_verify_links_errors_stable(request):
yield verify_links_errors_stable
88 changes: 88 additions & 0 deletions test/jesd_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
"""Tests for JESD204 interfaces"""

from pprint import pprint
from time import sleep

import pytest

import adi

try:
import adi.jesd

skip_jesd = False
except:
skip_jesd = True


def verify_links(iio_uri: str, classname: str):
"""Verify that the links are up in DATA mode
Args:
iio_uri (str): URI of the device
classname (str): Class name of the device
Exceptions:
AssertionError: If the link is not in DATA mode
"""
if skip_jesd:
pytest.skip("JESD204 interface support not available")

dev = eval(classname)(uri=iio_uri, jesd_monitor=True)
status = dev._jesd.get_all_link_statuses()
pprint(status)

# Check that all links are in DATA mode
for driver in status:
for lane in status[driver]:
print(f"Checking {driver}/{lane}")
data = status[driver][lane]
pprint(data)
assert (
data["CGS state"] == "DATA"
), f"Link {driver}/{lane} is not in DATA mode"


def verify_links_errors_stable(iio_uri: str, classname: str):
"""Verify that the links are stable and not increasing errors
Args:
iio_uri (str): URI of the device
classname (str): Class name of the
Exceptions:
AssertionError: If the link errors have increased
AssertionError: If the link is not in DATA mode
"""
if skip_jesd:
pytest.skip("JESD204 interface support not available")

dev = eval(classname)(uri=iio_uri, jesd_monitor=True)

# Get error count on all lanes and links
def get_link_errors(status):
links = {}
for driver in status:
for lane in status[driver]:
print(f"Checking {driver}/{lane}")
data = status[driver][lane]
links[f"{driver}/{lane}"] = int(data["Errors"])
return links

status = dev._jesd.get_all_link_statuses()
pre_link_errors = get_link_errors(status)
pprint(pre_link_errors)

N = 5
print(f"Waiting {N} seconds")
sleep(N)

status = dev._jesd.get_all_link_statuses()
post_link_errors = get_link_errors(status)
pprint(post_link_errors)

# Check that all links have not increased in errors
for link in pre_link_errors:
assert (
pre_link_errors[link] == post_link_errors[link]
), f"Link {link} has increased in errors"
18 changes: 18 additions & 0 deletions test/test_adrv9009_zu11eg.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,21 @@ def test_adrv9009_zu11eg_buffer_size(iio_uri, rx_buffer_size, rx_enabled_channel
else:
for chan in data:
assert len(chan) == rx_buffer_size


#########################################
# JESD204 Tests
@pytest.mark.jesd204
@pytest.mark.iio_hardware(hardware)
@pytest.mark.parametrize("classname", [(classname)])
def test_adrv9009_zu11eg_verify_links(test_verify_links, iio_uri, classname):
test_verify_links(iio_uri, classname)


@pytest.mark.jesd204
@pytest.mark.iio_hardware(hardware)
@pytest.mark.parametrize("classname", [(classname)])
def test_adrv9009_zu11eg_verify_links_errors_stable(
test_verify_links_errors_stable, iio_uri, classname
):
test_verify_links_errors_stable(iio_uri, classname)

0 comments on commit bcadbe8

Please sign in to comment.