example in readme fixed and test for the readme example added

This commit is contained in:
Nicolas Kruse 2025-04-16 10:16:30 +02:00
parent 7d2028c2bb
commit a0658af0b0
2 changed files with 10 additions and 2 deletions

View File

@ -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 |
|------:|--------------------|----------------------|-------------|

View File

@ -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()