copapy/tests/test_stencil_db.py

39 lines
1.1 KiB
Python
Raw Permalink Normal View History

2025-11-10 19:07:59 +00:00
from copapy._stencils import get_stencil_position
from copapy._basic_types import stencil_db_from_package
2025-09-20 21:25:07 +00:00
2025-11-10 19:07:59 +00:00
sdb = stencil_db_from_package()
2025-10-18 21:20:40 +00:00
2025-09-30 21:11:14 +00:00
def test_list_symbols():
2025-09-20 21:25:07 +00:00
print('----')
#print(sdb.function_definitions)
2025-10-12 21:13:33 +00:00
for sym_name in sdb.stencil_definitions.keys():
2025-09-21 21:08:30 +00:00
print('\n-', sym_name)
2025-10-12 20:22:30 +00:00
#print(list(sdb.get_patch_positions(sym_name)))
2025-09-30 21:11:14 +00:00
def test_start_end_function():
2025-10-12 21:13:33 +00:00
for sym_name in sdb.stencil_definitions.keys():
2025-10-10 21:09:27 +00:00
symbol = sdb.elf.symbols[sym_name]
2025-09-30 21:11:14 +00:00
2025-10-12 20:22:30 +00:00
if symbol.relocations and symbol.relocations[-1].symbol.info == 'STT_NOTYPE':
2025-10-18 21:20:40 +00:00
print('-', sym_name, get_stencil_position(symbol), len(symbol.data))
2025-09-30 21:11:14 +00:00
start, end = get_stencil_position(symbol)
2025-10-12 20:22:30 +00:00
assert start >= 0 and end >= start and end <= len(symbol.data)
2025-09-30 21:11:14 +00:00
2025-10-11 20:53:55 +00:00
def test_aux_functions():
2025-10-12 21:13:33 +00:00
for sym_name in sdb.stencil_definitions.keys():
2025-10-11 20:53:55 +00:00
symbol = sdb.elf.symbols[sym_name]
for reloc in symbol.relocations:
if reloc.symbol.info != "STT_NOTYPE":
print(reloc.symbol.name, reloc.symbol.info)
2025-09-30 21:11:14 +00:00
if __name__ == "__main__":
2025-10-12 21:13:33 +00:00
test_aux_functions()