about summary refs log tree commit diff stats
path: root/test/expression/stp.py
diff options
context:
space:
mode:
authorserpilliere <devnull@localhost>2014-06-03 10:27:56 +0200
committerserpilliere <devnull@localhost>2014-06-03 10:27:56 +0200
commited5c3668cc9f545b52674ad699fc2b0ed1ccb575 (patch)
tree07faf97d7e4d083173a1f7e1bfd249baed2d74f9 /test/expression/stp.py
parenta183e1ebd525453710306695daa8c410fd0cb2af (diff)
downloadmiasm-ed5c3668cc9f545b52674ad699fc2b0ed1ccb575.tar.gz
miasm-ed5c3668cc9f545b52674ad699fc2b0ed1ccb575.zip
Miasm v2
* API has changed, so old scripts need updates
* See example for API usage
* Use tcc or llvm for jit emulation
* Go to test and run test_all.py to check install

Enjoy !
Diffstat (limited to 'test/expression/stp.py')
-rw-r--r--test/expression/stp.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/expression/stp.py b/test/expression/stp.py
new file mode 100644
index 00000000..fe09e865
--- /dev/null
+++ b/test/expression/stp.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+
+import unittest
+
+
+class TestIrIr2STP(unittest.TestCase):
+
+    def test_ExprOp_strcst(self):
+        from miasm2.expression.expression import ExprInt32, ExprOp
+        import miasm2.expression.stp   # /!\ REALLY DIRTY HACK
+        args = [ExprInt32(i) for i in xrange(9)]
+
+        self.assertEqual(
+            ExprOp('|',  *args[:2]).strcst(), r'(0bin00000000000000000000000000000000 | 0bin00000000000000000000000000000001)')
+        self.assertEqual(
+            ExprOp('-',  *args[:2]).strcst(), r'BVUMINUS(0bin00000000000000000000000000000000)')
+        self.assertEqual(
+            ExprOp('+',  *args[:3]).strcst(), r'BVPLUS(32,BVPLUS(32,0bin00000000000000000000000000000000, 0bin00000000000000000000000000000001), 0bin00000000000000000000000000000010)')
+        self.assertRaises(ValueError, ExprOp('X', *args[:1]).strcst)
+
+    def test_ExprSlice_strcst(self):
+        from miasm2.expression.expression import ExprInt32, ExprSlice
+        import miasm2.expression.stp   # /!\ REALLY DIRTY HACK
+        args = [ExprInt32(i) for i in xrange(9)]
+
+        self.assertEqual(
+            args[0][1:2].strcst(), r'(0bin00000000000000000000000000000000)[1:1]')
+        self.assertRaises(ValueError, args[0].__getitem__, slice(1,7,2))
+
+if __name__ == '__main__':
+    testsuite = unittest.TestLoader().loadTestsFromTestCase(TestIrIr2STP)
+    report = unittest.TextTestRunner(verbosity=2).run(testsuite)
+    exit(len(report.errors + report.failures))
+