diff options
| -rw-r--r-- | test/ir/ir2C.py | 2 | ||||
| -rw-r--r-- | test/samples/x86_32/bsr_bsf.S | 42 | ||||
| -rw-r--r-- | test/test_all.py | 8 |
3 files changed, 50 insertions, 2 deletions
diff --git a/test/ir/ir2C.py b/test/ir/ir2C.py index 1089bba4..11b9b10e 100644 --- a/test/ir/ir2C.py +++ b/test/ir/ir2C.py @@ -37,7 +37,7 @@ class TestIrIr2C(unittest.TestCase): self.translationTest( ExprOp('-', *args[:2]), r'(((0x0&0xffffffff) - (0x1&0xffffffff))&0xffffffff)') self.translationTest( - ExprOp('bsr', *args[:2]), r'my_bsr(0x0, 0x1)') + ExprOp('bsr', *args[:1]), r'x86_bsr(0x0, 0x20)') self.translationTest( ExprOp('cpuid0', *args[:2]), r'cpuid0(0x0, 0x1)') self.translationTest( diff --git a/test/samples/x86_32/bsr_bsf.S b/test/samples/x86_32/bsr_bsf.S new file mode 100644 index 00000000..0f915ed1 --- /dev/null +++ b/test/samples/x86_32/bsr_bsf.S @@ -0,0 +1,42 @@ +main: + ;; BSF + ;; standard case + MOV ECX, 0xF0000004 + MOV EAX, 0x0 + BSF EAX, ECX + JZ bad + CMP EAX, 2 + JNZ bad + + + ;; case undef + MOV ECX, 0x0 + MOV EAX, 0x1337beef + BSF EAX, ECX + JNZ bad + CMP EAX, 0x1337beef + JNZ bad + + ;; BSR + ;; standard case + MOV ECX, 0x4000000F + MOV EAX, 0x0 + BSR EAX, ECX + JZ bad + CMP EAX, 30 + JNZ bad + + + ;; case undef + MOV ECX, 0x0 + MOV EAX, 0x1337beef + BSR EAX, ECX + JNZ bad + CMP EAX, 0x1337beef + JNZ bad + + RET + +bad: + INT 0x3 + RET diff --git a/test/test_all.py b/test/test_all.py index a2fd6df3..1e5de442 100644 --- a/test/test_all.py +++ b/test/test_all.py @@ -68,7 +68,9 @@ class SemanticTestAsm(RegressionTest): class SemanticTestExec(RegressionTest): """Execute a binary file""" - launcher_dct = {("PE", "x86_64"): "sandbox_pe_x86_64.py"} + launcher_dct = {("PE", "x86_64"): "sandbox_pe_x86_64.py", + ("PE", "x86_32"): "sandbox_pe_x86_32.py", + } launcher_base = os.path.join("..", "example", "jitter") def __init__(self, arch, container, address, *args, **kwargs): @@ -86,9 +88,13 @@ class SemanticTestExec(RegressionTest): test_x86_64_mul_div = SemanticTestAsm("x86_64", "PE", ["mul_div"]) +test_x86_32_bsr_bsf = SemanticTestAsm("x86_32", "PE", ["bsr_bsf"]) testset += test_x86_64_mul_div +testset += test_x86_32_bsr_bsf testset += SemanticTestExec("x86_64", "PE", 0x401000, ["mul_div"], depends=[test_x86_64_mul_div]) +testset += SemanticTestExec("x86_32", "PE", 0x401000, ["bsr_bsf"], + depends=[test_x86_32_bsr_bsf]) ## Core for script in ["interval.py", |