summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2021-10-12 22:26:55 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2021-10-12 22:26:55 (GMT)
commitd405d93f41f9376c55ac8af7acde62eec80386ec (patch)
tree200fe3624d99061cca876493103bf6e981cf30a9 /tests
parent2b3d86868d130ac82b403575d0b5521176e77827 (diff)
Reorganize the remaining code for binary contents.
Diffstat (limited to 'tests')
-rw-r--r--tests/analysis/contents/checksum.py2
-rw-r--r--tests/analysis/contents/endian.py50
-rw-r--r--tests/analysis/contents/memory.py18
-rw-r--r--tests/analysis/contents/restricted.py1
4 files changed, 35 insertions, 36 deletions
diff --git a/tests/analysis/contents/checksum.py b/tests/analysis/contents/checksum.py
index 54e4630..fd0c3ed 100644
--- a/tests/analysis/contents/checksum.py
+++ b/tests/analysis/contents/checksum.py
@@ -56,7 +56,7 @@ class TestRestrictedContent(ChrysalideTestCase):
fcnt = FileContent(self._out.name)
self.assertIsNotNone(fcnt)
- start = vmpa(4, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(4, vmpa.VmpaSpecialValue.NO_VIRTUAL)
covered = mrange(start, 4) # 'BBBB'
rcnt = RestrictedContent(fcnt, covered)
diff --git a/tests/analysis/contents/endian.py b/tests/analysis/contents/endian.py
index 77ed77a..b7c8bec 100644
--- a/tests/analysis/contents/endian.py
+++ b/tests/analysis/contents/endian.py
@@ -6,7 +6,7 @@
from chrysacase import ChrysalideTestCase
-from pychrysalide import arch
+from pychrysalide.analysis import BinContent
from pychrysalide.analysis.contents import FileContent, RestrictedContent
from pychrysalide.arch import vmpa
import tempfile
@@ -53,38 +53,38 @@ class TestEndianness(ChrysalideTestCase):
# 16 bits
- start = vmpa(12, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(12, vmpa.VmpaSpecialValue.NO_VIRTUAL)
- val = fcnt.read_u16(start, arch.SRE_LITTLE_WORD)
+ val = fcnt.read_u16(start, BinContent.SourceEndian.LITTLE_WORD)
self.assertEqual(val, 0x1516)
- start = vmpa(12, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(12, vmpa.VmpaSpecialValue.NO_VIRTUAL)
- val = fcnt.read_u16(start, arch.SRE_BIG_WORD)
+ val = fcnt.read_u16(start, BinContent.SourceEndian.BIG_WORD)
self.assertEqual(val, 0x1615)
# 32 bits
- start = vmpa(12, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(12, vmpa.VmpaSpecialValue.NO_VIRTUAL)
- val = fcnt.read_u32(start, arch.SRE_LITTLE_WORD)
+ val = fcnt.read_u32(start, BinContent.SourceEndian.LITTLE_WORD)
self.assertEqual(val, 0x17181516)
- start = vmpa(12, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(12, vmpa.VmpaSpecialValue.NO_VIRTUAL)
- val = fcnt.read_u32(start, arch.SRE_BIG_WORD)
+ val = fcnt.read_u32(start, BinContent.SourceEndian.BIG_WORD)
self.assertEqual(val, 0x16151817)
# 64 bits
- start = vmpa(0, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(0, vmpa.VmpaSpecialValue.NO_VIRTUAL)
- val = fcnt.read_u64(start, arch.SRE_LITTLE_WORD)
+ val = fcnt.read_u64(start, BinContent.SourceEndian.LITTLE_WORD)
self.assertEqual(val, 0x0708050603040102)
- start = vmpa(0, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(0, vmpa.VmpaSpecialValue.NO_VIRTUAL)
- val = fcnt.read_u64(start, arch.SRE_BIG_WORD)
+ val = fcnt.read_u64(start, BinContent.SourceEndian.BIG_WORD)
self.assertEqual(val, 0x0201040306050807)
@@ -95,36 +95,36 @@ class TestEndianness(ChrysalideTestCase):
# 16 bits
- start = vmpa(12, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(12, vmpa.VmpaSpecialValue.NO_VIRTUAL)
- val = fcnt.read_u16(start, arch.SRE_LITTLE)
+ val = fcnt.read_u16(start, BinContent.SourceEndian.LITTLE)
self.assertEqual(val, 0x1615)
- start = vmpa(12, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(12, vmpa.VmpaSpecialValue.NO_VIRTUAL)
- val = fcnt.read_u16(start, arch.SRE_BIG)
+ val = fcnt.read_u16(start, BinContent.SourceEndian.BIG)
self.assertEqual(val, 0x1516)
# 32 bits
- start = vmpa(12, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(12, vmpa.VmpaSpecialValue.NO_VIRTUAL)
- val = fcnt.read_u32(start, arch.SRE_LITTLE)
+ val = fcnt.read_u32(start, BinContent.SourceEndian.LITTLE)
self.assertEqual(val, 0x18171615)
- start = vmpa(12, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(12, vmpa.VmpaSpecialValue.NO_VIRTUAL)
- val = fcnt.read_u32(start, arch.SRE_BIG)
+ val = fcnt.read_u32(start, BinContent.SourceEndian.BIG)
self.assertEqual(val, 0x15161718)
# 64 bits
- start = vmpa(0, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(0, vmpa.VmpaSpecialValue.NO_VIRTUAL)
- val = fcnt.read_u64(start, arch.SRE_LITTLE)
+ val = fcnt.read_u64(start, BinContent.SourceEndian.LITTLE)
self.assertEqual(val, 0x0807060504030201)
- start = vmpa(0, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(0, vmpa.VmpaSpecialValue.NO_VIRTUAL)
- val = fcnt.read_u64(start, arch.SRE_BIG)
+ val = fcnt.read_u64(start, BinContent.SourceEndian.BIG)
self.assertEqual(val, 0x0102030405060708)
diff --git a/tests/analysis/contents/memory.py b/tests/analysis/contents/memory.py
index 55ce035..f99e607 100644
--- a/tests/analysis/contents/memory.py
+++ b/tests/analysis/contents/memory.py
@@ -7,7 +7,7 @@
from chrysacase import ChrysalideTestCase
-from pychrysalide import arch
+from pychrysalide.analysis import BinContent
from pychrysalide.analysis.contents import MemoryContent
from pychrysalide.arch import vmpa, mrange
@@ -29,7 +29,7 @@ class TestMemoryContent(ChrysalideTestCase):
cnt = MemoryContent(data)
- start = vmpa(4, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(4, vmpa.VmpaSpecialValue.NO_VIRTUAL)
val = cnt.read_u8(start)
self.assertEqual(val, 0x05)
@@ -37,14 +37,14 @@ class TestMemoryContent(ChrysalideTestCase):
val = cnt.read_u8(start)
self.assertEqual(val, 0x06)
- start = vmpa(14, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(14, vmpa.VmpaSpecialValue.NO_VIRTUAL)
- val = cnt.read_u16(start, arch.SRE_LITTLE)
+ val = cnt.read_u16(start, BinContent.SourceEndian.LITTLE)
self.assertEqual(val, 0x1817)
- start = vmpa(10, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(10, vmpa.VmpaSpecialValue.NO_VIRTUAL)
- val = cnt.read_u32(start, arch.SRE_LITTLE)
+ val = cnt.read_u32(start, BinContent.SourceEndian.LITTLE)
self.assertEqual(val, 0x16150013)
@@ -57,10 +57,10 @@ class TestMemoryContent(ChrysalideTestCase):
with self.assertRaisesRegex(Exception, 'Invalid read access.'):
- start = vmpa(1, vmpa.VMPA_NO_VIRTUAL)
+ start = vmpa(1, vmpa.VmpaSpecialValue.NO_VIRTUAL)
val = cnt.read_u8(start)
with self.assertRaisesRegex(Exception, 'Invalid read access.'):
- start = vmpa(0, vmpa.VMPA_NO_VIRTUAL)
- val = cnt.read_u16(start, arch.SRE_LITTLE)
+ start = vmpa(0, vmpa.VmpaSpecialValue.NO_VIRTUAL)
+ val = cnt.read_u16(start, BinContent.SourceEndian.LITTLE)
diff --git a/tests/analysis/contents/restricted.py b/tests/analysis/contents/restricted.py
index ae11619..023e600 100644
--- a/tests/analysis/contents/restricted.py
+++ b/tests/analysis/contents/restricted.py
@@ -7,7 +7,6 @@
from chrysacase import ChrysalideTestCase
-from pychrysalide import arch
from pychrysalide.analysis import BinContent
from pychrysalide.analysis.contents import FileContent, RestrictedContent
from pychrysalide.arch import vmpa, mrange