Skip to content

Commit

Permalink
move tests in tests folder
Browse files Browse the repository at this point in the history
  • Loading branch information
lmbsog0 committed Nov 5, 2021
1 parent 54a790a commit c61d613
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 14 deletions.
29 changes: 25 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,32 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
- name: Build binaries with Clang/LLVM
run: cd test_input && ./build.sh
run: cd tests && ./build.sh
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: boot
name: tests_input
path: |
test_input/*.elf
build/bin/*.bin
tests/*.elf
tests/*.bin
run-tests:
name: Run tests
needs: build-binaries
runs-on: ubuntu-20.04
container:
image: ghcr.io/sauci/pyelf:develop
credentials:
username: ${{secrets.PKG_REGISTRY_USERNAME}}
password: ${{secrets.PKG_REGISTRY_RW_TOKEN}}
volumes:
- ${{github.workspace}}:/usr/project/pyelf
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: tests_input
path: tests
- name: Run pytest tests
run: python3 -m pytest $(pwd) -v
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ docs/.build
docs/.static
docs/.templates
pyelf.egg-info/*
test_input/build
tests/build
test_input/*.asm
test_input/*.bin
test_input/*.elf
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ the bellow code snippet shows how to load an elf file and get some of its proper
```python
from pyelf import ElfFile

elf = ElfFile('test_input/input.elf')
elf = ElfFile('tests/input.elf')

# get a list of all symbols in file test_input/input.elf.
# get a list of all symbols in file tests/input.elf.
symbols = elf.symbols()
assert 'symbol_uint8' in symbols

Expand Down
12 changes: 6 additions & 6 deletions pyelf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from pyelf.pyelf import Address, ElfException, ElfFile

elf_files = (
os.path.join('test_input', 'big_endian.elf'),
os.path.join('test_input', 'little_endian.elf'))
os.path.join('tests', 'big_endian.elf'),
os.path.join('tests', 'little_endian.elf'))


def test_address_string_format():
Expand Down Expand Up @@ -62,7 +62,7 @@ def test_get_abi_info(elf_file):
('big_endian.elf', 'big'),
('little_endian.elf', 'little')))
def test_get_endianness(elf_file, expected_endianness):
elf_file = ElfFile(os.path.join('test_input', elf_file))
elf_file = ElfFile(os.path.join('tests', elf_file))
endianness = elf_file.endianness
assert endianness == expected_endianness

Expand All @@ -89,8 +89,8 @@ def test_get_not_existent_symbol(elf_file):


@pytest.mark.parametrize('elf_file, bin_file', (
(os.path.join('test_input', 'big_endian.elf'), os.path.join('test_input', 'big_endian.bin')),
(os.path.join('test_input', 'little_endian.elf'), os.path.join('test_input', 'little_endian.bin'))))
(os.path.join('tests', 'big_endian.elf'), os.path.join('tests', 'big_endian.bin')),
(os.path.join('tests', 'little_endian.elf'), os.path.join('tests', 'little_endian.bin'))))
def test_get_binary(elf_file, bin_file):
elf_file = ElfFile(elf_file)
with open(bin_file, 'rb') as fp:
Expand All @@ -100,7 +100,7 @@ def test_get_binary(elf_file, bin_file):

@pytest.mark.parametrize('elf_file', elf_files)
@pytest.mark.parametrize('address, expected_source_file, expected_line, expected_func_name', (
(0x30, '/usr/project/pyelf/test_input/main.c', 12, 'main'),))
(0x30, '/usr/project/pyelf/tests/main.c', 12, 'main'),))
def test_get_source_info(elf_file, address, expected_source_file, expected_line, expected_func_name):
elf_file = ElfFile(elf_file)
source_file, line, func_name = elf_file.get_source_info(address)
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pyelftools~=0.27
setuptools~=57.0.0
pytest~=6.2.5
pytest~=6.2.5
pytest-cov~=3.0.0
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c61d613

Please sign in to comment.