From 0435b8b75050177d1ffca2cf23cb7bda4c69a974 Mon Sep 17 00:00:00 2001
From: shakamd <shakamd@gmail.com>
Date: Wed, 16 Nov 2016 23:43:09 -0500
Subject: [PATCH] Adding unit test for arm_bl relative branch (#258)

* Adding unit test for arm_bl relative branch

* reducing number of instructions required to create failure

* typo

* Adding more test cases
---
 suite/regress/arm_bl_location.py | 41 ++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100755 suite/regress/arm_bl_location.py

diff --git a/suite/regress/arm_bl_location.py b/suite/regress/arm_bl_location.py
new file mode 100755
index 0000000..e0990d2
--- /dev/null
+++ b/suite/regress/arm_bl_location.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+
+# Test BL <target> instruction for ARM32
+
+# Github issue: #257
+# Author: shakamd
+
+from keystone import *
+
+import regress
+
+class TestARM(regress.RegressTest):
+    def runTest(self):
+        # Initialize Keystone engine
+        ks = Ks(KS_ARCH_ARM, KS_MODE_ARM)
+        # Assemble to get back insn encoding & statement count
+        encoding, count = ks.asm(b"""
+                    nop
+                    bl #0xfffe5064
+                    """)
+        # Assert the result
+        self.assertEqual(encoding[-4:], [ 0x16, 0x94, 0xff, 0xeb ])
+
+        encoding, count = ks.asm(b"""
+                    nop
+                    nop
+                    bl #0xfffe5068
+                    """)
+        # Assert the result
+        self.assertEqual(encoding[-4:], [ 0x16, 0x94, 0xff, 0xeb ])
+
+        encoding, count = ks.asm(b"""
+                    nop
+                    lsr r7, r2, #8
+                    bl #0xfffe5068
+                    """)
+        # Assert the result
+        self.assertEqual(encoding[-4:], [ 0x16, 0x94, 0xff, 0xeb ])
+
+if __name__ == '__main__':
+    regress.main()
-- 
GitLab