How to use _run_code method in ATX

Best Python code snippet using ATX

test_transfer.py

Source:test_transfer.py Github

copy

Full Screen

...27class X86TranslationTransferTests(X86TranslationTestCase):28 def test_bswap_1(self):29 asm = ["bswap eax"]30 ctx_init = self._init_context()31 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)32 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)33 if not cmp_result:34 self._save_failing_context(ctx_init)35 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))36 def test_bswap_2(self):37 asm = ["bswap rax"]38 ctx_init = self._init_context()39 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)40 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)41 if not cmp_result:42 self._save_failing_context(ctx_init)43 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))44 def test_cdq(self):45 asm = ["cdq"]46 ctx_init = self._init_context()47 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)48 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)49 if not cmp_result:50 self._save_failing_context(ctx_init)51 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))52 def test_cdqe(self):53 asm = ["cdqe"]54 ctx_init = self._init_context()55 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)56 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)57 if not cmp_result:58 self._save_failing_context(ctx_init)59 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))60 def test_cmova(self):61 asm = ["cmova eax, ebx"]62 ctx_init = self._init_context()63 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)64 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)65 if not cmp_result:66 self._save_failing_context(ctx_init)67 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))68 def test_cmovae(self):69 asm = ["cmovae eax, ebx"]70 ctx_init = self._init_context()71 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)72 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)73 if not cmp_result:74 self._save_failing_context(ctx_init)75 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))76 def test_cmovb(self):77 asm = ["cmovb eax, ebx"]78 ctx_init = self._init_context()79 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)80 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)81 if not cmp_result:82 self._save_failing_context(ctx_init)83 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))84 def test_cmovbe(self):85 asm = ["cmovbe eax, ebx"]86 ctx_init = self._init_context()87 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)88 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)89 if not cmp_result:90 self._save_failing_context(ctx_init)91 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))92 def test_cmovc(self):93 asm = ["cmovc eax, ebx"]94 ctx_init = self._init_context()95 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)96 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)97 if not cmp_result:98 self._save_failing_context(ctx_init)99 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))100 def test_cmove(self):101 asm = ["cmove eax, ebx"]102 ctx_init = self._init_context()103 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)104 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)105 if not cmp_result:106 self._save_failing_context(ctx_init)107 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))108 def test_cmovg(self):109 asm = ["cmovg eax, ebx"]110 ctx_init = self._init_context()111 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)112 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)113 if not cmp_result:114 self._save_failing_context(ctx_init)115 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))116 def test_cmovge(self):117 asm = ["cmovge eax, ebx"]118 ctx_init = self._init_context()119 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)120 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)121 if not cmp_result:122 self._save_failing_context(ctx_init)123 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))124 def test_cmovl(self):125 asm = ["cmovl eax, ebx"]126 ctx_init = self._init_context()127 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)128 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)129 if not cmp_result:130 self._save_failing_context(ctx_init)131 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))132 def test_cmovle(self):133 asm = ["cmovle eax, ebx"]134 ctx_init = self._init_context()135 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)136 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)137 if not cmp_result:138 self._save_failing_context(ctx_init)139 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))140 def test_cmovna(self):141 asm = ["cmovna eax, ebx"]142 ctx_init = self._init_context()143 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)144 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)145 if not cmp_result:146 self._save_failing_context(ctx_init)147 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))148 def test_cmovnae(self):149 asm = ["cmovnae eax, ebx"]150 ctx_init = self._init_context()151 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)152 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)153 if not cmp_result:154 self._save_failing_context(ctx_init)155 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))156 def test_cmovnb(self):157 asm = ["cmovnb eax, ebx"]158 ctx_init = self._init_context()159 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)160 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)161 if not cmp_result:162 self._save_failing_context(ctx_init)163 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))164 def test_cmovnbe(self):165 asm = ["cmovnbe eax, ebx"]166 ctx_init = self._init_context()167 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)168 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)169 if not cmp_result:170 self._save_failing_context(ctx_init)171 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))172 def test_cmovnc(self):173 asm = ["cmovnc eax, ebx"]174 ctx_init = self._init_context()175 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)176 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)177 if not cmp_result:178 self._save_failing_context(ctx_init)179 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))180 def test_cmovne(self):181 asm = ["cmovne eax, ebx"]182 ctx_init = self._init_context()183 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)184 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)185 if not cmp_result:186 self._save_failing_context(ctx_init)187 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))188 def test_cmovng(self):189 asm = ["cmovng eax, ebx"]190 ctx_init = self._init_context()191 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)192 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)193 if not cmp_result:194 self._save_failing_context(ctx_init)195 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))196 def test_cmovnge(self):197 asm = ["cmovnge eax, ebx"]198 ctx_init = self._init_context()199 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)200 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)201 if not cmp_result:202 self._save_failing_context(ctx_init)203 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))204 def test_cmovnl(self):205 asm = ["cmovnl eax, ebx"]206 ctx_init = self._init_context()207 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)208 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)209 if not cmp_result:210 self._save_failing_context(ctx_init)211 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))212 def test_cmovnle(self):213 asm = ["cmovnle eax, ebx"]214 ctx_init = self._init_context()215 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)216 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)217 if not cmp_result:218 self._save_failing_context(ctx_init)219 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))220 def test_cmovno(self):221 asm = ["cmovno eax, ebx"]222 ctx_init = self._init_context()223 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)224 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)225 if not cmp_result:226 self._save_failing_context(ctx_init)227 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))228 def test_cmovnp(self):229 asm = ["cmovnp eax, ebx"]230 ctx_init = self._init_context()231 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)232 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)233 if not cmp_result:234 self._save_failing_context(ctx_init)235 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))236 def test_cmovns(self):237 asm = ["cmovns eax, ebx"]238 ctx_init = self._init_context()239 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)240 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)241 if not cmp_result:242 self._save_failing_context(ctx_init)243 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))244 def test_cmovnz(self):245 asm = ["cmovnz eax, ebx"]246 ctx_init = self._init_context()247 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)248 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)249 if not cmp_result:250 self._save_failing_context(ctx_init)251 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))252 def test_cmovo(self):253 asm = ["cmovo eax, ebx"]254 ctx_init = self._init_context()255 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)256 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)257 if not cmp_result:258 self._save_failing_context(ctx_init)259 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))260 def test_cmovp(self):261 asm = ["cmovp eax, ebx"]262 ctx_init = self._init_context()263 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)264 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)265 if not cmp_result:266 self._save_failing_context(ctx_init)267 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))268 def test_cmovpe(self):269 asm = ["cmovpe eax, ebx"]270 ctx_init = self._init_context()271 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)272 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)273 if not cmp_result:274 self._save_failing_context(ctx_init)275 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))276 def test_cmovpo(self):277 asm = ["cmovpo eax, ebx"]278 ctx_init = self._init_context()279 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)280 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)281 if not cmp_result:282 self._save_failing_context(ctx_init)283 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))284 def test_cmovs(self):285 asm = ["cmovs eax, ebx"]286 ctx_init = self._init_context()287 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)288 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)289 if not cmp_result:290 self._save_failing_context(ctx_init)291 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))292 def test_cmovz(self):293 asm = ["cmovz eax, ebx"]294 ctx_init = self._init_context()295 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)296 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)297 if not cmp_result:298 self._save_failing_context(ctx_init)299 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))300 def test_cmpxchg(self):301 asm = ["cmpxchg ebx, ecx"]302 ctx_init = self._init_context()303 _, x86_ctx_out = pyasmjit.x86_64_execute("\n".join(asm), ctx_init)304 reil_ctx_out, _ = self.reil_emulator.execute(305 self._asm_to_reil(asm, 0xdeadbeef),306 start=0xdeadbeef << 8,307 end=(0xdeadbeef + 0x1) << 8,308 registers=ctx_init309 )310 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)311 if not cmp_result:312 self._save_failing_context(ctx_init)313 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))314 def test_mov_1(self):315 asm = ["mov eax, ebx"]316 ctx_init = self._init_context()317 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)318 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)319 if not cmp_result:320 self._save_failing_context(ctx_init)321 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))322 def test_mov_2(self):323 asm = ["mov eax, eax"]324 ctx_init = self._init_context()325 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)326 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)327 if not cmp_result:328 self._save_failing_context(ctx_init)329 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))330 def test_movabs(self):331 # TODO: Implement.332 pass333 def test_movsx(self):334 asm = ["movsx eax, bx"]335 ctx_init = self._init_context()336 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)337 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)338 if not cmp_result:339 self._save_failing_context(ctx_init)340 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))341 def test_movsxd(self):342 # TODO: Implement.343 pass344 def test_movzx_1(self):345 asm = ["movzx eax, bx"]346 ctx_init = self._init_context()347 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)348 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)349 if not cmp_result:350 self._save_failing_context(ctx_init)351 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))352 def test_movzx_2(self):353 asm = ["movzx eax, al"]354 ctx_init = self._init_context()355 ctx_init["rax"] = 0x1356 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)357 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)358 if not cmp_result:359 self._save_failing_context(ctx_init)360 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))361 def test_pop(self):362 # TODO: Implement.363 pass364 def test_push(self):365 # TODO: Implement.366 pass367 def test_seta(self):368 asm = ["seta al"]369 ctx_init = self._init_context()370 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)371 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)372 if not cmp_result:373 self._save_failing_context(ctx_init)374 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))375 def test_setae(self):376 asm = ["setae al"]377 ctx_init = self._init_context()378 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)379 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)380 if not cmp_result:381 self._save_failing_context(ctx_init)382 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))383 def test_setb(self):384 asm = ["setb al"]385 ctx_init = self._init_context()386 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)387 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)388 if not cmp_result:389 self._save_failing_context(ctx_init)390 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))391 def test_setbe(self):392 asm = ["setbe al"]393 ctx_init = self._init_context()394 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)395 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)396 if not cmp_result:397 self._save_failing_context(ctx_init)398 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))399 def test_setc(self):400 asm = ["setc al"]401 ctx_init = self._init_context()402 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)403 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)404 if not cmp_result:405 self._save_failing_context(ctx_init)406 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))407 def test_sete(self):408 asm = ["sete al"]409 ctx_init = self._init_context()410 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)411 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)412 if not cmp_result:413 self._save_failing_context(ctx_init)414 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))415 def test_setg(self):416 asm = ["setg al"]417 ctx_init = self._init_context()418 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)419 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)420 if not cmp_result:421 self._save_failing_context(ctx_init)422 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))423 def test_setge(self):424 asm = ["setge al"]425 ctx_init = self._init_context()426 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)427 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)428 if not cmp_result:429 self._save_failing_context(ctx_init)430 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))431 def test_setl(self):432 asm = ["setl al"]433 ctx_init = self._init_context()434 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)435 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)436 if not cmp_result:437 self._save_failing_context(ctx_init)438 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))439 def test_setle(self):440 asm = ["setle al"]441 ctx_init = self._init_context()442 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)443 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)444 if not cmp_result:445 self._save_failing_context(ctx_init)446 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))447 def test_setna(self):448 asm = ["setna al"]449 ctx_init = self._init_context()450 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)451 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)452 if not cmp_result:453 self._save_failing_context(ctx_init)454 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))455 def test_setnae(self):456 asm = ["setnae al"]457 ctx_init = self._init_context()458 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)459 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)460 if not cmp_result:461 self._save_failing_context(ctx_init)462 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))463 def test_setnb(self):464 asm = ["setnb al"]465 ctx_init = self._init_context()466 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)467 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)468 if not cmp_result:469 self._save_failing_context(ctx_init)470 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))471 def test_setnbe(self):472 asm = ["setnbe al"]473 ctx_init = self._init_context()474 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)475 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)476 if not cmp_result:477 self._save_failing_context(ctx_init)478 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))479 def test_setnc(self):480 asm = ["setnc al"]481 ctx_init = self._init_context()482 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)483 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)484 if not cmp_result:485 self._save_failing_context(ctx_init)486 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))487 def test_setne(self):488 asm = ["setne al"]489 ctx_init = self._init_context()490 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)491 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)492 if not cmp_result:493 self._save_failing_context(ctx_init)494 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))495 def test_setng(self):496 asm = ["setng al"]497 ctx_init = self._init_context()498 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)499 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)500 if not cmp_result:501 self._save_failing_context(ctx_init)502 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))503 def test_setnge(self):504 asm = ["setnge al"]505 ctx_init = self._init_context()506 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)507 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)508 if not cmp_result:509 self._save_failing_context(ctx_init)510 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))511 def test_setnl(self):512 asm = ["setnl al"]513 ctx_init = self._init_context()514 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)515 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)516 if not cmp_result:517 self._save_failing_context(ctx_init)518 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))519 def test_setnle(self):520 asm = ["setnle al"]521 ctx_init = self._init_context()522 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)523 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)524 if not cmp_result:525 self._save_failing_context(ctx_init)526 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))527 def test_setno(self):528 asm = ["setno al"]529 ctx_init = self._init_context()530 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)531 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)532 if not cmp_result:533 self._save_failing_context(ctx_init)534 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))535 def test_setnp(self):536 asm = ["setnp al"]537 ctx_init = self._init_context()538 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)539 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)540 if not cmp_result:541 self._save_failing_context(ctx_init)542 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))543 def test_setns(self):544 asm = ["setns al"]545 ctx_init = self._init_context()546 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)547 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)548 if not cmp_result:549 self._save_failing_context(ctx_init)550 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))551 def test_setnz(self):552 asm = ["setnz al"]553 ctx_init = self._init_context()554 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)555 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)556 if not cmp_result:557 self._save_failing_context(ctx_init)558 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))559 def test_seto(self):560 asm = ["seto al"]561 ctx_init = self._init_context()562 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)563 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)564 if not cmp_result:565 self._save_failing_context(ctx_init)566 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))567 def test_setp(self):568 asm = ["setp al"]569 ctx_init = self._init_context()570 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)571 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)572 if not cmp_result:573 self._save_failing_context(ctx_init)574 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))575 def test_setpe(self):576 asm = ["setpe al"]577 ctx_init = self._init_context()578 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)579 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)580 if not cmp_result:581 self._save_failing_context(ctx_init)582 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))583 def test_setpo(self):584 asm = ["setpo al"]585 ctx_init = self._init_context()586 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)587 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)588 if not cmp_result:589 self._save_failing_context(ctx_init)590 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))591 def test_sets(self):592 asm = ["sets al"]593 ctx_init = self._init_context()594 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)595 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)596 if not cmp_result:597 self._save_failing_context(ctx_init)598 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))599 def test_setz(self):600 asm = ["setz al"]601 ctx_init = self._init_context()602 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)603 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)604 if not cmp_result:605 self._save_failing_context(ctx_init)606 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))607 def test_xadd_1(self):608 asm = ["add eax, ebx"]609 ctx_init = self._init_context()610 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)611 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)612 if not cmp_result:613 self._save_failing_context(ctx_init)614 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))615 def test_xadd_2(self):616 asm = ["add rax, rbx"]617 ctx_init = self._init_context()618 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)619 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)620 if not cmp_result:621 self._save_failing_context(ctx_init)622 self.assertTrue(cmp_result, self._print_contexts(ctx_init, x86_ctx_out, reil_ctx_out))623 def test_xchg(self):624 asm = ["xchg eax, ebx"]625 ctx_init = self._init_context()626 x86_ctx_out, reil_ctx_out = self._run_code(asm, 0xdeadbeef, ctx_init)627 cmp_result = self._compare_contexts(ctx_init, x86_ctx_out, reil_ctx_out)628 if not cmp_result:629 self._save_failing_context(ctx_init)...

