Skip to content

Commit f1c6564

Browse files
added github pytest runner
1 parent 05016bc commit f1c6564

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

.github/workflows/test.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Python Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -e .
28+
29+
- name: Run tests
30+
run: make test

smda/common/labelprovider/ElfSymbolProvider.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,18 @@ def _parseOep(self, lief_result):
3232
def update(self, binary_info):
3333
#works both for PE and ELF
3434
self._func_symbols = {}
35-
if not binary_info.file_path:
35+
data = b""
36+
if binary_info.file_path:
37+
with open(binary_info.file_path, "rb") as fin:
38+
data = fin.read()
39+
return
40+
elif binary_info.raw_data:
41+
data = binary_info.raw_data
42+
else:
3643
return
37-
data = ""
38-
with open(binary_info.file_path, "rb") as fin:
39-
data = fin.read(16)
4044
if data[:4] != b"\x7FELF" or lief is None:
4145
return
42-
lief_binary = lief.parse(binary_info.file_path)
46+
lief_binary = lief.parse(data)
4347
self._parseOep(lief_binary)
4448
# TODO split resolution into API/dynamic part and local symbols
4549
self._parseExports(lief_binary)

tests/testFileFormatParsers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def testElfParsingWithBashlite(self):
7676
bashlite_binary_info = binary_info
7777
bashlite_disassembly = disasm._disassemble(binary_info)
7878
bashlite_unmapped_disassembly = disasm.disassembleUnmappedBuffer(bashlite_binary)
79-
assert bashlite_unmapped_disassembly.num_functions == 172
80-
# TODO test label extraction for ELF
79+
assert bashlite_unmapped_disassembly.num_functions == 177
80+
assert len([f.function_name for f in bashlite_unmapped_disassembly.getFunctions() if f.function_name]) == 174
8181

8282
def testMacOsParsingWithKomplex(self):
8383
disasm = Disassembler(config)

0 commit comments

Comments
 (0)