diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/arch/x86/qemu/testqemu.py | 36 | ||||
| -rw-r--r-- | test/arch/x86/qemu/testqemu64.py | 32 | ||||
| -rwxr-xr-x | test/os_dep/linux/stdlib.py | 2 | ||||
| -rwxr-xr-x | test/os_dep/win_api_x86_32.py | 2 |
4 files changed, 36 insertions, 36 deletions
diff --git a/test/arch/x86/qemu/testqemu.py b/test/arch/x86/qemu/testqemu.py index 99d6e6c1..594a826b 100644 --- a/test/arch/x86/qemu/testqemu.py +++ b/test/arch/x86/qemu/testqemu.py @@ -16,24 +16,24 @@ from miasm.jitter.csts import PAGE_READ, PAGE_WRITE # Utils def parse_fmt(s): - fmt = s[:]+b"\x00" + fmt = s[:]+"\x00" out = [] i = 0 while i < len(fmt): c = fmt[i:i+1] - if c != b"%": + if c != "%": i+=1 continue - if fmt[i+1:i+2] == b"%": + if fmt[i+1:i+2] == "%": i+=2 continue j = 0 i+=1 - while fmt[i+j:i+j+1] in b"0123456789$.-": + while fmt[i+j:i+j+1] in "0123456789$.-": j+=1 - if fmt[i+j:i+j+1] in [b'l']: + if fmt[i+j:i+j+1] in ['l']: j +=1 - if fmt[i+j:i+j+1] == b"h": + if fmt[i+j:i+j+1] == "h": x = fmt[i+j:i+j+2] else: x = fmt[i+j:i+j+1] @@ -50,8 +50,8 @@ def xxx___printf_chk(jitter): raise RuntimeError("Not implemented") fmt = jitter.get_str_ansi(args.format) # Manage llx - fmt = fmt.replace(b"llx", b"lx") - fmt = fmt.replace(b"%016lx", b"%016z") + fmt = fmt.replace("llx", "lx") + fmt = fmt.replace("%016lx", "%016z") fmt_a = parse_fmt(fmt) esp = jitter.cpu.ESP @@ -59,15 +59,15 @@ def xxx___printf_chk(jitter): i = 0 for x in fmt_a: a = jitter.vm.get_u32(esp + 8 + 4*i) - if x == b"s": + if x == "s": a = jitter.get_str_ansi(a) - elif x in (b"x", b'X', b"d"): + elif x in ("x", 'X', "d"): pass - elif x.lower() in (b"f", b"l"): + elif x.lower() in ("f", "l"): a2 = jitter.vm.get_u32(esp + 8 + 4*(i+1)) a = struct.unpack("d", struct.pack("Q", a2 << 32 | a))[0] i += 1 - elif x.lower() == b'z': + elif x.lower() == 'z': a2 = jitter.vm.get_u32(esp + 8 + 4*(i+1)) a = a2 << 32 | a i += 1 @@ -75,22 +75,22 @@ def xxx___printf_chk(jitter): raise RuntimeError("Not implemented format") args.append(a) i += 1 - fmt = fmt.replace(b"%016z", b"%016lx") + fmt = fmt.replace("%016z", "%016lx") output = fmt%(tuple(args)) # NaN bad repr in Python - output = output.replace(b"nan", b"-nan") + output = output.replace("nan", "-nan") - if b"\n" not in output: + if "\n" not in output: raise RuntimeError("Format must end with a \\n") # Check with expected result line = next(expected) - if output != line.encode(): + if output != line: print("Expected:", line) print("Obtained:", output) raise RuntimeError("Bad semantic") - stdout.write(b"[%d] %s" % (nb_tests, output)) + stdout.write(b"[%d] %s" % (nb_tests, output.encode('utf8'))) nb_tests += 1 jitter.func_ret_systemv(ret_ad, 0) @@ -105,7 +105,7 @@ def xxx_puts(jitter): output = jitter.get_str_ansi(args.target) # Check with expected result line = next(expected) - if output != line.rstrip().encode(): + if output != line.rstrip(): print("Expected:", line) print("Obtained:", output) raise RuntimeError("Bad semantic") diff --git a/test/arch/x86/qemu/testqemu64.py b/test/arch/x86/qemu/testqemu64.py index 24193d40..636cb6a9 100644 --- a/test/arch/x86/qemu/testqemu64.py +++ b/test/arch/x86/qemu/testqemu64.py @@ -16,24 +16,24 @@ from miasm.jitter.csts import PAGE_READ, PAGE_WRITE # Utils def parse_fmt(s): - fmt = s[:]+b"\x00" + fmt = s[:]+"\x00" out = [] i = 0 while i < len(fmt): c = fmt[i:i+1] - if c != b"%": + if c != "%": i+=1 continue - if fmt[i+1:i+2] == b"%": + if fmt[i+1:i+2] == "%": i+=2 continue j = 0 i+=1 - while fmt[i+j:i+j+1] in b"0123456789$.-": + while fmt[i+j:i+j+1] in "0123456789$.-": j+=1 - if fmt[i+j:i+j+1] in [b'l']: + if fmt[i+j:i+j+1] in ['l']: j +=1 - if fmt[i+j:i+j+1] == b"h": + if fmt[i+j:i+j+1] == "h": x = fmt[i+j:i+j+2] else: x = fmt[i+j:i+j+1] @@ -50,8 +50,8 @@ def xxx___printf_chk(jitter): raise RuntimeError("Not implemented") fmt = jitter.get_str_ansi(args.format) # Manage llx - fmt = fmt.replace(b"llx", b"lx") - fmt = fmt.replace(b"%016lx", b"%016z") + fmt = fmt.replace("llx", "lx") + fmt = fmt.replace("%016lx", "%016z") fmt_a = parse_fmt(fmt) args = [] @@ -59,11 +59,11 @@ def xxx___printf_chk(jitter): for x in fmt_a: a = jitter.get_arg_n_systemv(2 + i) - if x == b"s": + if x == "s": a = jitter.get_str_ansi(a) - elif x in (b"x", b'X', b'd', b'z', b'Z'): + elif x in ("x", 'X', 'd', 'z', 'Z'): pass - elif x.lower() in (b"f","l"): + elif x.lower() in ("f","l"): a = struct.unpack("d", struct.pack("Q", a))[0] i += 1 else: @@ -71,22 +71,22 @@ def xxx___printf_chk(jitter): args.append(a) i += 1 - fmt = fmt.replace(b"%016z", b"%016lx") + fmt = fmt.replace("%016z", "%016lx") output = fmt%(tuple(args)) # NaN bad repr in Python - output = output.replace(b"nan", b"-nan") + output = output.replace("nan", "-nan") - if b"\n" not in output: + if "\n" not in output: raise RuntimeError("Format must end with a \\n") # Check with expected result line = next(expected) - if output != line.encode(): + if output != line: print("Expected:", line) print("Obtained:", output) raise RuntimeError("Bad semantic") - stdout.write(b"[%d] %s" % (nb_tests, output)) + stdout.write(b"[%d] %s" % (nb_tests, output.encode('utf8'))) nb_tests += 1 jitter.func_ret_systemv(ret_ad, 0) diff --git a/test/os_dep/linux/stdlib.py b/test/os_dep/linux/stdlib.py index a205002b..ef890625 100755 --- a/test/os_dep/linux/stdlib.py +++ b/test/os_dep/linux/stdlib.py @@ -34,7 +34,7 @@ class TestLinuxStdlib(unittest.TestCase): jit.push_uint32_t(0) # ret_ad stdlib.xxx_sprintf(jit) ret = jit.get_str_ansi(buf) - self.assertEqual(ret, b"'coucou' 1111") + self.assertEqual(ret, "'coucou' 1111") if __name__ == '__main__': diff --git a/test/os_dep/win_api_x86_32.py b/test/os_dep/win_api_x86_32.py index a7d88f90..f759c6af 100755 --- a/test/os_dep/win_api_x86_32.py +++ b/test/os_dep/win_api_x86_32.py @@ -43,7 +43,7 @@ class TestWinAPI(unittest.TestCase): jit.push_uint32_t(0) # ret_ad winapi.msvcrt_sprintf(jit) ret = jit.get_str_ansi(buf) - self.assertEqual(ret, b"'coucou' 1111") + self.assertEqual(ret, "'coucou' 1111") def test_msvcrt_swprintf(self): |