about summary refs log tree commit diff stats
path: root/test/arch/x86/qemu/testqemu.py
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2019-09-22 19:32:18 +0200
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2019-09-22 22:02:51 +0200
commit523507835ed6789a9489120023b539f6ae82eb18 (patch)
tree84a479a7ab6324f651d406226aef72afca89f7c9 /test/arch/x86/qemu/testqemu.py
parent1902c27e796277ab495afe3d39bf17d882eda062 (diff)
downloadmiasm-523507835ed6789a9489120023b539f6ae82eb18.tar.gz
miasm-523507835ed6789a9489120023b539f6ae82eb18.zip
Fix get_str_ansi: return str
get_str_ansi and get_str_unic now returns both *str* object:
As get_str_unic decodes the string, get_str_ansi should do the same.
Diffstat (limited to 'test/arch/x86/qemu/testqemu.py')
-rw-r--r--test/arch/x86/qemu/testqemu.py36
1 files changed, 18 insertions, 18 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")