summaryrefslogtreecommitdiff
path: root/tests/glibext
diff options
context:
space:
mode:
Diffstat (limited to 'tests/glibext')
-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)