about summary refs log tree commit diff stats
path: root/test/arch/mep/ir/test_debug.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/arch/mep/ir/test_debug.py')
-rw-r--r--test/arch/mep/ir/test_debug.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/arch/mep/ir/test_debug.py b/test/arch/mep/ir/test_debug.py
new file mode 100644
index 00000000..53f4064d
--- /dev/null
+++ b/test/arch/mep/ir/test_debug.py
@@ -0,0 +1,33 @@
+# Toshiba MeP-c4 - Debug instructions unit tests
+# Guillaume Valadon <guillaume@valadon.net>
+
+from ut_helpers_ir import exec_instruction
+
+from miasm2.expression.expression import ExprId, ExprInt, ExprCond, ExprOp
+
+
+class TestDebug:
+
+    def test_dret(self):
+        """Test DRET execution"""
+
+        # DRET
+        exec_instruction("DRET",
+                         [(ExprId("DEPC", 32), ExprInt(2, 32)),
+                          (ExprId("DBG", 32), ExprInt(0xFFFFFFFF, 32))],
+                         [(ExprId("PC", 32), ExprInt(2, 32)),
+                          (ExprId("DBG", 32), ExprInt(0xFFFFBFFF, 32))])
+
+        exec_instruction("DRET",
+                         [(ExprId("DEPC", 32), ExprInt(2, 32)),
+                          (ExprId("DBG", 32), ExprInt(2**15, 32))],
+                         [(ExprId("PC", 32), ExprInt(2, 32)),
+                          (ExprId("DBG", 32), ExprInt(2**15, 32))])
+
+    def test_dbreak(self):
+        """Test DBREAK execution"""
+
+        # DBREAK
+        exec_instruction("DBREAK",
+                         [(ExprId("DBG", 32), ExprInt(0, 32))],
+                         [(ExprId("DBG", 32), ExprInt(0b10, 32))])