From a0658af0b061f4d26f35f54216b38e5c2f348ed4 Mon Sep 17 00:00:00 2001 From: Nicolas Kruse Date: Wed, 16 Apr 2025 10:16:30 +0200 Subject: [PATCH] example in readme fixed and test for the readme example added --- README.md | 4 ++-- tests/test_readme_example.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 tests/test_readme_example.py diff --git a/README.md b/README.md index d5eb3d2..75af0f8 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Example code and its outputs: ```python import pelfy -elf = pelfy.open_elf_file('obj/test-c-riscv64-linux-gnu-gcc-12-O3.o') +elf = pelfy.open_elf_file('tests/obj/test-c-riscv64-linux-gnu-gcc-12-O3.o') elf.sections ``` | index | name | type | description | @@ -58,7 +58,7 @@ elf.functions | 14 | mul_float_float | STT_FUNC | 12 | STB_GLOBAL | Symbol is a code object | | 15 | read_float | STT_FUNC | 16 | STB_GLOBAL | Symbol is a code object | ```python -elf.symbols['read_float'].get_relocations() +elf.symbols['read_float'].relocations ``` | index | symbol name | type | calculation | |------:|--------------------|----------------------|-------------| diff --git a/tests/test_readme_example.py b/tests/test_readme_example.py new file mode 100644 index 0000000..2a77956 --- /dev/null +++ b/tests/test_readme_example.py @@ -0,0 +1,8 @@ +import pelfy + +def test_readme_example(): + elf = pelfy.open_elf_file('tests/obj/test-c-riscv64-linux-gnu-gcc-12-O3.o') + + assert ' description ' in elf.sections.to_markdown() + assert ' stb ' in elf.functions.to_markdown() + assert ' symbol name ' in elf.symbols['read_float'].relocations.to_markdown() \ No newline at end of file