summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/arch/vmpa.py32
-rw-r--r--tests/test.py39
2 files changed, 71 insertions, 0 deletions
diff --git a/tests/arch/vmpa.py b/tests/arch/vmpa.py
new file mode 100755
index 0000000..9814b20
--- /dev/null
+++ b/tests/arch/vmpa.py
@@ -0,0 +1,32 @@
+#!/usr/bin/python3-dbg
+# -*- coding: utf-8 -*-
+
+import pychrysalide
+from pychrysalide.arch import vmpa
+from test import TestSuite
+
+
+########################
+
+TestSuite.print_sep()
+
+addr = vmpa()
+
+print('repr():', repr(addr))
+print('str(): ', str(addr))
+
+########################
+
+TestSuite.print_sep()
+
+TestSuite.check_true('Create a virtual memory or physical address', lambda: vmpa())
+
+v = vmpa()
+
+TestSuite.check_true('VMPA values are left uninitialized by default', lambda: v.phy == None and v.virt == None)
+
+a = vmpa(0, 0) + 1
+
+b = 1 + vmpa(0, 0)
+
+TestSuite.check_true('Verify the commutative property of addition', lambda: a == b)
diff --git a/tests/test.py b/tests/test.py
new file mode 100644
index 0000000..895c4f6
--- /dev/null
+++ b/tests/test.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python3-dbg
+# -*- coding: utf-8 -*-
+
+
+
+class TestSuite:
+
+
+
+
+
+
+
+
+ def print_sep():
+ """Print a separator line."""
+
+ print('------------------------')
+
+
+ def check_true(desc, code):
+ """Check if an expression is true."""
+
+ try:
+ test = code()
+ except:
+ test = False
+
+ if test:
+ print('[+] %s: OK' % desc)
+ else:
+ print('[+] %s: nok...' % desc)
+ raise Exception('Unexpected result!')
+
+
+
+
+
+