about summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/analysis/data_flow.py1
-rw-r--r--test/analysis/depgraph.py2
-rw-r--r--test/analysis/dse.py3
-rw-r--r--test/arch/aarch64/unit/asm_test.py5
-rw-r--r--test/arch/arm/arch.py62
-rw-r--r--test/arch/mips32/arch.py4
-rw-r--r--test/arch/mips32/unit/asm_test.py3
-rw-r--r--test/arch/msp430/arch.py4
-rw-r--r--test/arch/sh4/arch.py4
-rw-r--r--test/arch/x86/arch.py7
-rw-r--r--test/arch/x86/unit/asm_test.py7
-rw-r--r--test/core/asmblock.py8
-rw-r--r--test/expression/simplifications.py4
-rw-r--r--test/jitter/bad_block.py3
-rw-r--r--test/jitter/jit_options.py3
-rw-r--r--test/jitter/jmp_out_mem.py3
-rw-r--r--test/jitter/test_post_instr.py4
17 files changed, 15 insertions, 112 deletions
diff --git a/test/analysis/data_flow.py b/test/analysis/data_flow.py
index c3469109..d5b197d2 100644
--- a/test/analysis/data_flow.py
+++ b/test/analysis/data_flow.py
@@ -673,7 +673,6 @@ for test_nb, test in enumerate([(G1_IRA, G1_EXP_IRA),
 
     reaching_defs = ReachingDefinitions(g_ira)
     defuse = DiGraphDefUse(reaching_defs, deref_mem=True)
-    #open("defuse_%02d.dot" % (test_nb+1), "w").write(defuse.dot())
 
     # # Simplify graph
     dead_simp(g_ira)
diff --git a/test/analysis/depgraph.py b/test/analysis/depgraph.py
index 4e023761..86857182 100644
--- a/test/analysis/depgraph.py
+++ b/test/analysis/depgraph.py
@@ -1058,7 +1058,7 @@ for test_nb, test in enumerate([(G1_IRA, G1_INPUT),
             all_results.add(unflatGraph(flatGraph(result.graph)))
             open("graph_test_%02d_%02d.dot" % (test_nb + 1, i),
                  "w").write(dg2graph(result.graph))
-        # print all_flat
+
         if g_ind == 0:
             all_flat = sorted(all_flat)
             all_flats.append(all_flat)
diff --git a/test/analysis/dse.py b/test/analysis/dse.py
index 5a72db34..4367f6f7 100644
--- a/test/analysis/dse.py
+++ b/test/analysis/dse.py
@@ -34,8 +34,7 @@ class DSETest(object):
         self.myjit = jitter(jitter_engine)
         self.myjit.init_stack()
 
-        self.myjit.jit.log_regs = True
-        self.myjit.jit.log_mn = True
+        self.myjit.set_trace_log()
 
         self.dse = None
         self.assembly = None
diff --git a/test/arch/aarch64/unit/asm_test.py b/test/arch/aarch64/unit/asm_test.py
index ca27ef9d..437a8056 100644
--- a/test/arch/aarch64/unit/asm_test.py
+++ b/test/arch/aarch64/unit/asm_test.py
@@ -16,16 +16,11 @@ class Asm_Test(object):
         self.myjit = Machine("aarch64l").jitter(jitter)
         self.myjit.init_stack()
 
-        self.myjit.jit.log_regs = False
-        self.myjit.jit.log_mn = False
-
-
     def __call__(self):
         self.asm()
         self.run()
         self.check()
 
-
     def asm(self):
         blocks, symbol_pool = parse_asm.parse_txt(mn_aarch64, 'l', self.TXT,
                                                   symbol_pool = self.myjit.ir_arch.symbol_pool)
diff --git a/test/arch/arm/arch.py b/test/arch/arm/arch.py
index 90d137d0..f69bb104 100644
--- a/test/arch/arm/arch.py
+++ b/test/arch/arm/arch.py
@@ -5,41 +5,6 @@ from pdb import pm
 
 
 symbol_pool = AsmSymbolPool()
-if 0:
-    a = bs('00')
-    b = bs('01')
-    c = bs(l=2)
-    d = bs(l=4, fname='rd')
-    e = bs_name(l=1, name={'ADD': 0, 'SUB': 1})
-    assert(isinstance(e, bs_divert))
-    scc = bs_mod_name(l=1, mn_mod=['', 'S'])
-    f = bs(l=1, cls=(arm_reg,))
-
-    class arm_mov(mn_arm):
-        fields = [bs('0000'), bs('0000'), bs('0000')]
-
-    class arm_DATA(mn_arm):
-        fields = [bs('1111'), e, scc, f, bs('0')]
-    mn = mn_arm.dis(0xF000000)
-
-
-if 0:
-    import cProfile
-    cProfile.run('mn_arm.dis("\xe1\xa0\xa0\x06", "l")')
-    # l = mn_arm.dis(bin_stream("\xe1\xa0\xa0\x06"), mode_arm)
-    # print l
-    """
-    mode = 64
-    l = mn_x86.fromstring("ADC      DWORD PTR [RAX], 0x11223344", mode)
-    print 'xx'
-    #t= time.time()
-    import cProfile
-    def f():
-        x = l.asm(mode)
-        print x
-    cProfile.run('f()')
-    """
-
 
 def h2i(s):
     return s.replace(' ', '').decode('hex')
@@ -268,15 +233,11 @@ for s, l in reg_tests_arm:
     print s
     print mn
     assert(str(mn) == s)
-    # print hex(b)
-    # print [str(x.get()) for x in mn.args]
     l = mn_arm.fromstring(s, symbol_pool, 'l')
-    # print l
     assert(str(l) == s)
     a = mn_arm.asm(l)
     print [x for x in a]
     print repr(b)
-    # print mn.args
     assert(b in a)
 
 reg_tests_armt = [
@@ -720,36 +681,14 @@ for s, l in reg_tests_armt:
     print s
     print mn
     assert(str(mn) == s)
-    # print hex(b)
-    # print [str(x.get()) for x in mn.args]
     l = mn_armt.fromstring(s, symbol_pool, 'l')
-    # print l
     assert(str(l) == s)
     print 'Asm..', l
     a = mn_armt.asm(l)
     print [x for x in a]
     print repr(b)
-    # print mn.args
     assert(b in a)
 
-"""
-print "*"*30, "START SPECIAL PARSING", "*"*30
-parse_tests = [
-    "MOV      LR, toto",
-    "MOV      LR, 1+toto",
-    "MOV      LR, (lend-lstart)^toto<<<R1",
-    "MOV      LR, R1 LSL (l_end-l_start)^toto<<<R1",
-    "MOV      LR, R1 LSL (l_end-l_start)^toto<<<R1",
-    "EOR      R0, R1, toto^titi+1",
-    ]
-
-for l in parse_tests:
-    print "-"*80
-    l = mn_arm.fromstring(l, 'l')
-    print l.name, ", ".join([str(a) for a in l.args])
-"""
-
-
 print 'TEST time', time.time() - ts
 
 # speed test arm
@@ -787,7 +726,6 @@ instr_num = 0
 ts = time.time()
 while off < bs.getlen():
     mn = mn_armt.dis(bs, 'l', off)
-    # print instr_num, off, str(mn)
     instr_num += 1
     off += mn.l
 print 'instr per sec:', instr_num / (time.time() - ts)
diff --git a/test/arch/mips32/arch.py b/test/arch/mips32/arch.py
index c6b68c0c..6fc36d13 100644
--- a/test/arch/mips32/arch.py
+++ b/test/arch/mips32/arch.py
@@ -228,13 +228,9 @@ for s, l in reg_tests_mips32:
     print s
     print mn
     assert(str(mn) == s)
-    # print hex(b)
-    # print [str(x.get()) for x in mn.args]
     l = mn_mips32.fromstring(s, symbol_pool, 'b')
-    # print l
     assert(str(l) == s)
     a = mn_mips32.asm(l, 'b')
     print [x for x in a]
     print repr(b)
-    # print mn.args
     assert(b in a)
diff --git a/test/arch/mips32/unit/asm_test.py b/test/arch/mips32/unit/asm_test.py
index f03a32d7..a2203783 100644
--- a/test/arch/mips32/unit/asm_test.py
+++ b/test/arch/mips32/unit/asm_test.py
@@ -18,9 +18,6 @@ class Asm_Test(object):
         self.myjit = Machine("mips32l").jitter(jitter)
         self.myjit.init_stack()
 
-        self.myjit.jit.log_regs = False
-        self.myjit.jit.log_mn = False
-
     def __call__(self):
         self.asm()
         self.run()
diff --git a/test/arch/msp430/arch.py b/test/arch/msp430/arch.py
index 3df2becb..08e5bdae 100644
--- a/test/arch/msp430/arch.py
+++ b/test/arch/msp430/arch.py
@@ -95,13 +95,9 @@ for s, l in reg_tests_msp:
     print s
     print mn
     assert(str(mn) == s)
-    # print hex(b)
-    # print [str(x.get()) for x in mn.args]
     l = mn_msp430.fromstring(s, symbol_pool, None)
-    # print l
     assert(str(l) == s)
     a = mn_msp430.asm(l)
     print [x for x in a]
     print repr(b)
-    # print mn.args
     assert(b in a)
diff --git a/test/arch/sh4/arch.py b/test/arch/sh4/arch.py
index 574dcf49..9162fdbc 100644
--- a/test/arch/sh4/arch.py
+++ b/test/arch/sh4/arch.py
@@ -398,15 +398,11 @@ for s, l in reg_tests_sh4:
     print s
     print mn
     assert(str(mn) == s)
-    # print hex(b)
-    # print [str(x.get()) for x in mn.args]
     l = mn_sh4.fromstring(s, symbol_pool, None)
-    # print l
     assert(str(l) == s)
     a = mn_sh4.asm(l)
     print [x for x in a]
     print repr(b)
-    # print mn.args
     assert(b in a)
 
 
diff --git a/test/arch/x86/arch.py b/test/arch/x86/arch.py
index 05b31815..1865ceba 100644
--- a/test/arch/x86/arch.py
+++ b/test/arch/x86/arch.py
@@ -3062,17 +3062,13 @@ for mode, s, l, in reg_tests:
     print s
     print mn
     assert(str(mn).strip() == s)
-    # print hex(b)
-    # print [str(x.get()) for x in mn.args]
     print 'fromstring', repr(s)
     l = mn_x86.fromstring(s, symbol_pool, mode)
-    # print l
     print 'str args', [(str(x), x.size) for x in l.args]
     assert(str(l).strip(' ') == s)
     a = mn_x86.asm(l)
     print 'asm result', [x for x in a]
     print repr(b)
-    # test_file[mode[0]].write(b)
 
     for x in a:
         print "BYTES", repr(x)
@@ -3086,7 +3082,6 @@ for mode, s, l, in reg_tests:
         assert(str(rl).strip(' ') == s)
     print repr(b), a
     assert(b in a)
-    # print mn.args
 print 'TEST time', time.time() - ts
 
 
@@ -3118,9 +3113,7 @@ def profile_dis(o):
     print 'instr per sec:', instr_num / (time.time() - ts)
 
 import cProfile
-# cProfile.run(r'mn_x86.dis("\x81\x54\x18\xfe\x44\x33\x22\x11", m32)')
 cProfile.run('profile_dis(o)')
-# profile_dis(o)
 
 # Test instruction representation with prefix
 instr_bytes = '\x65\xc7\x00\x09\x00\x00\x00'
diff --git a/test/arch/x86/unit/asm_test.py b/test/arch/x86/unit/asm_test.py
index 961967f9..4b802606 100644
--- a/test/arch/x86/unit/asm_test.py
+++ b/test/arch/x86/unit/asm_test.py
@@ -18,9 +18,6 @@ class Asm_Test(object):
         self.myjit = Machine(self.arch_name).jitter(jitter_engine)
         self.myjit.init_stack()
 
-        self.myjit.jit.log_regs = False
-        self.myjit.jit.log_mn = False
-
     def test_init(self):
         pass
 
@@ -81,10 +78,6 @@ class Asm_Test_16(Asm_Test):
         self.myjit.stack_size = 0x1000
         self.myjit.init_stack()
 
-        self.myjit.jit.log_regs = False
-        self.myjit.jit.log_mn = False
-
-
     def init_machine(self):
         self.myjit.vm.add_memory_page(self.run_addr, PAGE_READ | PAGE_WRITE, self.assembly)
         self.myjit.push_uint16_t(self.ret_addr)
diff --git a/test/core/asmblock.py b/test/core/asmblock.py
index c4a97518..0e965bfd 100644
--- a/test/core/asmblock.py
+++ b/test/core/asmblock.py
@@ -247,7 +247,7 @@ assert len(entry_block.lines) == 4
 assert map(str, entry_block.lines) == ['XOR        EAX, EAX',
                                        'XOR        EBX, EBX',
                                        'XOR        ECX, ECX',
-                                       'JNZ        label_3']
+                                       'JNZ        loc_3']
 assert len(asmcfg.successors(entry_block.loc_key)) == 2
 assert len(entry_block.bto) == 2
 nextb = asmcfg.loc_key_to_block((cons.loc_key for cons in entry_block.bto
@@ -258,11 +258,11 @@ assert len(nextb.lines) == 4
 assert map(str, nextb.lines) == ['XOR        EDX, EDX',
                                  'XOR        ESI, ESI',
                                  'XOR        EDI, EDI',
-                                 'JMP        label_4']
+                                 'JMP        loc_4']
 assert asmcfg.successors(nextb.loc_key) == [nextb.loc_key]
 assert len(tob.lines) == 2
 assert map(str, tob.lines) == ['XOR        EBP, EBP',
-                               'JMP        label_3']
+                               'JMP        loc_3']
 assert asmcfg.successors(tob.loc_key) == [tob.loc_key]
 
 # Check split_block
@@ -289,7 +289,7 @@ lbl_newb = asmcfg.successors(entry_block.loc_key)[0]
 newb = asmcfg.loc_key_to_block(lbl_newb)
 assert len(newb.lines) == 2
 assert map(str, newb.lines) == ['XOR        ECX, ECX',
-                                'JNZ        label_3']
+                                'JNZ        loc_3']
 preds = asmcfg.predecessors(lbl_newb)
 assert len(preds) == 2
 assert entry_block.loc_key in preds
diff --git a/test/expression/simplifications.py b/test/expression/simplifications.py
index a4e839cf..b2591a83 100644
--- a/test/expression/simplifications.py
+++ b/test/expression/simplifications.py
@@ -177,6 +177,10 @@ to_test = [(ExprInt(1, 32) - ExprInt(1, 32), ExprInt(0, 32)),
            (ExprInt(0x4142, 32)[:32], ExprInt(0x4142, 32)),
            (ExprInt(0x4142, 32)[:8], ExprInt(0x42, 8)),
            (ExprInt(0x4142, 32)[8:16], ExprInt(0x41, 8)),
+           (ExprOp('>>', ExprOp('<<', a, ExprInt(0x4, 32)), ExprInt(0x4, 32)),
+            ExprOp('&', a, ExprInt(0x0FFFFFFF, 32))),
+           (ExprOp('<<', ExprOp('>>', a, ExprInt(0x4, 32)), ExprInt(0x4, 32)),
+            ExprOp('&', a, ExprInt(0xFFFFFFF0, 32))),
            (a[:32], a),
            (a[:8][:8], a[:8]),
            (a[:16][:8], a[:8]),
diff --git a/test/jitter/bad_block.py b/test/jitter/bad_block.py
index 04c1f475..ae11e696 100644
--- a/test/jitter/bad_block.py
+++ b/test/jitter/bad_block.py
@@ -32,8 +32,7 @@ run_addr = 0x40000000
 
 jitter.vm.add_memory_page(run_addr, PAGE_READ | PAGE_WRITE, data)
 
-jitter.jit.log_regs = True
-jitter.jit.log_mn = True
+jitter.set_trace_log()
 jitter.push_uint32_t(0x1337beef)
 
 jitter.add_breakpoint(0x1337beef, code_sentinelle)
diff --git a/test/jitter/jit_options.py b/test/jitter/jit_options.py
index 4fe936d5..a0ddbc11 100644
--- a/test/jitter/jit_options.py
+++ b/test/jitter/jit_options.py
@@ -33,8 +33,7 @@ def init_jitter():
 
     # Init jitter
     myjit.init_stack()
-    myjit.jit.log_regs = True
-    myjit.jit.log_mn = True
+    myjit.set_trace_log()
     myjit.push_uint32_t(0x1337beef)
 
     myjit.add_breakpoint(0x1337beef, code_sentinelle)
diff --git a/test/jitter/jmp_out_mem.py b/test/jitter/jmp_out_mem.py
index 49da16ad..93ae8304 100644
--- a/test/jitter/jmp_out_mem.py
+++ b/test/jitter/jmp_out_mem.py
@@ -35,8 +35,7 @@ run_addr = 0x40000000
 
 jitter.vm.add_memory_page(run_addr, PAGE_READ | PAGE_WRITE, data)
 
-jitter.jit.log_regs = True
-jitter.jit.log_mn = True
+jitter.set_trace_log()
 jitter.push_uint32_t(0x1337beef)
 
 jitter.add_breakpoint(0x1337beef, code_sentinelle)
diff --git a/test/jitter/test_post_instr.py b/test/jitter/test_post_instr.py
index edf86645..39e87616 100644
--- a/test/jitter/test_post_instr.py
+++ b/test/jitter/test_post_instr.py
@@ -23,8 +23,8 @@ jitter.vm.add_memory_page(0x1000, PAGE_READ|PAGE_WRITE, "\x00"*0x1000, "code pag
 # RET
 jitter.vm.set_mem(0x1000, "B844332211C3".decode('hex'))
 
-jitter.jit.log_mn = True
-jitter.jit.log_regs = True
+
+jitter.set_trace_log()
 
 def do_not_raise_me(jitter):
     raise ValueError("Should not be here")