ci: fixed make_example.py and path names

This commit is contained in:
Nicolas 2025-12-07 12:38:55 +01:00
parent d041312315
commit 9b78947202
4 changed files with 22 additions and 71 deletions

View File

@ -68,10 +68,10 @@ jobs:
bash tools/create_asm.sh
echo '<p>example</p>' >> $GITHUB_STEP_SUMMARY
python tools/clean_asm.py build/asm/example.asm >> $GITHUB_STEP_SUMMARY
python tools/clean_asm.py build/runner/example.asm >> $GITHUB_STEP_SUMMARY
echo '<p>stencils_x86_64_O3.o</p>' >> $GITHUB_STEP_SUMMARY
python tools/clean_asm.py build/asm/stencils.asm >> $GITHUB_STEP_SUMMARY
python tools/clean_asm.py build/runner/stencils.asm >> $GITHUB_STEP_SUMMARY
- name: Run tests with pytest
run: pytest

View File

@ -28,7 +28,7 @@ def main() -> None:
if outp_flag:
print(line + '<br>')
if "Disassembly of section .text:" in line:
if "Disassembly of section .text" in line:
outp_flag = True
print('</code>')

View File

@ -5,29 +5,29 @@ set -v
mkdir -p build/runner
arch=$(python3 -c "import copapy; print(copapy._stencils.detect_process_arch())")
cparch=$(python3 -c "import copapy; print(copapy._stencils.detect_process_arch())")
# Disassemble stencil object file
objdump -d -x src/copapy/obj/stencils_${arch}_O3.o > build/runner/stencils.asm
objdump -d -x src/copapy/obj/stencils_${cparch}_O3.o > build/runner/stencils.asm
# Create example code disassembly
python3 tools/make_example.py
build/runner/coparun build/runner/test.copapy build/runner/test.copapy.bin
if [ $(arch) = 'x86_64' ]; then
arch="i386:x86-64"
elif [ $(arch) = 'x86' ]; then
arch="i386"
elif [ $(arch) = 'arm64' ]; then
arch="aarch64"
elif [ $(arch) = 'armv6' ]; then
arch="arm"
elif [ $(arch) = 'armv7' ]; then
arch="arm"
if [ "$cparch" = 'x86_64' ]; then
cparch="i386:x86-64"
elif [ "$cparch" = 'x86' ]; then
cparch="i386"
elif [ "$cparch" = 'arm64' ]; then
cparch="aarch64"
elif [ "$cparch" = 'armv6' ]; then
cparch="arm"
elif [ "$cparch" = 'armv7' ]; then
cparch="arm"
fi
echo "Archtitecture: '$arch'"
echo "Archtitecture: '$cparch'"
objdump -D -b binary -m $arch --adjust-vma=0x10000 build/runner/test.copapy.bin > build/runner/example.asm
objdump -D -b binary -m $cparch --adjust-vma=0x10000 build/runner/test.copapy.bin > build/runner/example.asm
rm build/runner/test.copapy.bin

View File

@ -4,7 +4,7 @@ from copapy._binwrite import Command
import copapy as cp
def compile_to_x86_64() -> None:
def compile_example(arch: str = 'native') -> None:
"""Test compilation of a simple program for x86_64."""
c1 = value(9.0)
@ -16,65 +16,16 @@ def compile_to_x86_64() -> None:
out = [Write(r) for r in ret]
sdb = stencil_db_from_package('x86_64')
sdb = stencil_db_from_package(arch)
dw, _ = compile_to_dag(out, sdb)
dw.write_com(Command.DUMP_CODE)
print('* Data to runner:')
dw.print()
#print('* Data to runner:')
#dw.print()
dw.to_file('build/runner/test.copapy')
def compile_to_x86() -> None:
"""Test compilation of a simple program for x86 32 bit."""
c1 = value(9.0)
#ret = [c1 / 4, c1 / -4, c1 // 4, c1 // -4, (c1 * -1) // 4]
ret = [c1 // 3.3 + 5]
#ret = [cp.sqrt(c1)]
#c2 = cp._math.get_42()
#ret = [c2]
ret = [cp.sin(value(2.5))]
out = [Write(r) for r in ret]
sdb = stencil_db_from_package('x86')
dw, _ = compile_to_dag(out, sdb)
dw.write_com(Command.DUMP_CODE)
print('* Data to runner:')
dw.print()
dw.to_file('build/runner/test-x86.copapy')
def compile_to_aarch64() -> None:
"""Test compilation of a simple program for arm64."""
c1 = value(9.0)
#ret = [c1 / 4, c1 / -4, c1 // 4, c1 // -4, (c1 * -1) // 4]
#ret = [cp.sin(c1), cp.sqrt(c1) + 5]
ret = [c1 // 3.3 + 5]
#c2 = cp._math.get_42()
#ret = [c2]
out = [Write(r) for r in ret]
sdb = stencil_db_from_package('arm64')
dw, _ = compile_to_dag(out, sdb)
dw.write_com(Command.DUMP_CODE)
print('* Data to runner:')
dw.print()
dw.to_file('build/runner/test-arm64.copapy')
if __name__ == "__main__":
compile_to_x86_64()
compile_to_x86()
compile_to_aarch64()
compile_example()