about summary refs log tree commit diff stats
path: root/test/arch/msp430
diff options
context:
space:
mode:
Diffstat (limited to 'test/arch/msp430')
-rw-r--r--test/arch/msp430/arch.py19
-rwxr-xr-xtest/arch/msp430/sem.py15
2 files changed, 21 insertions, 13 deletions
diff --git a/test/arch/msp430/arch.py b/test/arch/msp430/arch.py
index 91de95b3..eea87091 100644
--- a/test/arch/msp430/arch.py
+++ b/test/arch/msp430/arch.py
@@ -1,12 +1,15 @@
+from __future__ import print_function
+
 import time
 from pdb import pm
+from miasm2.core.utils import decode_hex, encode_hex
 from miasm2.arch.msp430.arch import *
 from miasm2.core.locationdb import LocationDB
 
 loc_db = LocationDB()
 
 def h2i(s):
-    return s.replace(' ', '').decode('hex')
+    return decode_hex(s.replace(' ', ''))
 
 
 def u16swap(i):
@@ -86,18 +89,18 @@ reg_tests_msp = [
 ts = time.time()
 
 for s, l in reg_tests_msp:
-    print "-" * 80
+    print("-" * 80)
     s = s[8:]
     b = h2i((l))
-    print repr(b)
+    print(repr(b))
     mn = mn_msp430.dis(b, None)
-    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_msp430.fromstring(s, loc_db, None)
     assert(str(l) == s)
     a = mn_msp430.asm(l)
-    print [x for x in a]
-    print repr(b)
+    print([x for x in a])
+    print(repr(b))
     assert(b in a)
diff --git a/test/arch/msp430/sem.py b/test/arch/msp430/sem.py
index 10e57e36..88aa990d 100755
--- a/test/arch/msp430/sem.py
+++ b/test/arch/msp430/sem.py
@@ -1,9 +1,12 @@
 #! /usr/bin/env python2
 #-*- coding:utf-8 -*-
 
+from __future__ import print_function
 import unittest
 import logging
 
+from future.utils import viewitems
+
 from miasm2.ir.symbexec import SymbolicExecutionEngine
 from miasm2.arch.msp430.arch import mn_msp430 as mn, mode_msp430 as mode
 from miasm2.arch.msp430.sem import ir_msp430 as ir_arch
@@ -22,7 +25,7 @@ def M(addr):
 def compute(asm, inputstate={}, debug=False):
     loc_db = LocationDB()
     sympool = dict(regs_init)
-    sympool.update({k: ExprInt(v, k.size) for k, v in inputstate.iteritems()})
+    sympool.update({k: ExprInt(v, k.size) for k, v in viewitems(inputstate)})
     ir_tmp = ir_arch(loc_db)
     ircfg = ir_tmp.new_ircfg()
     symexec = SymbolicExecutionEngine(ir_tmp, sympool)
@@ -33,11 +36,13 @@ def compute(asm, inputstate={}, debug=False):
     loc_key = ir_tmp.add_instr_to_ircfg(instr, ircfg)
     symexec.run_at(ircfg, loc_key)
     if debug:
-        for k, v in symexec.symbols.items():
+        for k, v in viewitems(symexec.symbols):
             if regs_init.get(k, None) != v:
-                print k, v
-    return {k: v.arg.arg for k, v in symexec.symbols.items()
-            if k not in EXCLUDE_REGS and regs_init.get(k, None) != v}
+                print(k, v)
+    return {
+        k: v.arg.arg for k, v in viewitems(symexec.symbols)
+        if k not in EXCLUDE_REGS and regs_init.get(k, None) != v
+    }
 
 
 class TestMSP430Semantic(unittest.TestCase):