Skip to content

Commit

Permalink
Break apart tests to individual cases
Browse files Browse the repository at this point in the history
Add case for jump back (all iterated before).
  • Loading branch information
JulianSKelly committed Feb 26, 2016
1 parent c8be93a commit b959122
Showing 1 changed file with 34 additions and 26 deletions.
60 changes: 34 additions & 26 deletions fpgalib/test/test_dac.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,59 +37,67 @@ def test_make_jump_table(self):
self.dac.make_jump_table(entries)
# we made it this far and we're feeling pretty good about it

def test_catch_bad_jump_table(self):
"""Test jump table commands that are executed too frequently"""

# from_addr of 16 followed by 20 are too close together
bad_jump_args = [
def test_catch_nop_nop_too_close(self):
entries = self.make_entries([
('NOP', [16]),
('NOP', [20]),
('END', [400])
]
])
with pytest.raises(ValueError):
self.dac.make_jump_table(entries)

This comment has been minimized.

Copy link
@maffoo

maffoo Feb 27, 2016

Contributor

nit: too much indentation


def test_catch_jump_iterated_nop_too_close(self):

# from addr of 16 is followed by from addr of 20
bad_jump_args_2 = [
entries = self.make_entries([
('JUMP', [32, 16, 1]),
('NOP', [20]),
('END', [400])
]
])
with pytest.raises(ValueError):
self.dac.make_jump_table(entries)

def test_catch_jump_back_too_close(self):

entries = self.make_entries([
('NOP', [32]),
('JUMP', [100, 28, 0]),
('END', [400])
])
with pytest.raises(ValueError):
self.dac.make_jump_table(entries)

def test_catch_idle_end_too_close(self):

# from addr of 32 is followed by from addr of 36 (even though IDLE?)
bad_jump_args_3 = [
entries = self.make_entries([
('IDLE', [32, 200]),
('END', [36])
]

for args in [bad_jump_args, bad_jump_args_2, bad_jump_args_3]:
entries = self.make_entries(args)
with pytest.raises(ValueError):
self.dac.make_jump_table(entries)
])
with pytest.raises(ValueError):
self.dac.make_jump_table(entries)

def test_catch_bad_jump_table_edge(self):
def test_nop_nop_1_clk_too_close(self):
"""Test a table that executes commands 1 clock cycle too frequently"""

from_addr = self.dac.JT_MIN_FROM_ADDR * 4
bad_jump_args = [
entries = self.make_entries([
('NOP', [from_addr]),
('NOP', [from_addr +
(self.dac.JT_MIN_CLK_CYCLES_BETWEEN_OPCODES - 1) * 4]),
('END', [400])
]
])

entries = self.make_entries(bad_jump_args)
with pytest.raises(ValueError):
self.dac.make_jump_table(entries)
self.dac.make_jump_table(entries)

def test_nop_nop_min_clk_ok(self):
from_addr = self.dac.JT_MIN_FROM_ADDR * 4
bad_jump_args = [
_ = self.make_entries([
('NOP', [from_addr]),
('NOP', [from_addr +
self.dac.JT_MIN_CLK_CYCLES_BETWEEN_OPCODES * 4]),
('END', [400])
]

_ = self.make_entries(bad_jump_args)

])

if __name__ == '__main__':
pytest.main(['-v', __file__])

0 comments on commit b959122

Please sign in to comment.