summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-01-29 22:54:42 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-01-29 22:54:42 (GMT)
commit49fcaf9ea6dc34382ac69b3eaf803c0617b652e0 (patch)
tree7fcd84f6f16ac8e646e01f266c66e0bff41106ad /tests
parentce583a69951bf9a94ca46bcf9f598cdc94b80e29 (diff)
Introduced binary portion support for Python bindings.
Diffstat (limited to 'tests')
-rw-r--r--tests/glibext/__init__.py0
-rw-r--r--tests/glibext/binportion.py60
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)