Full Screen

Full Screen

clock.py

Source:clock.py Github

copy

Full Screen

1# -----------------------------------------------------------------------------2# pyDM404 - A cross platform Drum Sequencer3# Author: Scott Taber4# File: clock.py - Contains the Clock class for controlling the timer process5#6# modified from https://github.com/ElliotGarbus/MidiClockGenerator7# -----------------------------------------------------------------------------8from time import perf_counter, sleep, time9from multiprocessing import Process, Value10class ClockGen:11 def __init__(self):12 self.shared_bpm = Value('f', 60)13 self._run_code = Value('i', 1) # used to stop midiClock from main process14 self.clock_process = None15 @staticmethod16 def _clock_generator(out_port, bpm, run):17 while run.value:18 pulse_rate = 60.0 / (bpm.value * 24)19 out_port.send(1)20 t1 = perf_counter()21 if bpm.value <= 3000:22 sleep(pulse_rate * 0.8)23 t2 = perf_counter()24 while (t2 - t1) < pulse_rate:25 t2 = perf_counter()26 def launch_process(self, out_port):27 if self.clock_process: # if the process exists, close prior to creating a new one28 self.end_process()29 30 self._run_code.value = 131 self.clock_process = Process(target=self._clock_generator,32 args=(out_port, self.shared_bpm, self._run_code),33 name='midi-background')34 self.clock_process.start()35 def end_process(self):36 self._run_code.value = 037 self.clock_process.join()...

Full Screen

Full Screen

test_libversioning.py

Source:test_libversioning.py Github

copy

Full Screen

1import unittest2from databutler.utils import multiprocess3from databutler.utils.libversioning import modified_lib_env4def _run_code(code: str, lib_name: str, version: str):5 with modified_lib_env(lib_name, version):6 exec(code)7class LibVersioningTests(unittest.TestCase):8 def test_pandas_1(self):9 # df.ftypes was removed in Pandas 1.* but was only deprecated in 0.25.010 code = (11 "import sys; print(sys.path)\n"12 "import pandas as pd\n"13 "assert pd.__version__ == '0.25.1'"14 )15 multiprocess.run_func_in_process(_run_code, code, "pandas", "0.25.1")16 self.assertRaises(17 AssertionError,18 multiprocess.run_func_in_process,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ATX automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful