From 0712331803f1d54e36cf3f5c04b5dd1c0538c655 Mon Sep 17 00:00:00 2001
From: Nguyen Anh Quynh <aquynh@gmail.com>
Date: Sat, 21 May 2016 00:47:02 +0800
Subject: [PATCH] regress: add testcase for #68

---
 suite/regress/x86_div0.py | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100755 suite/regress/x86_div0.py

diff --git a/suite/regress/x86_div0.py b/suite/regress/x86_div0.py
new file mode 100755
index 0000000..f88d65e
--- /dev/null
+++ b/suite/regress/x86_div0.py
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+
+# Handle modulo 0 or div 0 issue
+
+# Github issue: #68
+# Author: Nguyen Anh Quynh
+
+from keystone import *
+
+import regress
+
+CODE1 = b"jne 4014%0"
+CODE2 = b"jne 4014/0"
+
+class TestX86(regress.RegressTest):
+    def runTest(self):
+        # Initialize Keystone engine
+        ks = Ks(KS_ARCH_X86, KS_MODE_32)
+
+        try:
+            encoding, count = ks.asm(CODE1)
+        except KsError as e:
+            if e.errno == KS_ERR_ASM_INVALIDOPERAND:
+                print("Got error KS_ERR_ASM_INVALIDOPERAND as expected")
+            else:
+                self.assertFalse(1, "ERROR: %s" % e)
+
+        try:
+            encoding, count = ks.asm(CODE2)
+        except KsError as e:
+            if e.errno == KS_ERR_ASM_INVALIDOPERAND:
+                print("Got error KS_ERR_ASM_INVALIDOPERAND as expected")
+            else:
+                self.assertFalse(1, "ERROR: %s" % e)
+
+if __name__ == '__main__':
+    regress.main()
-- 
GitLab