copapy/tests/test_stencil_db.py

39 lines
1.1 KiB
Python
Raw Normal View History

2025-10-07 21:20:43 +00:00
from copapy import stencil_database, stencil_db
import platform
2025-09-20 21:25:07 +00:00
2025-10-11 20:53:55 +00:00
arch = platform.machine()
sdb = stencil_database(f'src/copapy/obj/stencils_{arch}_O3.o')
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':
print('-', sym_name, stencil_db.get_stencil_position(symbol), len(symbol.data))
2025-09-30 21:11:14 +00:00
2025-10-12 20:22:30 +00:00
start, end = stencil_db.get_stencil_position(symbol)
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()