diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2020-10-09 17:47:00 +0200 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2021-06-08 08:11:01 +0200 |
| commit | 2a3c5a4f9db4d4d6e6cadbd5886218054efe6261 (patch) | |
| tree | 8d54a9b3e8a199d578aef71025d16c372c24f6b7 | |
| parent | 6285271a95f3ec9815728fb808a69bb21b50f770 (diff) | |
| download | miasm-2a3c5a4f9db4d4d6e6cadbd5886218054efe6261.tar.gz miasm-2a3c5a4f9db4d4d6e6cadbd5886218054efe6261.zip | |
Symbols are str instead of bytes
| -rw-r--r-- | miasm/arch/aarch64/arch.py | 2 | ||||
| -rw-r--r-- | miasm/arch/arm/arch.py | 2 | ||||
| -rw-r--r-- | miasm/arch/mep/arch.py | 2 | ||||
| -rw-r--r-- | miasm/arch/mips32/arch.py | 2 | ||||
| -rw-r--r-- | miasm/arch/msp430/arch.py | 2 | ||||
| -rw-r--r-- | miasm/arch/ppc/arch.py | 2 | ||||
| -rw-r--r-- | miasm/arch/sh4/arch.py | 2 | ||||
| -rw-r--r-- | miasm/core/cpu.py | 4 | ||||
| -rw-r--r-- | miasm/core/locationdb.py | 16 | ||||
| -rw-r--r-- | miasm/core/parse_asm.py | 5 | ||||
| -rw-r--r-- | miasm/jitter/loader/elf.py | 6 | ||||
| -rw-r--r-- | miasm/loader/elf_init.py | 2 | ||||
| -rw-r--r-- | test/analysis/depgraph.py | 486 | ||||
| -rw-r--r-- | test/core/locationdb.py | 6 |
14 files changed, 270 insertions, 269 deletions
diff --git a/miasm/arch/aarch64/arch.py b/miasm/arch/aarch64/arch.py index fc52fe11..fc188ff2 100644 --- a/miasm/arch/aarch64/arch.py +++ b/miasm/arch/aarch64/arch.py @@ -286,7 +286,7 @@ class aarch64_arg(m_arg): if isinstance(value.name, ExprId): fixed_size.add(value.name.size) return value.name - loc_key = loc_db.get_or_create_name_location(value.name.encode()) + loc_key = loc_db.get_or_create_name_location(value.name) return m2_expr.ExprLoc(loc_key, size_hint) if isinstance(value, AstInt): assert size_hint is not None diff --git a/miasm/arch/arm/arch.py b/miasm/arch/arm/arch.py index 2b4476f0..abe6711f 100644 --- a/miasm/arch/arm/arch.py +++ b/miasm/arch/arm/arch.py @@ -792,7 +792,7 @@ class arm_arg(m_arg): return arg.name if arg.name in gpregs.str: return None - loc_key = loc_db.get_or_create_name_location(arg.name.encode()) + loc_key = loc_db.get_or_create_name_location(arg.name) return ExprLoc(loc_key, 32) if isinstance(arg, AstOp): args = [self.asm_ast_to_expr(tmp, loc_db) for tmp in arg.args] diff --git a/miasm/arch/mep/arch.py b/miasm/arch/mep/arch.py index 073acc57..a6b994ac 100644 --- a/miasm/arch/mep/arch.py +++ b/miasm/arch/mep/arch.py @@ -553,7 +553,7 @@ class mep_arg(m_arg): return arg.name if isinstance(arg.name, str) and arg.name in gpr_names: return None # GV: why? - loc_key = loc_db.get_or_create_name_location(arg.name.encode()) + loc_key = loc_db.get_or_create_name_location(arg.name) return ExprLoc(loc_key, 32) elif isinstance(arg, AstMem): diff --git a/miasm/arch/mips32/arch.py b/miasm/arch/mips32/arch.py index 0398be37..803f9eef 100644 --- a/miasm/arch/mips32/arch.py +++ b/miasm/arch/mips32/arch.py @@ -266,7 +266,7 @@ class mips32_arg(cpu.m_arg): return arg.name if arg.name in gpregs.str: return None - loc_key = loc_db.get_or_create_name_location(arg.name.encode()) + loc_key = loc_db.get_or_create_name_location(arg.name) return ExprLoc(loc_key, 32) if isinstance(arg, AstOp): args = [self.asm_ast_to_expr(tmp, loc_db) for tmp in arg.args] diff --git a/miasm/arch/msp430/arch.py b/miasm/arch/msp430/arch.py index 46014b8c..8d208d26 100644 --- a/miasm/arch/msp430/arch.py +++ b/miasm/arch/msp430/arch.py @@ -71,7 +71,7 @@ class msp430_arg(m_arg): index = gpregs.str.index(name) reg = gpregs.expr[index] return reg - loc_key = loc_db.get_or_create_name_location(value.name.encode()) + loc_key = loc_db.get_or_create_name_location(value.name) return ExprLoc(loc_key, 16) if isinstance(value, AstOp): args = [self.asm_ast_to_expr(tmp, loc_db) for tmp in value.args] diff --git a/miasm/arch/ppc/arch.py b/miasm/arch/ppc/arch.py index 2b951027..41259180 100644 --- a/miasm/arch/ppc/arch.py +++ b/miasm/arch/ppc/arch.py @@ -41,7 +41,7 @@ class ppc_arg(m_arg): return arg.name if arg.name in gpregs.str: return None - loc_key = loc_db.get_or_create_name_location(arg.name.encode()) + loc_key = loc_db.get_or_create_name_location(arg.name) return ExprLoc(loc_key, 32) if isinstance(arg, AstOp): args = [self.asm_ast_to_expr(tmp, loc_db) for tmp in arg.args] diff --git a/miasm/arch/sh4/arch.py b/miasm/arch/sh4/arch.py index 9310d3c3..3bf5049b 100644 --- a/miasm/arch/sh4/arch.py +++ b/miasm/arch/sh4/arch.py @@ -105,7 +105,7 @@ class sh4_arg(m_arg): return arg.name if arg.name in gpregs.str: return None - loc_key = loc_db.get_or_create_name_location(arg.name.encode()) + loc_key = loc_db.get_or_create_name_location(arg.name) return ExprLoc(loc_key, 32) if isinstance(arg, AstOp): args = [self.asm_ast_to_expr(tmp, loc_db) for tmp in arg.args] diff --git a/miasm/core/cpu.py b/miasm/core/cpu.py index f509c9c9..6c73c4c1 100644 --- a/miasm/core/cpu.py +++ b/miasm/core/cpu.py @@ -1025,10 +1025,10 @@ class instruction(object): loc_key = exprloc.loc_key names = loc_db.get_location_names(loc_key) # special symbols - if b'$' in names: + if '$' in names: fixed_expr[exprloc] = self.get_asm_offset(exprloc) continue - if b'_' in names: + if '_' in names: fixed_expr[exprloc] = self.get_asm_next_offset(exprloc) continue arg_int = loc_db.get_location_offset(loc_key) diff --git a/miasm/core/locationdb.py b/miasm/core/locationdb.py index f950b48f..b7e16ea2 100644 --- a/miasm/core/locationdb.py +++ b/miasm/core/locationdb.py @@ -4,7 +4,7 @@ from builtins import int as int_types from functools import reduce from future.utils import viewitems, viewvalues -from miasm.core.utils import printable, force_bytes +from miasm.core.utils import printable from miasm.expression.expression import LocKey, ExprLoc @@ -85,7 +85,7 @@ class LocationDB(object): Return the LocKey of @name if any, None otherwise. @name: target name """ - name = force_bytes(name) + assert isinstance(name, str) return self._name_to_loc_key.get(name) def get_or_create_name_location(self, name): @@ -93,7 +93,7 @@ class LocationDB(object): Return the LocKey of @name if any, create one otherwise. @name: target name """ - name = force_bytes(name) + assert isinstance(name, str) loc_key = self._name_to_loc_key.get(name) if loc_key is not None: return loc_key @@ -121,7 +121,7 @@ class LocationDB(object): Return the offset of @name if any, None otherwise. @name: target name """ - name = force_bytes(name) + assert isinstance(name, str) loc_key = self.get_name_location(name) if loc_key is None: return None @@ -132,7 +132,7 @@ class LocationDB(object): @name: str instance @loc_key: LocKey instance """ - name = force_bytes(name) + assert isinstance(name, str) assert loc_key in self._loc_keys already_existing_loc = self._name_to_loc_key.get(name) if already_existing_loc is not None and already_existing_loc != loc_key: @@ -148,7 +148,7 @@ class LocationDB(object): @loc_key: LocKey instance """ assert loc_key in self._loc_keys - name = force_bytes(name) + assert isinstance(name, str) already_existing_loc = self._name_to_loc_key.get(name) if already_existing_loc is None: raise KeyError("%r is not already associated" % name) @@ -216,7 +216,7 @@ class LocationDB(object): @name: string """ - name = force_bytes(name) + assert isinstance(name, str) if self.get_name_location(name) is None: return name i = 0 @@ -239,7 +239,6 @@ class LocationDB(object): LocKey may be updated and will be returned. """ - name = force_bytes(name) # Deprecation handling if isinstance(name, int_types): assert offset is None or offset == name @@ -258,6 +257,7 @@ class LocationDB(object): # Test for collisions name_loc_key = None if name is not None: + assert isinstance(name, str) name_loc_key = self.get_name_location(name) if strict: diff --git a/miasm/core/parse_asm.py b/miasm/core/parse_asm.py index 19bf4415..79ef416d 100644 --- a/miasm/core/parse_asm.py +++ b/miasm/core/parse_asm.py @@ -3,6 +3,7 @@ import re import codecs from builtins import range +from miasm.core.utils import force_str from miasm.expression.expression import ExprId, ExprInt, ExprOp, LocKey import miasm.core.asmblock as asmblock from miasm.core.cpu import instruction, base_expr @@ -67,7 +68,7 @@ STATE_IN_BLOC = 1 def asm_ast_to_expr_with_size(arg, loc_db, size): if isinstance(arg, AstId): - return ExprId(arg.name.encode(), size) + return ExprId(force_str(arg.name), size) if isinstance(arg, AstOp): args = [asm_ast_to_expr_with_size(tmp, loc_db, size) for tmp in arg.args] return ExprOp(arg.op, *args) @@ -174,7 +175,7 @@ def parse_txt(mnemo, attrib, txt, loc_db): # label match_re = LABEL_RE.match(line) if match_re: - label_name = match_re.group(1).encode() + label_name = match_re.group(1) label = loc_db.get_or_create_name_location(label_name) lines.append(label) continue diff --git a/miasm/jitter/loader/elf.py b/miasm/jitter/loader/elf.py index cb102c47..91d1c18b 100644 --- a/miasm/jitter/loader/elf.py +++ b/miasm/jitter/loader/elf.py @@ -73,14 +73,14 @@ def fill_loc_db_with_symbols(elf, loc_db, base_addr=0): for name, sym in viewitems(section_header.symbols): if not name or sym.value == 0: continue - name = loc_db.find_free_name(name) + name = loc_db.find_free_name(force_str(name)) loc_db.add_location(name, sym.value, strict=False) if hasattr(section_header, 'reltab'): for rel in section_header.reltab: if not rel.sym or rel.offset == 0: continue - name = loc_db.find_free_name(rel.sym) + name = loc_db.find_free_name(force_str(rel.sym)) loc_db.add_location(name, rel.offset, strict=False) if hasattr(section_header, 'symtab'): @@ -135,7 +135,7 @@ def fill_loc_db_with_symbols(elf, loc_db, base_addr=0): # Reserved index (between SHN_LORESERV and SHN_HIRESERVE) raise RuntimeError("Unsupported reserved index: %r" % symbol_entry) - name = symbol_entry.name + name = force_str(symbol_entry.name) if name == "": # Ignore empty symbol log.debug("Empty symbol %r", symbol_entry) diff --git a/miasm/loader/elf_init.py b/miasm/loader/elf_init.py index 72d08302..cffb3575 100644 --- a/miasm/loader/elf_init.py +++ b/miasm/loader/elf_init.py @@ -7,7 +7,7 @@ import struct from future.utils import PY3, with_metaclass -from miasm.core.utils import force_bytes +from miasm.core.utils import force_bytes, force_str from miasm.loader import cstruct from miasm.loader import elf from miasm.loader.strpatchwork import StrPatchwork diff --git a/test/analysis/depgraph.py b/test/analysis/depgraph.py index f0b67737..57a73a5f 100644 --- a/test/analysis/depgraph.py +++ b/test/analysis/depgraph.py @@ -865,253 +865,253 @@ def get_flat_init_depnodes(depnodes): return out # TESTS -flat_test_results = [[(((b'lbl0', 1, 0), (b'lbl0', 'c', 0), (b'lbl1', 'b', 0), (b'lbl2', 'a', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'c', 0)), - ((b'lbl0', 'c', 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 'b', 0), (b'lbl2', 'a', 0))))], - [(((b'lbl0', 1, 0), - (b'lbl0', 'c', 0), - (b'lbl1', 2, 0), - (b'lbl1', 'b', 0), - (b'lbl2', 'a', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'c', 0)), - ((b'lbl0', 'c', 0), (b'lbl2', 'a', 0)), - ((b'lbl1', 2, 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 'b', 0), (b'lbl2', 'a', 0))))], - [(((b'lbl0', 1, 0), - (b'lbl0', 'c', 0), - (b'lbl1', 2, 0), - (b'lbl1', 'b', 0), - (b'lbl3', 'a', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'c', 0)), - ((b'lbl0', 'c', 0), (b'lbl3', 'a', 0)), - ((b'lbl1', 2, 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 'b', 0), (b'lbl3', 'a', 0)))), - (((b'lbl0', 1, 0), - (b'lbl0', 'c', 0), - (b'lbl2', 3, 0), - (b'lbl2', 'b', 0), - (b'lbl3', 'a', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'c', 0)), - ((b'lbl0', 'c', 0), (b'lbl3', 'a', 0)), - ((b'lbl2', 3, 0), (b'lbl2', 'b', 0)), - ((b'lbl2', 'b', 0), (b'lbl3', 'a', 0))))], - [(('b', (b'lbl2', 'a', 0)), (('b', (b'lbl2', 'a', 0)),))], - [(((b'lbl0', 1, 0), - (b'lbl0', 'b', 0), - (b'lbl1', 2, 0), - (b'lbl1', 'b', 0), - (b'lbl2', 'a', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'b', 0)), - ((b'lbl0', 'b', 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 2, 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 'b', 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 'b', 0), (b'lbl2', 'a', 0)))), - (((b'lbl0', 1, 0), - (b'lbl0', 'b', 0), - (b'lbl1', 2, 0), - (b'lbl1', 'b', 0), - (b'lbl2', 'a', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'b', 0)), - ((b'lbl0', 'b', 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 2, 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 'b', 0), (b'lbl2', 'a', 0))))], - [(((b'lbl0', 1, 0), (b'lbl0', 'b', 0), (b'lbl1', 'a', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'b', 0)), - ((b'lbl0', 'b', 0), (b'lbl1', 'a', 0))))], - [(((b'lbl0', 1, 0), - (b'lbl0', 'c', 0), - (b'lbl1', 'a', 1), - (b'lbl1', 'b', 0), - (b'lbl2', 'd', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'c', 0)), - ((b'lbl0', 'c', 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 'a', 1), (b'lbl2', 'd', 0)), - ((b'lbl1', 'b', 0), (b'lbl1', 'a', 1))))], - [(('d', (b'lbl1', 'b', 0), (b'lbl1', 'c', 1), (b'lbl2', 'a', 0)), - (('d', (b'lbl1', 'c', 1)), - ((b'lbl1', 'b', 0), (b'lbl2', 'a', 0)), - ((b'lbl1', 'c', 1), (b'lbl1', 'b', 0)))), - (((b'lbl0', 1, 0), (b'lbl0', 'c', 0), (b'lbl1', 'b', 0), (b'lbl2', 'a', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'c', 0)), - ((b'lbl0', 'c', 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 'b', 0), (b'lbl2', 'a', 0))))], +flat_test_results = [[((('lbl0', 1, 0), ('lbl0', 'c', 0), ('lbl1', 'b', 0), ('lbl2', 'a', 0)), + ((('lbl0', 1, 0), ('lbl0', 'c', 0)), + (('lbl0', 'c', 0), ('lbl1', 'b', 0)), + (('lbl1', 'b', 0), ('lbl2', 'a', 0))))], + [((('lbl0', 1, 0), + ('lbl0', 'c', 0), + ('lbl1', 2, 0), + ('lbl1', 'b', 0), + ('lbl2', 'a', 0)), + ((('lbl0', 1, 0), ('lbl0', 'c', 0)), + (('lbl0', 'c', 0), ('lbl2', 'a', 0)), + (('lbl1', 2, 0), ('lbl1', 'b', 0)), + (('lbl1', 'b', 0), ('lbl2', 'a', 0))))], + [((('lbl0', 1, 0), + ('lbl0', 'c', 0), + ('lbl1', 2, 0), + ('lbl1', 'b', 0), + ('lbl3', 'a', 0)), + ((('lbl0', 1, 0), ('lbl0', 'c', 0)), + (('lbl0', 'c', 0), ('lbl3', 'a', 0)), + (('lbl1', 2, 0), ('lbl1', 'b', 0)), + (('lbl1', 'b', 0), ('lbl3', 'a', 0)))), + ((('lbl0', 1, 0), + ('lbl0', 'c', 0), + ('lbl2', 3, 0), + ('lbl2', 'b', 0), + ('lbl3', 'a', 0)), + ((('lbl0', 1, 0), ('lbl0', 'c', 0)), + (('lbl0', 'c', 0), ('lbl3', 'a', 0)), + (('lbl2', 3, 0), ('lbl2', 'b', 0)), + (('lbl2', 'b', 0), ('lbl3', 'a', 0))))], + [(('b', ('lbl2', 'a', 0)), (('b', ('lbl2', 'a', 0)),))], + [((('lbl0', 1, 0), + ('lbl0', 'b', 0), + ('lbl1', 2, 0), + ('lbl1', 'b', 0), + ('lbl2', 'a', 0)), + ((('lbl0', 1, 0), ('lbl0', 'b', 0)), + (('lbl0', 'b', 0), ('lbl1', 'b', 0)), + (('lbl1', 2, 0), ('lbl1', 'b', 0)), + (('lbl1', 'b', 0), ('lbl1', 'b', 0)), + (('lbl1', 'b', 0), ('lbl2', 'a', 0)))), + ((('lbl0', 1, 0), + ('lbl0', 'b', 0), + ('lbl1', 2, 0), + ('lbl1', 'b', 0), + ('lbl2', 'a', 0)), + ((('lbl0', 1, 0), ('lbl0', 'b', 0)), + (('lbl0', 'b', 0), ('lbl1', 'b', 0)), + (('lbl1', 2, 0), ('lbl1', 'b', 0)), + (('lbl1', 'b', 0), ('lbl2', 'a', 0))))], + [((('lbl0', 1, 0), ('lbl0', 'b', 0), ('lbl1', 'a', 0)), + ((('lbl0', 1, 0), ('lbl0', 'b', 0)), + (('lbl0', 'b', 0), ('lbl1', 'a', 0))))], + [((('lbl0', 1, 0), + ('lbl0', 'c', 0), + ('lbl1', 'a', 1), + ('lbl1', 'b', 0), + ('lbl2', 'd', 0)), + ((('lbl0', 1, 0), ('lbl0', 'c', 0)), + (('lbl0', 'c', 0), ('lbl1', 'b', 0)), + (('lbl1', 'a', 1), ('lbl2', 'd', 0)), + (('lbl1', 'b', 0), ('lbl1', 'a', 1))))], + [(('d', ('lbl1', 'b', 0), ('lbl1', 'c', 1), ('lbl2', 'a', 0)), + (('d', ('lbl1', 'c', 1)), + (('lbl1', 'b', 0), ('lbl2', 'a', 0)), + (('lbl1', 'c', 1), ('lbl1', 'b', 0)))), + ((('lbl0', 1, 0), ('lbl0', 'c', 0), ('lbl1', 'b', 0), ('lbl2', 'a', 0)), + ((('lbl0', 1, 0), ('lbl0', 'c', 0)), + (('lbl0', 'c', 0), ('lbl1', 'b', 0)), + (('lbl1', 'b', 0), ('lbl2', 'a', 0))))], [(('d', - (b'lbl0', 1, 0), - (b'lbl0', 'c', 0), - (b'lbl1', 'b', 0), - (b'lbl1', 'c', 1), - (b'lbl2', 'a', 0)), - (('d', (b'lbl1', 'c', 1)), - ((b'lbl0', 1, 0), (b'lbl0', 'c', 0)), - ((b'lbl0', 'c', 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 'b', 0), (b'lbl2', 'a', 0)))), - (('d', (b'lbl1', 'b', 0), (b'lbl1', 'c', 1), (b'lbl2', 'a', 0)), - (('d', (b'lbl1', 'c', 1)), - ((b'lbl1', 'b', 0), (b'lbl2', 'a', 0)), - ((b'lbl1', 'c', 1), (b'lbl1', 'b', 0))))], - [(('b', (b'lbl1', 2, 0), (b'lbl1', 'b', 0), (b'lbl2', 'a', 0)), - (('b', (b'lbl1', 'b', 0)), - ((b'lbl1', 2, 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 'b', 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 'b', 0), (b'lbl2', 'a', 0)))), - (('b', (b'lbl1', 2, 0), (b'lbl1', 'b', 0), (b'lbl2', 'a', 0)), - (('b', (b'lbl1', 'b', 0)), - ((b'lbl1', 2, 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 'b', 0), (b'lbl2', 'a', 0))))], - [(((b'lbl0', 1, 0), - (b'lbl0', 2, 0), - (b'lbl0', 'a', 0), - (b'lbl0', 'b', 0), - (b'lbl1', 'a', 0), - (b'lbl1', 'b', 0), - (b'lbl2', 'a', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'a', 0)), - ((b'lbl0', 2, 0), (b'lbl0', 'b', 0)), - ((b'lbl0', 'a', 0), (b'lbl1', 'b', 0)), - ((b'lbl0', 'b', 0), (b'lbl1', 'a', 0)), - ((b'lbl1', 'a', 0), (b'lbl2', 'a', 0)), - ((b'lbl1', 'b', 0), (b'lbl2', 'a', 0))))], - [(((b'lbl0', 1, 0), - (b'lbl0', 'b', 0), - (b'lbl1', 2, 1), - (b'lbl1', 'a', 0), - (b'lbl1', 'b', 1), - (b'lbl2', 'b', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'b', 0)), - ((b'lbl0', 'b', 0), (b'lbl1', 'b', 1)), - ((b'lbl1', 2, 1), (b'lbl1', 'b', 1)), - ((b'lbl1', 'a', 0), (b'lbl2', 'b', 0)), - ((b'lbl1', 'b', 1), (b'lbl1', 'a', 0)))), - (((b'lbl0', 1, 0), - (b'lbl0', 'b', 0), - (b'lbl1', 2, 1), - (b'lbl1', 'a', 0), - (b'lbl1', 'b', 1), - (b'lbl2', 'b', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'b', 0)), - ((b'lbl0', 'b', 0), (b'lbl1', 'b', 1)), - ((b'lbl1', 2, 1), (b'lbl1', 'b', 1)), - ((b'lbl1', 'a', 0), (b'lbl2', 'b', 0)), - ((b'lbl1', 'b', 1), (b'lbl1', 'a', 0)), - ((b'lbl1', 'b', 1), (b'lbl1', 'b', 1)))), - (((b'lbl0', 1, 0), (b'lbl0', 'b', 0), (b'lbl1', 'a', 0), (b'lbl2', 'b', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'b', 0)), - ((b'lbl0', 'b', 0), (b'lbl1', 'a', 0)), - ((b'lbl1', 'a', 0), (b'lbl2', 'b', 0))))], - [(((b'lbl0', 1, 0), - (b'lbl0', 'a', 0), - (b'lbl1', 'c', 0), - (b'lbl2', 3, 0), - (b'lbl2', 3, 1), - (b'lbl2', 'a', 1), - (b'lbl2', 'b', 0), - (b'lbl3', 'r', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'a', 0)), - ((b'lbl0', 'a', 0), (b'lbl2', 'b', 0)), - ((b'lbl1', 'c', 0), (b'lbl3', 'r', 0)), - ((b'lbl2', 3, 0), (b'lbl2', 'b', 0)), - ((b'lbl2', 3, 1), (b'lbl2', 'a', 1)), - ((b'lbl2', 'a', 1), (b'lbl1', 'c', 0)), - ((b'lbl2', 'a', 1), (b'lbl2', 'b', 0)), - ((b'lbl2', 'b', 0), (b'lbl2', 'a', 1)))), - (((b'lbl0', 1, 0), - (b'lbl0', 'a', 0), - (b'lbl1', 'c', 0), - (b'lbl2', 3, 0), - (b'lbl2', 3, 1), - (b'lbl2', 'a', 1), - (b'lbl2', 'b', 0), - (b'lbl3', 'r', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'a', 0)), - ((b'lbl0', 'a', 0), (b'lbl2', 'b', 0)), - ((b'lbl1', 'c', 0), (b'lbl3', 'r', 0)), - ((b'lbl2', 3, 0), (b'lbl2', 'b', 0)), - ((b'lbl2', 3, 1), (b'lbl2', 'a', 1)), - ((b'lbl2', 'a', 1), (b'lbl1', 'c', 0)), - ((b'lbl2', 'b', 0), (b'lbl2', 'a', 1)))), - (((b'lbl0', 1, 0), (b'lbl0', 'a', 0), (b'lbl1', 'c', 0), (b'lbl3', 'r', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'a', 0)), - ((b'lbl0', 'a', 0), (b'lbl1', 'c', 0)), - ((b'lbl1', 'c', 0), (b'lbl3', 'r', 0))))], + ('lbl0', 1, 0), + ('lbl0', 'c', 0), + ('lbl1', 'b', 0), + ('lbl1', 'c', 1), + ('lbl2', 'a', 0)), + (('d', ('lbl1', 'c', 1)), + (('lbl0', 1, 0), ('lbl0', 'c', 0)), + (('lbl0', 'c', 0), ('lbl1', 'b', 0)), + (('lbl1', 'b', 0), ('lbl2', 'a', 0)))), + (('d', ('lbl1', 'b', 0), ('lbl1', 'c', 1), ('lbl2', 'a', 0)), + (('d', ('lbl1', 'c', 1)), + (('lbl1', 'b', 0), ('lbl2', 'a', 0)), + (('lbl1', 'c', 1), ('lbl1', 'b', 0))))], + [(('b', ('lbl1', 2, 0), ('lbl1', 'b', 0), ('lbl2', 'a', 0)), + (('b', ('lbl1', 'b', 0)), + (('lbl1', 2, 0), ('lbl1', 'b', 0)), + (('lbl1', 'b', 0), ('lbl1', 'b', 0)), + (('lbl1', 'b', 0), ('lbl2', 'a', 0)))), + (('b', ('lbl1', 2, 0), ('lbl1', 'b', 0), ('lbl2', 'a', 0)), + (('b', ('lbl1', 'b', 0)), + (('lbl1', 2, 0), ('lbl1', 'b', 0)), + (('lbl1', 'b', 0), ('lbl2', 'a', 0))))], + [((('lbl0', 1, 0), + ('lbl0', 2, 0), + ('lbl0', 'a', 0), + ('lbl0', 'b', 0), + ('lbl1', 'a', 0), + ('lbl1', 'b', 0), + ('lbl2', 'a', 0)), + ((('lbl0', 1, 0), ('lbl0', 'a', 0)), + (('lbl0', 2, 0), ('lbl0', 'b', 0)), + (('lbl0', 'a', 0), ('lbl1', 'b', 0)), + (('lbl0', 'b', 0), ('lbl1', 'a', 0)), + (('lbl1', 'a', 0), ('lbl2', 'a', 0)), + (('lbl1', 'b', 0), ('lbl2', 'a', 0))))], + [((('lbl0', 1, 0), + ('lbl0', 'b', 0), + ('lbl1', 2, 1), + ('lbl1', 'a', 0), + ('lbl1', 'b', 1), + ('lbl2', 'b', 0)), + ((('lbl0', 1, 0), ('lbl0', 'b', 0)), + (('lbl0', 'b', 0), ('lbl1', 'b', 1)), + (('lbl1', 2, 1), ('lbl1', 'b', 1)), + (('lbl1', 'a', 0), ('lbl2', 'b', 0)), + (('lbl1', 'b', 1), ('lbl1', 'a', 0)))), + ((('lbl0', 1, 0), + ('lbl0', 'b', 0), + ('lbl1', 2, 1), + ('lbl1', 'a', 0), + ('lbl1', 'b', 1), + ('lbl2', 'b', 0)), + ((('lbl0', 1, 0), ('lbl0', 'b', 0)), + (('lbl0', 'b', 0), ('lbl1', 'b', 1)), + (('lbl1', 2, 1), ('lbl1', 'b', 1)), + (('lbl1', 'a', 0), ('lbl2', 'b', 0)), + (('lbl1', 'b', 1), ('lbl1', 'a', 0)), + (('lbl1', 'b', 1), ('lbl1', 'b', 1)))), + ((('lbl0', 1, 0), ('lbl0', 'b', 0), ('lbl1', 'a', 0), ('lbl2', 'b', 0)), + ((('lbl0', 1, 0), ('lbl0', 'b', 0)), + (('lbl0', 'b', 0), ('lbl1', 'a', 0)), + (('lbl1', 'a', 0), ('lbl2', 'b', 0))))], + [((('lbl0', 1, 0), + ('lbl0', 'a', 0), + ('lbl1', 'c', 0), + ('lbl2', 3, 0), + ('lbl2', 3, 1), + ('lbl2', 'a', 1), + ('lbl2', 'b', 0), + ('lbl3', 'r', 0)), + ((('lbl0', 1, 0), ('lbl0', 'a', 0)), + (('lbl0', 'a', 0), ('lbl2', 'b', 0)), + (('lbl1', 'c', 0), ('lbl3', 'r', 0)), + (('lbl2', 3, 0), ('lbl2', 'b', 0)), + (('lbl2', 3, 1), ('lbl2', 'a', 1)), + (('lbl2', 'a', 1), ('lbl1', 'c', 0)), + (('lbl2', 'a', 1), ('lbl2', 'b', 0)), + (('lbl2', 'b', 0), ('lbl2', 'a', 1)))), + ((('lbl0', 1, 0), + ('lbl0', 'a', 0), + ('lbl1', 'c', 0), + ('lbl2', 3, 0), + ('lbl2', 3, 1), + ('lbl2', 'a', 1), + ('lbl2', 'b', 0), + ('lbl3', 'r', 0)), + ((('lbl0', 1, 0), ('lbl0', 'a', 0)), + (('lbl0', 'a', 0), ('lbl2', 'b', 0)), + (('lbl1', 'c', 0), ('lbl3', 'r', 0)), + (('lbl2', 3, 0), ('lbl2', 'b', 0)), + (('lbl2', 3, 1), ('lbl2', 'a', 1)), + (('lbl2', 'a', 1), ('lbl1', 'c', 0)), + (('lbl2', 'b', 0), ('lbl2', 'a', 1)))), + ((('lbl0', 1, 0), ('lbl0', 'a', 0), ('lbl1', 'c', 0), ('lbl3', 'r', 0)), + ((('lbl0', 1, 0), ('lbl0', 'a', 0)), + (('lbl0', 'a', 0), ('lbl1', 'c', 0)), + (('lbl1', 'c', 0), ('lbl3', 'r', 0))))], [(('d', - (b'lbl0', 1, 0), - (b'lbl0', 'a', 0), - (b'lbl1', 'b', 0), - (b'lbl3', 'r', 0)), - (('d', (b'lbl3', 'r', 0)), - ((b'lbl0', 1, 0), (b'lbl0', 'a', 0)), - ((b'lbl0', 'a', 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 'b', 0), (b'lbl3', 'r', 0)))), - (((b'lbl0', 1, 0), - (b'lbl0', 'a', 0), - (b'lbl1', 'b', 0), - (b'lbl2', 1, 1), - (b'lbl2', 'a', 1), - (b'lbl2', 'd', 0), - (b'lbl3', 'r', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'a', 0)), - ((b'lbl0', 'a', 0), (b'lbl2', 'd', 0)), - ((b'lbl1', 'b', 0), (b'lbl3', 'r', 0)), - ((b'lbl2', 1, 1), (b'lbl2', 'a', 1)), - ((b'lbl2', 'a', 1), (b'lbl1', 'b', 0)), - ((b'lbl2', 'a', 1), (b'lbl2', 'd', 0)), - ((b'lbl2', 'd', 0), (b'lbl2', 'a', 1)), - ((b'lbl2', 'd', 0), (b'lbl3', 'r', 0)))), - (((b'lbl0', 1, 0), - (b'lbl0', 'a', 0), - (b'lbl1', 'b', 0), - (b'lbl2', 1, 1), - (b'lbl2', 'a', 1), - (b'lbl2', 'd', 0), - (b'lbl3', 'r', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'a', 0)), - ((b'lbl0', 'a', 0), (b'lbl2', 'd', 0)), - ((b'lbl1', 'b', 0), (b'lbl3', 'r', 0)), - ((b'lbl2', 1, 1), (b'lbl2', 'a', 1)), - ((b'lbl2', 'a', 1), (b'lbl1', 'b', 0)), - ((b'lbl2', 'd', 0), (b'lbl2', 'a', 1)), - ((b'lbl2', 'd', 0), (b'lbl3', 'r', 0))))], + ('lbl0', 1, 0), + ('lbl0', 'a', 0), + ('lbl1', 'b', 0), + ('lbl3', 'r', 0)), + (('d', ('lbl3', 'r', 0)), + (('lbl0', 1, 0), ('lbl0', 'a', 0)), + (('lbl0', 'a', 0), ('lbl1', 'b', 0)), + (('lbl1', 'b', 0), ('lbl3', 'r', 0)))), + ((('lbl0', 1, 0), + ('lbl0', 'a', 0), + ('lbl1', 'b', 0), + ('lbl2', 1, 1), + ('lbl2', 'a', 1), + ('lbl2', 'd', 0), + ('lbl3', 'r', 0)), + ((('lbl0', 1, 0), ('lbl0', 'a', 0)), + (('lbl0', 'a', 0), ('lbl2', 'd', 0)), + (('lbl1', 'b', 0), ('lbl3', 'r', 0)), + (('lbl2', 1, 1), ('lbl2', 'a', 1)), + (('lbl2', 'a', 1), ('lbl1', 'b', 0)), + (('lbl2', 'a', 1), ('lbl2', 'd', 0)), + (('lbl2', 'd', 0), ('lbl2', 'a', 1)), + (('lbl2', 'd', 0), ('lbl3', 'r', 0)))), + ((('lbl0', 1, 0), + ('lbl0', 'a', 0), + ('lbl1', 'b', 0), + ('lbl2', 1, 1), + ('lbl2', 'a', 1), + ('lbl2', 'd', 0), + ('lbl3', 'r', 0)), + ((('lbl0', 1, 0), ('lbl0', 'a', 0)), + (('lbl0', 'a', 0), ('lbl2', 'd', 0)), + (('lbl1', 'b', 0), ('lbl3', 'r', 0)), + (('lbl2', 1, 1), ('lbl2', 'a', 1)), + (('lbl2', 'a', 1), ('lbl1', 'b', 0)), + (('lbl2', 'd', 0), ('lbl2', 'a', 1)), + (('lbl2', 'd', 0), ('lbl3', 'r', 0))))], [(('b', - (b'lbl0', 1, 0), - (b'lbl0', 'a', 0), - (b'lbl1', 'b', 2), - (b'lbl1', 'c', 1), - (b'lbl1', 'd', 0), - (b'lbl2', 'r', 0)), - (('b', (b'lbl1', 'd', 0)), - ((b'lbl0', 1, 0), (b'lbl0', 'a', 0)), - ((b'lbl0', 'a', 0), (b'lbl1', 'd', 0)), - ((b'lbl1', 'b', 2), (b'lbl1', 'd', 0)), - ((b'lbl1', 'b', 2), (b'lbl2', 'r', 0)), - ((b'lbl1', 'c', 1), (b'lbl1', 'b', 2)), - ((b'lbl1', 'd', 0), (b'lbl1', 'c', 1)))), + ('lbl0', 1, 0), + ('lbl0', 'a', 0), + ('lbl1', 'b', 2), + ('lbl1', 'c', 1), + ('lbl1', 'd', 0), + ('lbl2', 'r', 0)), + (('b', ('lbl1', 'd', 0)), + (('lbl0', 1, 0), ('lbl0', 'a', 0)), + (('lbl0', 'a', 0), ('lbl1', 'd', 0)), + (('lbl1', 'b', 2), ('lbl1', 'd', 0)), + (('lbl1', 'b', 2), ('lbl2', 'r', 0)), + (('lbl1', 'c', 1), ('lbl1', 'b', 2)), + (('lbl1', 'd', 0), ('lbl1', 'c', 1)))), (('b', - (b'lbl0', 1, 0), - (b'lbl0', 'a', 0), - (b'lbl1', 'b', 2), - (b'lbl1', 'c', 1), - (b'lbl1', 'd', 0), - (b'lbl2', 'r', 0)), - (('b', (b'lbl1', 'd', 0)), - ((b'lbl0', 1, 0), (b'lbl0', 'a', 0)), - ((b'lbl0', 'a', 0), (b'lbl1', 'd', 0)), - ((b'lbl1', 'b', 2), (b'lbl2', 'r', 0)), - ((b'lbl1', 'c', 1), (b'lbl1', 'b', 2)), - ((b'lbl1', 'd', 0), (b'lbl1', 'c', 1))))], - [(((b'lbl0', 1, 0), (b'lbl0', 'a', 0), (b'lbl5', 'r', 0)), - (((b'lbl0', 1, 0), (b'lbl0', 'a', 0)), - ((b'lbl0', 'a', 0), (b'lbl5', 'r', 0))))], - [(((b'lbl0', 2, 0), - (b'lbl0', 'd', 0), - (b'lbl1', 'a', 0), - (b'lbl1', 'b', 0), - (b'lbl2', 'a', 0)), - (((b'lbl0', 2, 0), (b'lbl0', 'd', 0)), - ((b'lbl0', 'd', 0), (b'lbl1', 'a', 0)), - ((b'lbl0', 'd', 0), (b'lbl1', 'b', 0)), - ((b'lbl1', 'a', 0), (b'lbl2', 'a', 0)), - ((b'lbl1', 'b', 0), (b'lbl2', 'a', 0))))]] + ('lbl0', 1, 0), + ('lbl0', 'a', 0), + ('lbl1', 'b', 2), + ('lbl1', 'c', 1), + ('lbl1', 'd', 0), + ('lbl2', 'r', 0)), + (('b', ('lbl1', 'd', 0)), + (('lbl0', 1, 0), ('lbl0', 'a', 0)), + (('lbl0', 'a', 0), ('lbl1', 'd', 0)), + (('lbl1', 'b', 2), ('lbl2', 'r', 0)), + (('lbl1', 'c', 1), ('lbl1', 'b', 2)), + (('lbl1', 'd', 0), ('lbl1', 'c', 1))))], + [((('lbl0', 1, 0), ('lbl0', 'a', 0), ('lbl5', 'r', 0)), + ((('lbl0', 1, 0), ('lbl0', 'a', 0)), + (('lbl0', 'a', 0), ('lbl5', 'r', 0))))], + [((('lbl0', 2, 0), + ('lbl0', 'd', 0), + ('lbl1', 'a', 0), + ('lbl1', 'b', 0), + ('lbl2', 'a', 0)), + ((('lbl0', 2, 0), ('lbl0', 'd', 0)), + (('lbl0', 'd', 0), ('lbl1', 'a', 0)), + (('lbl0', 'd', 0), ('lbl1', 'b', 0)), + (('lbl1', 'a', 0), ('lbl2', 'a', 0)), + (('lbl1', 'b', 0), ('lbl2', 'a', 0))))]] test_results = [[unflatGraph(flat_result) for flat_result in flat_results] for flat_results in flat_test_results] diff --git a/test/core/locationdb.py b/test/core/locationdb.py index b6d7d8e0..0502f0df 100644 --- a/test/core/locationdb.py +++ b/test/core/locationdb.py @@ -58,9 +58,9 @@ loc_db.consistency_check() # Names manipulation loc_key5 = loc_db.add_location() -name1 = b"name1" -name2 = b"name2" -name3 = b"name3" +name1 = "name1" +name2 = "name2" +name3 = "name3" assert len(loc_db.get_location_names(loc_key5)) == 0 loc_db.add_location_name(loc_key5, name1) loc_db.add_location_name(loc_key5, name2) |