summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2014-08-16 11:30:35 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2014-08-16 11:30:35 (GMT)
commit161c0f8ab227af5033b1b6456607b9b9c3bc60df (patch)
treecadf14ab1bfe857ac9a7904fe9ea98de554751d8 /tests
parent56ee4d3ecddeee05f11083fcc1595e3756b91790 (diff)
Improved the code for handling vmpa_t definitions.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@388 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
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!')
+
+
+
+
+
+