Skip to content

Commit

Permalink
Make test_s6_glitch.py run again.
Browse files Browse the repository at this point in the history
WIP as current usefulness is low.
  • Loading branch information
jpcrypt committed Apr 16, 2024
1 parent d33da82 commit f20c40a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ def pytest_addoption(parser):
parser.addoption("--swo_trace", action="store_true", default=False, help="Enable trace tests.")
parser.addoption("--xadc", action="store_true", default=False, help="Report XADC temp and status after each test")
parser.addoption("--log", action="store_true", default=False, help="Log XADC stats to file")
parser.addoption("--loose", action="store_true", default=False, help="Loosen test margins for test_s6_glitch.py")
parser.addoption("--target", action="store", default="Lite", help="Target name for test_s6_glitch.py (Lite/Pro)")

@pytest.fixture
def fulltest(request):
Expand All @@ -28,3 +30,11 @@ def xadc(request):
def log(request):
return int(request.config.getoption("--log"))

@pytest.fixture
def loose(request):
return int(request.config.getoption("--loose"))

@pytest.fixture
def target(request):
return request.config.getoption("--target")

28 changes: 10 additions & 18 deletions tests/test_s6_glitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,21 @@
"""

print('\n\n\n\n**************************************************************************************')
print('* IMPORTANT NOTE: *')
print('* *')
print('* IMPORTANT NOTE 1: *')
print('* This script is intended for basic regression testing of CW-lite/pro glitching *')
print('* during development. If you are having issues connecting to your CW-lite or target *')
print('* device, running this script is unlikely to provide you with useful information. *')
print('* Instead, seek assistance on forum.newae.com or discord by providing details of *')
print('* your setup (including the target), and the full error log from your Jupyter *')
print('* notebook. *')
print('* *')
print('* IMPORTANT NOTE 2: *')
print('* Does not run very reliably! Working on it... *')
print('* *')
print('**************************************************************************************\n\n')


@pytest.fixture()
def target(pytestconfig):
return pytestconfig.getoption("target")

@pytest.fixture()
def reps(pytestconfig):
return int(pytestconfig.getoption("reps"))

@pytest.fixture()
def loose(pytestconfig):
return int(pytestconfig.getoption("loose"))



hscope = None
scope = None
Expand All @@ -58,7 +50,7 @@ def test_connect(target):
try:
scope = cw.scope(name=target)
except:
pytest.exit("Couldn't connect to target scope")
pytest.exit("Couldn't connect to target scope (%s)" % target)
if not hscope.LA.present:
pytest.exit('Cannot test glitch without internal logic analyzer. Rebuild Husky FPGA to test.')
# setup Husky LA:
Expand Down Expand Up @@ -289,9 +281,9 @@ def test_coarse_offset(target, reps, loose, positive, width, oversamp, desc):

# 4. verify period of each pulse:
partitions = np.where(glitch[1:] != glitch[:-1])[0]
for i in range(1, len(partitions)-2, 2):
period = partitions[i+2] - partitions[i]
if abs(period - 50) > period_margin:
for j in range(1, len(partitions)-2, 2):
period = partitions[j+2] - partitions[j]
if abs(period - oversamp) > period_margin:
errors += "Offset %f: Glitch period %d exceeds expected period margin (%d)" % (actual_offsets[i], period, period_margin)

assert errors == '', "Errors seen for rep %d:\n%s" % (rep, errors)
Expand Down

0 comments on commit f20c40a

Please sign in to comment.