Skip to content

Commit

Permalink
Add node util tests. Version release
Browse files Browse the repository at this point in the history
  • Loading branch information
amykyta3 committed May 10, 2019
1 parent 7af80de commit 9953b24
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion systemrdl/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.7.0-dev"
__version__ = "1.7.0"
61 changes: 61 additions & 0 deletions test/test_node_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

from .unittest_utils import RDLSourceTestCase

#===============================================================================
# Validate inferred field bit placement/packing
#===============================================================================
class TestNodeUtils(RDLSourceTestCase):

def test_index_tools(self):
top = self.compile(
["rdl_testcases/address_packing.rdl"],
"hier"
)

with self.subTest("hier.x"):
node = top.find_by_path("hier.x")
self.assertEqual(node.get_path(), "hier.x")
node.clear_lineage_index()
self.assertEqual(node.get_path(), "hier.x")
node.zero_lineage_index()
self.assertEqual(node.get_path(), "hier.x")

with self.subTest("hier.y.a"):
node = top.find_by_path("hier.y[2].a")
self.assertEqual(node.get_path(), "hier.y[2].a[][]")
node.zero_lineage_index()
self.assertEqual(node.get_path(), "hier.y[0].a[0][0]")
node.clear_lineage_index()
self.assertEqual(node.get_path(), "hier.y[].a[][]")

def test_address_tools(self):
top = self.compile(
["rdl_testcases/address_packing.rdl"],
"hier"
)

with self.subTest("hier.y[2].a"):
node = top.find_by_path("hier.y[2].a")
with self.assertRaises(ValueError):
node.address_offset
with self.assertRaises(ValueError):
node.absolute_address
self.assertEqual(node.raw_address_offset, 0)
self.assertEqual(node.raw_absolute_address, 0x100)

with self.subTest("hier.y.c[1][1]"):
node = top.find_by_path("hier.y.c[1][1]")
self.assertEqual(node.address_offset, 0x64 + 4*4+4)
with self.assertRaises(ValueError):
node.absolute_address
self.assertEqual(node.raw_address_offset, 0x64)
self.assertEqual(node.raw_absolute_address, 0x100 + 0x64)

def test_repr(self):
top = self.compile(
["rdl_testcases/address_packing.rdl"],
"hier"
)

node = top.find_by_path("hier.x.b.a")
self.assertRegex(str(node), "<FieldNode hier\.x\.b\[\]\.a at 0x\w+>")

0 comments on commit 9953b24

Please sign in to comment.