diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-01-29 22:54:42 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-01-29 22:54:42 (GMT) |
commit | 49fcaf9ea6dc34382ac69b3eaf803c0617b652e0 (patch) | |
tree | 7fcd84f6f16ac8e646e01f266c66e0bff41106ad /tests/glibext | |
parent | ce583a69951bf9a94ca46bcf9f598cdc94b80e29 (diff) |
Introduced binary portion support for Python bindings.
Diffstat (limited to 'tests/glibext')
-rw-r--r-- | tests/glibext/__init__.py | 0 | ||||
-rw-r--r-- | tests/glibext/binportion.py | 60 |
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/glibext/__init__.py b/tests/glibext/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/glibext/__init__.py diff --git a/tests/glibext/binportion.py b/tests/glibext/binportion.py new file mode 100644 index 0000000..a95352e --- /dev/null +++ b/tests/glibext/binportion.py @@ -0,0 +1,60 @@ +#!/usr/bin/python3-dbg +# -*- coding: utf-8 -*- + + +from chrysacase import ChrysalideTestCase +from pychrysalide.arch import vmpa +from pychrysalide.glibext import BinPortion + + +class TestPathNames(ChrysalideTestCase): + """TestCase for glibext.BinPortion*""" + + + def testPortionProperties(self): + """Validate various binary portion properties.""" + + p = BinPortion(BinPortion.BPC_RAW, 0x102, 10) + + p.desc = 'ABC' + self.assertEqual(p.desc, 'ABC') + + self.assertEqual(p.range.addr.phys, None) + self.assertEqual(p.range.addr.virt, 0x102) + self.assertEqual(p.range.length, 10) + + p.continuation = True + self.assertTrue(p.continuation) + + p.continuation = False + self.assertFalse(p.continuation) + + p.rights = BinPortion.PAC_ALL + self.assertEqual(p.rights, BinPortion.PAC_READ | BinPortion.PAC_WRITE | BinPortion.PAC_EXEC) + + + def testPortionMethods(self): + """Validate some binary portion methods.""" + + p = BinPortion(BinPortion.BPC_RAW, 0x102, 10) + + self.assertEqual(p.range.length, 10) + + p.limit_range(10) + + self.assertEqual(p.range.length, 10) + + p.limit_range(6) + + self.assertEqual(p.range.length, 6) + + + def testPortionComparison(self): + """Compare different binary portions.""" + + p0 = BinPortion(BinPortion.BPC_CODE, 0x102, 10) + + addr = vmpa(vmpa.VMPA_NO_PHYSICAL, 0x102) + p1 = BinPortion(BinPortion.BPC_CODE, addr, 10) + + self.assertEqual(p0, p1) |