<s> import os <EOL> import pickle <EOL> import platform <EOL> import random <EOL> import unittest <EOL> import pyasmjit <EOL> from barf . arch import ARCH_X86_MODE_64 <EOL> from barf . arch . x86 . x86base import X86ArchitectureInformation <EOL> from barf . arch . x86 . x86parser import X86Parser <EOL> from barf . arch . x86 . x86translator import FULL_TRANSLATION <EOL> from barf . arch . x86 . x86translator import X86Translator <EOL> from barf . core . reil import ReilContainer <EOL> from barf . core . reil import ReilEmulator <EOL> from barf . core . reil import ReilSequence <EOL> @ unittest . skipUnless ( platform . machine ( ) . lower ( ) == '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> class X86TranslationTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . arch_mode = ARCH_X86_MODE_64 <EOL> self . arch_info = X86ArchitectureInformation ( self . arch_mode ) <EOL> self . x86_parser = X86Parser ( self . arch_mode ) <EOL> self . x86_translator = X86Translator ( self . arch_mode , FULL_TRANSLATION ) <EOL> self . reil_emulator = ReilEmulator ( self . arch_info ) <EOL> self . context_filename = "<STR_LIT>" <EOL> def test_cdqe ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_lea ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cld ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_clc ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_nop ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_test ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_not ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_xor ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_or ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_and ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmp ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_neg ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_dec ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_inc ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_div_1 ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_div_2 ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_div_3 ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_div_4 ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_div_5 ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_idiv_1 ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_idiv_2 ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_idiv_3 ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_idiv_3 ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_idiv_4 ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_idiv_5 ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_mul ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_sbb ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_sub ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_adc ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_add ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_xchg ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_movzx ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_mov ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmova ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovae ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovb ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovbe ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovc ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmove ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovg ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovge ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovl ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovle ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovna ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovnae ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovnb ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovnbe ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovnc ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovne ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovng ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovnge ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovnl ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovnle ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovno ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovnp ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovns ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovnz ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovo ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovp ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovpe ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovpo ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovs ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmovz ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_seta ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setae ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setb ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setbe ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setc ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_sete ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setg ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setge ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setl ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setle ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setna ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setnae ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setnb ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setnbe ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setnc ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setne ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setng ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setnge ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setnl ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setnle ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setno ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setnp ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setns ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setnz ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_seto ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setp ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setpe ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setpo ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_sets ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_setz ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_all_jcc ( self ) : <EOL> conds = [ <EOL> '<STR_LIT:a>' , '<STR_LIT>' , '<STR_LIT:b>' , '<STR_LIT>' , '<STR_LIT:c>' , '<STR_LIT:e>' , '<STR_LIT:g>' , '<STR_LIT>' , '<STR_LIT:l>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:o>' , '<STR_LIT:p>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:s>' , '<STR_LIT:z>' <EOL> ] <EOL> for c in conds : <EOL> self . __test_jcc ( c ) <EOL> def __test_jcc ( self , jmp_cond ) : <EOL> untouched_value = <NUM_LIT> <EOL> touched_value = <NUM_LIT> <EOL> asm = [ <EOL> "<STR_LIT>" . format ( untouched_value ) , <EOL> "<STR_LIT>" + jmp_cond + "<STR_LIT>" , <EOL> "<STR_LIT>" . format ( touched_value ) , <EOL> "<STR_LIT>" , <EOL> ] <EOL> asm_reil = list ( asm ) <EOL> asm_reil [ <NUM_LIT:1> ] = asm_reil [ <NUM_LIT:1> ] . format ( str ( <NUM_LIT> + <NUM_LIT> ) ) <EOL> asm_pyasmjit = list ( asm ) <EOL> asm_pyasmjit [ <NUM_LIT:1> ] = asm_pyasmjit [ <NUM_LIT:1> ] . format ( "<STR_LIT>" ) <EOL> reil_instrs = self . __asm_to_reil ( asm_reil , <NUM_LIT> ) <EOL> ctx_init = self . __init_context ( ) <EOL> _ , x86_ctx_out = pyasmjit . x86_execute ( "<STR_LIT:\n>" . join ( asm_pyasmjit ) , ctx_init ) <EOL> reil_ctx_out , _ = self . reil_emulator . execute ( <EOL> reil_instrs , <EOL> start = <NUM_LIT> << <NUM_LIT:8> , <EOL> registers = ctx_init <EOL> ) <EOL> reil_ctx_out = self . __fix_reil_flags ( reil_ctx_out , x86_ctx_out ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_shr ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_shl ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_sal ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_sar ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_stc ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_rol ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_ror ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_rcl ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> ctx_init [ '<STR_LIT>' ] = ctx_init [ '<STR_LIT>' ] | <NUM_LIT> <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_rcr ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> ctx_init [ '<STR_LIT>' ] = ctx_init [ '<STR_LIT>' ] | <NUM_LIT> <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_bt ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> reil_ctx_out = self . __fix_reil_flag ( reil_ctx_out , x86_ctx_out , "<STR_LIT>" ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_cmpxchg ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> _ , x86_ctx_out = pyasmjit . x86_execute ( "<STR_LIT:\n>" . join ( asm ) , ctx_init ) <EOL> reil_ctx_out , _ = self . reil_emulator . execute ( <EOL> self . __asm_to_reil ( asm , <NUM_LIT> ) , <EOL> start = <NUM_LIT> << <NUM_LIT:8> , <EOL> end = ( <NUM_LIT> + <NUM_LIT> ) << <NUM_LIT:8> , <EOL> registers = ctx_init <EOL> ) <EOL> reil_ctx_out = self . __fix_reil_flags ( reil_ctx_out , x86_ctx_out ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_movsx ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def test_sahf ( self ) : <EOL> asm = [ "<STR_LIT>" ] <EOL> ctx_init = self . __init_context ( ) <EOL> ctx_init [ '<STR_LIT>' ] = <NUM_LIT> <EOL> flags_mapper = { <EOL> <NUM_LIT:0> : "<STR_LIT>" , <EOL> <NUM_LIT:2> : "<STR_LIT>" , <EOL> <NUM_LIT:4> : "<STR_LIT>" , <EOL> <NUM_LIT:6> : "<STR_LIT>" , <EOL> <NUM_LIT:7> : "<STR_LIT>" , <EOL> } <EOL> for bit , _ in flags_mapper . items ( ) : <EOL> ctx_init [ '<STR_LIT>' ] = ctx_init [ '<STR_LIT>' ] & ( ( ~ <NUM_LIT:2> ** bit ) & <NUM_LIT:2> ** <NUM_LIT:64> - <NUM_LIT:1> ) <EOL> x86_ctx_out , reil_ctx_out = self . __run_code ( asm , <NUM_LIT> , ctx_init ) <EOL> cmp_result = self . __compare_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) <EOL> if not cmp_result : <EOL> self . __save_failing_context ( ctx_init ) <EOL> self . assertTrue ( cmp_result , self . __print_contexts ( ctx_init , x86_ctx_out , reil_ctx_out ) ) <EOL> def __init_context ( self ) : <EOL> """<STR_LIT>""" <EOL> if os . path . isfile ( self . context_filename ) : <EOL> context = self . __load_failing_context ( ) <EOL> else : <EOL> context = self . __create_random_context ( ) <EOL> return context <EOL> def __create_random_context ( self ) : <EOL> context = { } <EOL> for reg in self . arch_info . registers_gp_base : <EOL> if reg not in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> min_value , max_value = <NUM_LIT:0> , <NUM_LIT:2> ** self . arch_info . operand_size - <NUM_LIT:1> <EOL> context [ reg ] = random . randint ( min_value , max_value ) <EOL> context [ '<STR_LIT>' ] = self . __create_random_flags ( ) <EOL> return context <EOL> def __create_random_flags ( self ) : <EOL> flags_mapper = { <EOL> <NUM_LIT:0> : "<STR_LIT>" , <EOL> <NUM_LIT:2> : "<STR_LIT>" , <EOL> <NUM_LIT:4> : "<STR_LIT>" , <EOL> <NUM_LIT:6> : "<STR_LIT>" , <EOL> <NUM_LIT:7> : "<STR_LIT>" , <EOL> <NUM_LIT:11> : "<STR_LIT>" , <EOL> } <EOL> flags = <NUM_LIT> <EOL> for bit , _ in flags_mapper . items ( ) : <EOL> flags = flags | ( <NUM_LIT:2> ** bit * random . randint ( <NUM_LIT:0> , <NUM_LIT:1> ) ) <EOL> return flags <EOL> def __load_failing_context ( self ) : <EOL> f = open ( self . context_filename , "<STR_LIT:rb>" ) <EOL> context = pickle . load ( f ) <EOL> f . close ( ) <EOL> return context <EOL> def __save_failing_context ( self , context ) : <EOL> f = open ( self . context_filename , "<STR_LIT:wb>" ) <EOL> pickle . dump ( context , f ) <EOL> f . close ( ) <EOL> def __compare_contexts ( self , context_init , x86_context , reil_context ) : <EOL> match = True <EOL> mask = <NUM_LIT:2> ** <NUM_LIT:64> - <NUM_LIT:1> <EOL> for reg in sorted ( context_init . keys ( ) ) : <EOL> if ( x86_context [ reg ] & mask ) != ( reil_context [ reg ] & mask ) : <EOL> match = False <EOL> break <EOL> return match <EOL> def __print_contexts ( self , context_init , x86_context , reil_context ) : <EOL> out = "<STR_LIT>" <EOL> header_fmt = "<STR_LIT>" <EOL> header = header_fmt . format ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> ruler = "<STR_LIT:->" * len ( header ) + "<STR_LIT:\n>" <EOL> out += header <EOL> out += ruler <EOL> fmt = "<STR_LIT>" <EOL> mask = <NUM_LIT:2> ** <NUM_LIT:64> - <NUM_LIT:1> <EOL> for reg in sorted ( context_init . keys ( ) ) : <EOL> if ( x86_context [ reg ] & mask ) != ( reil_context [ reg ] & mask ) : <EOL> eq , marker = "<STR_LIT>" , "<STR_LIT:<>" <EOL> else : <EOL> eq , marker = "<STR_LIT>" , "<STR_LIT>" <EOL> out += fmt . format ( <EOL> reg , <EOL> context_init [ reg ] & mask , <EOL> x86_context [ reg ] & mask , <EOL> reil_context [ reg ] & mask , <EOL> eq = eq , <EOL> marker = marker <EOL> ) <EOL> reg = "<STR_LIT>" <EOL> fmt = "<STR_LIT>" <EOL> init_value = context_init [ reg ] & mask <EOL> x86_value = x86_context [ reg ] & mask <EOL> reil_value = reil_context [ reg ] & mask <EOL> init_flags_str = self . __print_flags ( context_init [ reg ] ) <EOL> x86_flags_str = self . __print_flags ( x86_context [ reg ] ) <EOL> reil_flags_str = self . __print_flags ( reil_context [ reg ] ) <EOL> out += "<STR_LIT:\n>" <EOL> out += fmt . format ( reg , "<STR_LIT>" , init_value , init_flags_str ) + "<STR_LIT:\n>" <EOL> out += fmt . format ( reg , "<STR_LIT>" , x86_value , x86_flags_str ) + "<STR_LIT:\n>" <EOL> out += fmt . format ( reg , "<STR_LIT>" , reil_value , reil_flags_str ) <EOL> return out <EOL> def __print_registers ( self , registers ) : <EOL> out = "<STR_LIT>" <EOL> header_fmt = "<STR_LIT>" <EOL> header = header_fmt . format ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ruler = "<STR_LIT:->" * len ( header ) + "<STR_LIT:\n>" <EOL> out += header <EOL> out += ruler <EOL> fmt = "<STR_LIT>" <EOL> for reg in sorted ( registers . keys ( ) ) : <EOL> out += fmt . format ( reg , registers [ reg ] ) <EOL> print ( out ) <EOL> def __print_flags ( self , flags ) : <EOL> flags_mapper = { <EOL> <NUM_LIT:0> : "<STR_LIT>" , <EOL> <NUM_LIT:2> : "<STR_LIT>" , <EOL> <NUM_LIT:4> : "<STR_LIT>" , <EOL> <NUM_LIT:6> : "<STR_LIT>" , <EOL> <NUM_LIT:7> : "<STR_LIT>" , <EOL> <NUM_LIT:10> : "<STR_LIT>" , <EOL> <NUM_LIT:11> : "<STR_LIT>" , <EOL> } <EOL> out = "<STR_LIT>" <EOL> for bit , flag in flags_mapper . items ( ) : <EOL> flag_str = flag . upper ( ) if flags & <NUM_LIT:2> ** bit else flag . lower ( ) <EOL> out += flag_str + "<STR_LIT:U+0020>" <EOL> return out [ : - <NUM_LIT:1> ] <EOL> def __fix_reil_flag ( self , reil_context , x86_context , flag ) : <EOL> reil_context_out = dict ( reil_context ) <EOL> flags_reg = '<STR_LIT>' if '<STR_LIT>' in reil_context_out else '<STR_LIT>' <EOL> _ , bit = self . arch_info . alias_mapper [ flag ] <EOL> reil_context_out [ flags_reg ] &= ~ ( <NUM_LIT:2> ** bit ) & ( <NUM_LIT:2> ** <NUM_LIT:32> - <NUM_LIT:1> ) <EOL> reil_context_out [ flags_reg ] |= ( x86_context [ flags_reg ] & <NUM_LIT:2> ** bit ) <EOL> return reil_context_out <EOL> def __fix_reil_flags ( self , reil_context , x86_context ) : <EOL> reil_context_out = dict ( reil_context ) <EOL> reil_context_out = self . __fix_reil_flag ( reil_context_out , x86_context , "<STR_LIT>" ) <EOL> reil_context_out = self . __fix_reil_flag ( reil_context_out , x86_context , "<STR_LIT>" ) <EOL> return reil_context_out <EOL> def __set_address ( self , address , x86_instrs ) : <EOL> addr = address <EOL> for x86_instr in x86_instrs : <EOL> x86_instr . address = addr <EOL> x86_instr . size = <NUM_LIT:1> <EOL> addr += <NUM_LIT:1> <EOL> def __translate ( self , asm_instrs ) : <EOL> instr_container = ReilContainer ( ) <EOL> asm_instr_last = None <EOL> instr_seq_prev = None <EOL> for asm_instr in asm_instrs : <EOL> instr_seq = ReilSequence ( ) <EOL> for reil_instr in self . x86_translator . translate ( asm_instr ) : <EOL> instr_seq . append ( reil_instr ) <EOL> if instr_seq_prev : <EOL> instr_seq_prev . next_sequence_address = instr_seq . address <EOL> instr_container . add ( instr_seq ) <EOL> instr_seq_prev = instr_seq <EOL> if instr_seq_prev : <EOL> if asm_instr_last : <EOL> instr_seq_prev . next_sequence_address = ( asm_instr_last . address + asm_instr_last . size ) << <NUM_LIT:8> <EOL> return instr_container <EOL> def __asm_to_reil ( self , asm_list , address ) : <EOL> x86_instrs = [ self . x86_parser . parse ( asm ) for asm in asm_list ] <EOL> self . __set_address ( address , x86_instrs ) <EOL> reil_instrs = self . __translate ( x86_instrs ) <EOL> return reil_instrs <EOL> def __run_code ( self , asm_list , address , ctx_init ) : <EOL> reil_instrs = self . __asm_to_reil ( asm_list , address ) <EOL> _ , x86_ctx_out = pyasmjit . x86_execute ( "<STR_LIT:\n>" . join ( asm_list ) , ctx_init ) <EOL> reil_ctx_out , _ = self . reil_emulator . execute ( reil_instrs , start = address << <NUM_LIT:8> , registers = ctx_init ) <EOL> reil_ctx_out = self . __fix_reil_flags ( reil_ctx_out , x86_ctx_out ) <EOL> return x86_ctx_out , reil_ctx_out <EOL> def main ( ) : <EOL> unittest . main ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
