Skip to content

Commit

Permalink
Added new parameterized tests. (analogdevicesinc#61)
Browse files Browse the repository at this point in the history
* Initial Changes.
-Added test_daq2_p.py test_ad9680_p.py and test_pluto_p.py
-Added fmcomms2 to the check_board_other to detect fmcomms2 board in test_ad9361_p test
-Added a uri property to the BoardInterface to let the test fixtures use the uri of the previously detected matching board.

* Added parametrized tests
-Added test_daq2_p.py test_ad9680_p.py and test_pluto_p.py
-Added fmcomms2 to the check_board_other to detect fmcomms2 board in test_ad9361_p test
-Added a uri property to the BoardInterface to let the test fixtures use the uri of the previously detected matching board.
  • Loading branch information
kister-jimenez authored Feb 6, 2020
1 parent afac8a7 commit 9ef9180
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 391 deletions.
34 changes: 16 additions & 18 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
dev_checked = False
found_dev = False
found_devices = {} # type: ignore
found_uris = {} # type: ignore
URI = "ip:analog"


Expand All @@ -29,6 +30,7 @@ class BaseTestHelpers:
devicename = "pluto"
skipped_tests = [] # type: ignore
classname = "adi.ad9361"
uri = "ip:pluto.local"

def check_skip(self):
# Check if calling function is in skip list
Expand All @@ -42,6 +44,7 @@ def check_skip(self):
def check_dev(self):
# Must use globals since each test is a separate class instance
global found_devices
global found_uris
if not isinstance(self.devicename, list):
ds = [self.devicename]
else:
Expand All @@ -51,24 +54,25 @@ def check_dev(self):
for d in ds:
if d in found_devices:
found_dev = found_devices[d]
# If device was already found before, update the board interface URI
self.uri = found_uris[d]
dev_checked = True
break

if not dev_checked:
found_dev, board = iio_scanner.find_device(self.devicename)
if found_dev:
found_devices[board.name] = found_dev
global URI
URI = board.uri
found_uris[board.name] = board.uri
self.uri = board.uri
else:
for d in ds:
found_devices[d] = False

found_uris[d] = ""
return found_dev

def dev_interface(self, val, attr, tol):
global URI
sdr = eval(self.classname + "(uri='" + URI + "')")
sdr = eval(self.classname + "(uri='" + self.uri + "')")
# Check hardware
setattr(sdr, attr, val)
rval = float(getattr(sdr, attr))
Expand All @@ -87,6 +91,7 @@ class BoardInterface(BaseTestHelpers):
def __init__(self, classname, devicename):
self.classname = classname
self.devicename = devicename
self.uri = ""
self.check_skip()


Expand Down Expand Up @@ -120,8 +125,7 @@ def attribute_single_value_pow2(classname, devicename, attr, max_pow, tol):

def dma_rx(classname, devicename, channel):
bi = BoardInterface(classname, devicename)
global URI
sdr = eval(bi.classname + "(uri='" + URI + "')")
sdr = eval(bi.classname + "(uri='" + bi.uri + "')")
if sdr._num_rx_channels > 2:
if not isinstance(channel, list):
sdr.rx_enabled_channels = [channel]
Expand All @@ -145,9 +149,7 @@ def dma_rx(classname, devicename, channel):

def dma_tx(classname, devicename, channel):
bi = BoardInterface(classname, devicename)
global URI
sdr = eval(bi.classname + "(uri='" + URI + "')")

sdr = eval(bi.classname + "(uri='" + bi.uri + "')")
TXFS = 1000
N = 2 ** 15
ts = 1 / float(TXFS)
Expand All @@ -174,8 +176,7 @@ def dma_tx(classname, devicename, channel):

def dma_loopback(classname, devicename, channel):
bi = BoardInterface(classname, devicename)
global URI
sdr = eval(bi.classname + "(uri='" + URI + "')")
sdr = eval(bi.classname + "(uri='" + bi.uri + "')")
sdr.loopback = 1
sdr.tx_cyclic_buffer = True
if sdr._num_tx_channels > 2:
Expand Down Expand Up @@ -231,8 +232,7 @@ def freq_est(y, fs):
def iq_loopback(classname, devicename, channel, param_set):
bi = BoardInterface(classname, devicename)
# See if we can tone using DMAs
global URI
sdr = eval(bi.classname + "(uri='" + URI + "')")
sdr = eval(bi.classname + "(uri='" + bi.uri + "')")
# Set custom device parameters
for p in param_set.keys():
setattr(sdr, p, param_set[p])
Expand Down Expand Up @@ -285,8 +285,7 @@ def iq_loopback(classname, devicename, channel, param_set):
def t_sfdr(classname, devicename, channel, param_set, sfdr_min):
bi = BoardInterface(classname, devicename)
# See if we can tone using DMAs
global URI
sdr = eval(bi.classname + "(uri='" + URI + "')")
sdr = eval(bi.classname + "(uri='" + bi.uri + "')")
# Set custom device parameters
for p in param_set.keys():
setattr(sdr, p, param_set[p])
Expand Down Expand Up @@ -329,8 +328,7 @@ def gain_check(
):
bi = BoardInterface(classname, devicename)
# See if we can tone using DMAs
global URI
sdr = eval(bi.classname + "(uri='" + URI + "')")
sdr = eval(bi.classname + "(uri='" + bi.uri + "')")
# Set custom device parameters
for p in param_set.keys():
setattr(sdr, p, param_set[p])
Expand Down
14 changes: 12 additions & 2 deletions test/iio_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

import scapy.all as scapy

HOSTNAMES = ["analog.local", "analog.lan"]
HOSTNAMES = [
"analog.local",
"analog.lan",
"analog-zc706-daq2.local",
"analog-zc706-fmcomms2.local",
]


def check_iio(address):
Expand Down Expand Up @@ -83,6 +88,10 @@ def check_board_other(ctx):
ctx, [device("adm1177"), device("ad9361-phy"), device("cf-ad9361-lpc", 2)]
):
return "pluto"
if check_config(
ctx, [device("ad7291"), device("ad9361-phy"), device("cf-ad9361-lpc", 4)]
):
return "fmcomms2"
if check_config(ctx, [device("ad9361-phy"), device("ad9361-phy-b")]):
return "fmcomms5"
if check_config(ctx, [device("ad9361-phy"), device("cf-ad9361-lpc", 2)]):
Expand Down Expand Up @@ -147,6 +156,7 @@ def scan_all(skip_usb=False):
# FIND IP
bs = ip_scan_auto()
# bs = ip_scan("192.168.86")

if bs not in boards:
boards = boards + bs

Expand All @@ -160,7 +170,7 @@ def scan_all(skip_usb=False):
if c.name == "local":
boards.append(board(name, "local:"))
else:
boards.append(board(name, c.name))
boards.append(board(name, ctx))
return boards


Expand Down
133 changes: 0 additions & 133 deletions test/test_ad9144.py

This file was deleted.

Loading

0 comments on commit 9ef9180

Please sign in to comment.