Files
lief-project-LIEF/tests/elf/test_binary_size.py
T
Romain Thomas 70c842f726 enhance testing
2026-03-17 09:01:40 +01:00

22 lines
641 B
Python

import lief
import pathlib
from utils import get_sample, check_layout
def test_builder_size():
FILES = [
"ELF/batch-x86-64/test.clang.fcf_protection.bin",
"ELF/batch-x86-64/test.clang.fcf_protection.nopie.bin",
"ELF/batch-x86-64/test.clang.fullstatic.nothread.bin",
]
for file in FILES:
infile = pathlib.Path(get_sample(file))
target = lief.ELF.parse(infile)
config = lief.ELF.Builder.config_t()
config.notes = False
raw = target.write_to_bytes(config)
assert len(raw) <= infile.stat().st_size
new = lief.ELF.parse(raw)
check_layout(new)