2025-11-10 19:07:59 +00:00
|
|
|
from copapy._stencils import get_stencil_position
|
2025-11-09 22:23:24 +00:00
|
|
|
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-01 21:09:49 +00:00
|
|
|
|
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
|
|
|
|
2026-03-03 13:47:53 +00:00
|
|
|
if symbol.section and symbol.section.name == '.text':
|
|
|
|
|
print('SKIP', sym_name, '(Aux function, not a stencil)')
|
|
|
|
|
continue
|
2025-09-30 21:11:14 +00:00
|
|
|
|
2026-03-03 13:47:53 +00:00
|
|
|
if symbol.section:
|
|
|
|
|
function_size = symbol.section.fields['sh_size'] # len(symbol.data) excludes nop after the function
|
2025-10-12 20:22:30 +00:00
|
|
|
|
2026-03-03 13:47:53 +00:00
|
|
|
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)
|
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()
|