about summary refs log tree commit diff stats
path: root/test/arch/arm/arch.py
diff options
context:
space:
mode:
authorCamille Mougey <commial@gmail.com>2019-03-07 14:37:07 +0100
committerGitHub <noreply@github.com>2019-03-07 14:37:07 +0100
commit4c2320b46250a8d6f8774e1218544b72a154cd8e (patch)
treeb67e7b072439f84109bd39dad8ed7f3f135224f8 /test/arch/arm/arch.py
parenteab809932871f91d6f4aa770fc321af9e156e0f5 (diff)
parent26c1075723a02984da6d3bc7423c5c0c43082dc3 (diff)
downloadmiasm-4c2320b46250a8d6f8774e1218544b72a154cd8e.tar.gz
miasm-4c2320b46250a8d6f8774e1218544b72a154cd8e.zip
Merge pull request #990 from serpilliere/support_python2_python3
Support python2 python3
Diffstat (limited to 'test/arch/arm/arch.py')
-rw-r--r--test/arch/arm/arch.py49
1 files changed, 26 insertions, 23 deletions
diff --git a/test/arch/arm/arch.py b/test/arch/arm/arch.py
index f86c3cfb..c8f2d433 100644
--- a/test/arch/arm/arch.py
+++ b/test/arch/arm/arch.py
@@ -1,13 +1,16 @@
+from __future__ import print_function
 import time
-from miasm2.arch.arm.arch import *
-from miasm2.core.locationdb import LocationDB
+
+from miasm.core.utils import decode_hex, encode_hex
+from miasm.arch.arm.arch import *
+from miasm.core.locationdb import LocationDB
 from pdb import pm
 
 
 loc_db = LocationDB()
 
 def h2i(s):
-    return s.replace(' ', '').decode('hex')
+    return decode_hex(s.replace(' ', ''))
 
 
 def u16swap(i):
@@ -225,19 +228,19 @@ reg_tests_arm = [
 ts = time.time()
 
 for s, l in reg_tests_arm:
-    print "-" * 80
+    print("-" * 80)
     s = s[12:]
     b = h2i((l))
     mn = mn_arm.dis(b, 'l')
-    print [str(x) for x in mn.args]
-    print s
-    print mn
+    print([str(x) for x in mn.args])
+    print(s)
+    print(mn)
     assert(str(mn) == s)
     l = mn_arm.fromstring(s, loc_db, 'l')
     assert(str(l) == s)
     a = mn_arm.asm(l)
-    print [x for x in a]
-    print repr(b)
+    print([x for x in a])
+    print(repr(b))
     assert(b in a)
 
 reg_tests_armt = [
@@ -692,30 +695,30 @@ reg_tests_armt = [
 
 
 ]
-print "#" * 40, 'armthumb', '#' * 40
+print("#" * 40, 'armthumb', '#' * 40)
 
 for s, l in reg_tests_armt:
-    print "-" * 80
+    print("-" * 80)
     s = s[12:]
     b = h2i((l))
-    print b.encode('hex')
+    print(encode_hex(b))
     mn = mn_armt.dis(b, 'l')
-    print [str(x) for x in mn.args]
-    print s
-    print mn
+    print([str(x) for x in mn.args])
+    print(s)
+    print(mn)
     assert(str(mn) == s)
     l = mn_armt.fromstring(s, loc_db, 'l')
     assert(str(l) == s)
-    print 'Asm..', l
+    print('Asm..', l)
     a = mn_armt.asm(l)
-    print [x for x in a]
-    print repr(b)
+    print([x for x in a])
+    print(repr(b))
     assert(b in a)
 
-print 'TEST time', time.time() - ts
+print('TEST time', time.time() - ts)
 
 # speed test arm
-o = ""
+o = b""
 for s, l in reg_tests_arm:
     s = s[12:]
     b = h2i((l))
@@ -731,11 +734,11 @@ while off < bs.getlen():
     mn = mn_arm.dis(bs, 'l', off)
     instr_num += 1
     off += 4
-print 'instr per sec:', instr_num / (time.time() - ts)
+print('instr per sec:', instr_num // (time.time() - ts))
 
 
 # speed test thumb
-o = ""
+o = b""
 for s, l in reg_tests_armt:
     s = s[12:]
     b = h2i((l))
@@ -751,7 +754,7 @@ while off < bs.getlen():
     mn = mn_armt.dis(bs, 'l', off)
     instr_num += 1
     off += mn.l
-print 'instr per sec:', instr_num / (time.time() - ts)
+print('instr per sec:', instr_num // (time.time() - ts))
 
 import cProfile
 cProfile.run(r'mn_arm.dis("\xe1\xa0\xa0\x06", "l")')