diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/analysis/contents/restricted.py | 88 |
1 files changed, 78 insertions, 10 deletions
diff --git a/tests/analysis/contents/restricted.py b/tests/analysis/contents/restricted.py index e8d3e07..6484299 100644 --- a/tests/analysis/contents/restricted.py +++ b/tests/analysis/contents/restricted.py @@ -58,15 +58,39 @@ class TestRestrictedContent(ChrysalideTestCase): self.assertIsNotNone(rcnt) val = rcnt.read_u8(start) - self.assertEqual(val, b'\x15') + self.assertEqual(val, 0x15) val = rcnt.read_u8(start) - self.assertEqual(val, b'\x16') + self.assertEqual(val, 0x16) val = rcnt.read_u16(start, vmpa.SRE_LITTLE) - self.assertEqual(val, b'\x17\x18') + self.assertEqual(val, 0x1817) val = rcnt.read_u32(start, vmpa.SRE_LITTLE) + self.assertEqual(val, 0x24232221) + + + def testReadRawAccess(self): + """Check valid raw accesses to restricted content.""" + + fcnt = FileContent(self._out.name) + + start = vmpa(12, vmpa.VMPA_NO_VIRTUAL) + covered = mrange(start, 12) # 0x15 ... 0x28 + + rcnt = RestrictedContent(fcnt, covered) + self.assertIsNotNone(rcnt) + + val = rcnt.read_raw(start, 1) + self.assertEqual(val, b'\x15') + + val = rcnt.read_raw(start, 1) + self.assertEqual(val, b'\x16') + + val = rcnt.read_raw(start, 2) + self.assertEqual(val, b'\x17\x18') + + val = rcnt.read_raw(start, 4) self.assertEqual(val, b'\x21\x22\x23\x24') @@ -83,34 +107,78 @@ class TestRestrictedContent(ChrysalideTestCase): start = vmpa(12, vmpa.VMPA_NO_VIRTUAL) val = rcnt.read_u8(start) - self.assertEqual(val, b'\x15') + self.assertEqual(val, 0x15) start = vmpa(12, vmpa.VMPA_NO_VIRTUAL) val = rcnt.read_u16(start, vmpa.SRE_LITTLE) - self.assertEqual(val, b'\x15\x16') + self.assertEqual(val, 0x1615) start = vmpa(12, vmpa.VMPA_NO_VIRTUAL) val = rcnt.read_u32(start, vmpa.SRE_LITTLE) - self.assertEqual(val, b'\x15\x16\x17\x18') + self.assertEqual(val, 0x18171615) start = vmpa(12, vmpa.VMPA_NO_VIRTUAL) val = rcnt.read_u64(start, vmpa.SRE_LITTLE) - self.assertEqual(val, b'\x15\x16\x17\x18\x21\x22\x23\x24') + self.assertEqual(val, 0x2423222118171615) start = vmpa(23, vmpa.VMPA_NO_VIRTUAL) val = rcnt.read_u8(start) - self.assertEqual(val, b'\x28') + self.assertEqual(val, 0x28) start = vmpa(22, vmpa.VMPA_NO_VIRTUAL) val = rcnt.read_u16(start, vmpa.SRE_LITTLE) - self.assertEqual(val, b'\x27\x28') + self.assertEqual(val, 0x2827) start = vmpa(20, vmpa.VMPA_NO_VIRTUAL) val = rcnt.read_u32(start, vmpa.SRE_LITTLE) - self.assertEqual(val, b'\x25\x26\x27\x28') + self.assertEqual(val, 0x28272625) start = vmpa(16, vmpa.VMPA_NO_VIRTUAL) val = rcnt.read_u64(start, vmpa.SRE_LITTLE) + self.assertEqual(val, 0x2827262524232221) + + + def testBorderLineRawAccess(self): + """Check valid border line raw accesses to restricted content.""" + + fcnt = FileContent(self._out.name) + + start = vmpa(12, vmpa.VMPA_NO_VIRTUAL) + covered = mrange(start, 12) # 0x15 ... 0x28 + + rcnt = RestrictedContent(fcnt, covered) + self.assertIsNotNone(rcnt) + + start = vmpa(12, vmpa.VMPA_NO_VIRTUAL) + val = rcnt.read_raw(start, 1) + self.assertEqual(val, b'\x15') + + start = vmpa(12, vmpa.VMPA_NO_VIRTUAL) + val = rcnt.read_raw(start, 2) + self.assertEqual(val, b'\x15\x16') + + start = vmpa(12, vmpa.VMPA_NO_VIRTUAL) + val = rcnt.read_raw(start, 4) + self.assertEqual(val, b'\x15\x16\x17\x18') + + start = vmpa(12, vmpa.VMPA_NO_VIRTUAL) + val = rcnt.read_raw(start, 8) + self.assertEqual(val, b'\x15\x16\x17\x18\x21\x22\x23\x24') + + start = vmpa(23, vmpa.VMPA_NO_VIRTUAL) + val = rcnt.read_raw(start, 1) + self.assertEqual(val, b'\x28') + + start = vmpa(22, vmpa.VMPA_NO_VIRTUAL) + val = rcnt.read_raw(start, 2) + self.assertEqual(val, b'\x27\x28') + + start = vmpa(20, vmpa.VMPA_NO_VIRTUAL) + val = rcnt.read_raw(start, 4) + self.assertEqual(val, b'\x25\x26\x27\x28') + + start = vmpa(16, vmpa.VMPA_NO_VIRTUAL) + val = rcnt.read_raw(start, 8) self.assertEqual(val, b'\x21\x22\x23\x24\x25\x26\x27\x28') |