test fixed

This commit is contained in:
Nicolas 2025-10-04 23:07:47 +02:00
parent b3eace3be4
commit aca7e0e253
2 changed files with 9 additions and 7 deletions

View File

@ -14,10 +14,14 @@ def get_var_name(var: Any, scope: dict[str, Any] = globals()) -> list[str]:
return [name for name, value in scope.items() if value is var] return [name for name, value in scope.items() if value is var]
def stencil_db_from_package(arch: str = 'native', optimization: str = 'O3') -> stencil_database: def get_local_arch() -> str:
arch_translation_table = {'ARM64': 'x86_64'} arch_translation_table = {'ARM64': 'x86_64'}
return arch_translation_table.get(platform.machine(), platform.machine())
def stencil_db_from_package(arch: str = 'native', optimization: str = 'O3') -> stencil_database:
if arch == 'native': if arch == 'native':
arch = arch_translation_table.get(platform.machine(), platform.machine()) arch = get_local_arch()
stencil_data = pkgutil.get_data(__name__, f"obj/stencils_{arch}_{optimization}.o") stencil_data = pkgutil.get_data(__name__, f"obj/stencils_{arch}_{optimization}.o")
assert stencil_data, f"stencils_{arch}_{optimization} not found" assert stencil_data, f"stencils_{arch}_{optimization} not found"
return stencil_database(stencil_data) return stencil_database(stencil_data)

View File

@ -1,10 +1,8 @@
from copapy import stencil_database from copapy import stencil_database, stencil_db, get_local_arch
from copapy import stencil_db
import platform
def test_list_symbols(): def test_list_symbols():
arch = platform.machine() arch = get_local_arch()
sdb = stencil_database(f'src/copapy/obj/stencils_{arch}_O3.o') sdb = stencil_database(f'src/copapy/obj/stencils_{arch}_O3.o')
print('----') print('----')
#print(sdb.function_definitions) #print(sdb.function_definitions)
@ -14,7 +12,7 @@ def test_list_symbols():
def test_start_end_function(): def test_start_end_function():
arch = platform.machine() arch = get_local_arch()
sdb = stencil_database(f'src/copapy/obj/stencils_{arch}_O3.o') sdb = stencil_database(f'src/copapy/obj/stencils_{arch}_O3.o')
for sym_name in sdb.function_definitions.keys(): for sym_name in sdb.function_definitions.keys():
data = sdb.elf.symbols[sym_name].data data = sdb.elf.symbols[sym_name].data