Skip to content

Commit bcadbe8

Browse files
authored
Merge pull request #639 from analogdevicesinc/tfcollins/jesd-testing
2 parents 56230aa + ff37f1d commit bcadbe8

File tree

6 files changed

+130
-0
lines changed

6 files changed

+130
-0
lines changed

doc/source/dev/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ pyadi-iio has a large set of parameterizable fixtures for testing different devi
9494
test_attr
9595
test_dma
9696
test_generics
97+
test_jesd
9798

9899

99100
Set Up Isolated Environment

doc/source/dev/test_jesd.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
JESD204 Tests
2+
=================
3+
4+
Functions used by test fixtures for evaluating JESD204 link states.
5+
6+
.. automodule:: test.jesd_tests
7+
:members:

test/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def pytest_configure(config):
3030
)
3131
config.addinivalue_line("markers", "lvds_test: mark tests for LVDS")
3232
config.addinivalue_line("markers", "cmos_test: mark tests for CMOS")
33+
config.addinivalue_line("markers", "jesd204: mark tests for JESD204")
3334

3435

3536
def pytest_collection_modifyitems(items):

test/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from test.generics import iio_attribute_single_value
1616
from test.globals import *
1717
from test.html import pytest_html_report_title, pytest_runtest_makereport
18+
from test.jesd_tests import *
1819

1920
import numpy as np
2021
import pytest
@@ -302,3 +303,17 @@ def test_attribute_check_range_singleval_with_depends(request):
302303
@pytest.fixture()
303304
def test_attribute_single_value_boolean_readonly(request):
304305
yield attribute_single_value_boolean_readonly
306+
307+
308+
#########################################
309+
# JESD204 Fixtures
310+
311+
312+
@pytest.fixture()
313+
def test_verify_links(request):
314+
yield verify_links
315+
316+
317+
@pytest.fixture()
318+
def test_verify_links_errors_stable(request):
319+
yield verify_links_errors_stable

test/jesd_tests.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
"""Tests for JESD204 interfaces"""
2+
3+
from pprint import pprint
4+
from time import sleep
5+
6+
import pytest
7+
8+
import adi
9+
10+
try:
11+
import adi.jesd
12+
13+
skip_jesd = False
14+
except:
15+
skip_jesd = True
16+
17+
18+
def verify_links(iio_uri: str, classname: str):
19+
"""Verify that the links are up in DATA mode
20+
21+
Args:
22+
iio_uri (str): URI of the device
23+
classname (str): Class name of the device
24+
25+
Exceptions:
26+
AssertionError: If the link is not in DATA mode
27+
"""
28+
if skip_jesd:
29+
pytest.skip("JESD204 interface support not available")
30+
31+
dev = eval(classname)(uri=iio_uri, jesd_monitor=True)
32+
status = dev._jesd.get_all_link_statuses()
33+
pprint(status)
34+
35+
# Check that all links are in DATA mode
36+
for driver in status:
37+
for lane in status[driver]:
38+
print(f"Checking {driver}/{lane}")
39+
data = status[driver][lane]
40+
pprint(data)
41+
assert (
42+
data["CGS state"] == "DATA"
43+
), f"Link {driver}/{lane} is not in DATA mode"
44+
45+
46+
def verify_links_errors_stable(iio_uri: str, classname: str):
47+
"""Verify that the links are stable and not increasing errors
48+
49+
Args:
50+
iio_uri (str): URI of the device
51+
classname (str): Class name of the
52+
53+
Exceptions:
54+
AssertionError: If the link errors have increased
55+
AssertionError: If the link is not in DATA mode
56+
"""
57+
if skip_jesd:
58+
pytest.skip("JESD204 interface support not available")
59+
60+
dev = eval(classname)(uri=iio_uri, jesd_monitor=True)
61+
62+
# Get error count on all lanes and links
63+
def get_link_errors(status):
64+
links = {}
65+
for driver in status:
66+
for lane in status[driver]:
67+
print(f"Checking {driver}/{lane}")
68+
data = status[driver][lane]
69+
links[f"{driver}/{lane}"] = int(data["Errors"])
70+
return links
71+
72+
status = dev._jesd.get_all_link_statuses()
73+
pre_link_errors = get_link_errors(status)
74+
pprint(pre_link_errors)
75+
76+
N = 5
77+
print(f"Waiting {N} seconds")
78+
sleep(N)
79+
80+
status = dev._jesd.get_all_link_statuses()
81+
post_link_errors = get_link_errors(status)
82+
pprint(post_link_errors)
83+
84+
# Check that all links have not increased in errors
85+
for link in pre_link_errors:
86+
assert (
87+
pre_link_errors[link] == post_link_errors[link]
88+
), f"Link {link} has increased in errors"

test/test_adrv9009_zu11eg.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,21 @@ def test_adrv9009_zu11eg_buffer_size(iio_uri, rx_buffer_size, rx_enabled_channel
334334
else:
335335
for chan in data:
336336
assert len(chan) == rx_buffer_size
337+
338+
339+
#########################################
340+
# JESD204 Tests
341+
@pytest.mark.jesd204
342+
@pytest.mark.iio_hardware(hardware)
343+
@pytest.mark.parametrize("classname", [(classname)])
344+
def test_adrv9009_zu11eg_verify_links(test_verify_links, iio_uri, classname):
345+
test_verify_links(iio_uri, classname)
346+
347+
348+
@pytest.mark.jesd204
349+
@pytest.mark.iio_hardware(hardware)
350+
@pytest.mark.parametrize("classname", [(classname)])
351+
def test_adrv9009_zu11eg_verify_links_errors_stable(
352+
test_verify_links_errors_stable, iio_uri, classname
353+
):
354+
test_verify_links_errors_stable(iio_uri, classname)

0 commit comments

Comments
 (0)