copapy/tests/test_stencil_db.py

46 lines
1.4 KiB
Python

from copapy._stencils import get_stencil_position
from copapy._basic_types import stencil_db_from_package
sdb = stencil_db_from_package()
def test_list_symbols():
print('----')
#print(sdb.function_definitions)
for sym_name in sdb.stencil_definitions.keys():
print('\n-', sym_name)
#print(list(sdb.get_patch_positions(sym_name)))
def test_start_end_function():
for sym_name in sdb.stencil_definitions.keys():
symbol = sdb.elf.symbols[sym_name]
if symbol.relocations and symbol.relocations[-1].symbol.info == 'STT_NOTYPE':
if symbol.section and symbol.section.name == '.text':
print('SKIP', sym_name, '(Aux function, not a stencil)')
continue
if symbol.section:
function_size = symbol.section.fields['sh_size'] # len(symbol.data) excludes nop after the function
print('-', sym_name, get_stencil_position(symbol), function_size)
start, end = get_stencil_position(symbol)
assert (start >= 0 and end >= start and end <= function_size)
def test_aux_functions():
for sym_name in sdb.stencil_definitions.keys():
symbol = sdb.elf.symbols[sym_name]
for reloc in symbol.relocations:
if reloc.symbol.info != "STT_NOTYPE":
print(reloc.symbol.name, reloc.symbol.info)
if __name__ == "__main__":
test_aux_functions()