Skip to content

Commit

Permalink
Merge pull request #536 from jpineda3/ad9081-test-fixes
Browse files Browse the repository at this point in the history
test: ad9081: Scale channel param
  • Loading branch information
tfcollins authored Mar 8, 2024
2 parents b5da485 + ae819ad commit 9940df5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/test_ad9081.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
classname = "adi.ad9081"


def is_channel(channel, iio_uri):
import adi

dev = adi.ad9081(uri=iio_uri)
channels = list(
set([int("".join(filter(str.isdigit, s))) for s in dev._tx_channel_names])
)
return channel in channels


def scale_field(param_set, iio_uri):
# Scale fields to match number of channels
import adi
Expand Down Expand Up @@ -97,6 +107,8 @@ def test_ad9081_attr(
@pytest.mark.parametrize("classname", [(classname)])
@pytest.mark.parametrize("channel", [0, 1, 2, 3])
def test_ad9081_rx_data(test_dma_rx, iio_uri, classname, channel):
if not is_channel(channel, iio_uri):
pytest.skip("Skipping test: Channel " + str(channel) + "not available.")
test_dma_rx(iio_uri, classname, channel)


Expand All @@ -105,6 +117,8 @@ def test_ad9081_rx_data(test_dma_rx, iio_uri, classname, channel):
@pytest.mark.parametrize("classname", [(classname)])
@pytest.mark.parametrize("channel", [0, 1, 2, 3])
def test_ad9081_tx_data(test_dma_tx, iio_uri, classname, channel):
if not is_channel(channel, iio_uri):
pytest.skip("Skipping test: Channel " + str(channel) + "not available.")
test_dma_tx(iio_uri, classname, channel)


Expand Down Expand Up @@ -135,6 +149,8 @@ def test_ad9081_tx_data(test_dma_tx, iio_uri, classname, channel):
def test_ad9081_cyclic_buffers(
test_cyclic_buffer, iio_uri, classname, channel, param_set
):
if not is_channel(channel, iio_uri):
pytest.skip("Skipping test: Channel " + str(channel) + "not available.")
param_set = scale_field(param_set, iio_uri)
test_cyclic_buffer(iio_uri, classname, channel, param_set)

Expand Down Expand Up @@ -164,6 +180,8 @@ def test_ad9081_cyclic_buffers(
def test_ad9081_cyclic_buffers_exception(
test_cyclic_buffer_exception, iio_uri, classname, channel, param_set
):
if not is_channel(channel, iio_uri):
pytest.skip("Skipping test: Channel " + str(channel) + "not available.")
param_set = scale_field(param_set, iio_uri)
test_cyclic_buffer_exception(iio_uri, classname, channel, param_set)

Expand Down

0 comments on commit 9940df5

Please sign in to comment.