This commit is contained in:
Nicolas 2025-10-16 23:08:13 +02:00
commit 45d1007644
2 changed files with 41 additions and 7 deletions

View File

@ -58,13 +58,11 @@ jobs:
python tools/make_example.py
python tools/extract_code.py "bin/test.copapy" "bin/test.copapy.bin"
objdump -D -b binary -m i386:x86-64 --adjust-vma=0x1000 bin/test.copapy.bin > bin/test.copapy.asm
echo '<p>test.copapy.asm</p><pre>' >> $GITHUB_STEP_SUMMARY
cat bin/test.copapy.asm >> $GITHUB_STEP_SUMMARY
echo '</pre>' >> $GITHUB_STEP_SUMMARY
objdump -d -j .text src/copapy/obj/stencils_x86_64_O3.o > bin/stencils_x86_64_O3.asm
echo '<p>stencils_x86_64_O3.asm</p><pre>' >> $GITHUB_STEP_SUMMARY
cat bin/stencils_x86_64_O3.asm >> $GITHUB_STEP_SUMMARY
echo '</pre>' >> $GITHUB_STEP_SUMMARY
echo '<p>test.copapy.asm</p>' >> $GITHUB_STEP_SUMMARY
python tools/clean_asm.py bin/test.copapy.asm >> $GITHUB_STEP_SUMMARY
objdump -d -x src/copapy/obj/stencils_x86_64_O3.o > bin/stencils_x86_64_O3.asm
echo '<p>stencils_x86_64_O3.asm</p>' >> $GITHUB_STEP_SUMMARY
python tools/clean_asm.py bin/stencils_x86_64_O3.asm >> $GITHUB_STEP_SUMMARY
- name: Run tests with pytest
run: pytest

36
tools/clean_asm.py Normal file
View File

@ -0,0 +1,36 @@
import argparse
import re
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("path", type=str, help="Input file path")
args = parser.parse_args()
regex = r"(\:\n)(.*?)(^[^\n]+\n[^\n]+result_.*?\n\n)"
subst = "\\g<1><b>\\g<2></b><i>\\g<3></i>"
with open(args.path, 'rt') as f:
text = f.read()
outp_flag = "Disassembly of section .text" not in text
text = text.replace('\t', ' ' * 4)
text = text.replace('>', '&gt;')
text = text.replace('<', '&lt;')
text = re.sub(regex, subst, text, 0, re.MULTILINE | re.DOTALL)
text = re.sub(r"(?<= ) ", "&nbsp;", text, 0, re.MULTILINE | re.DOTALL)
print('<code>')
for line in text.splitlines():
if outp_flag:
print(line + '<br>')
if "Disassembly of section .text:" in line:
outp_flag = True
print('</code>')
if __name__ == "__main__":
main()