Skip to content

Commit 1a71b03

Browse files
authored
Merge pull request #1791 from volatilityfoundation/feature/code-coverage
Add in coverage recording to the test process
2 parents 28a72b8 + f4a2c7a commit 1a71b03

File tree

3 files changed

+65
-54
lines changed

3 files changed

+65
-54
lines changed

.github/workflows/test.yaml

Lines changed: 61 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,70 @@
11
name: Test Volatility3
22
on: [push, pull_request]
33
jobs:
4-
54
build:
65
runs-on: ubuntu-22.04
76
strategy:
87
matrix:
98
python-version: ["3.8"]
109
steps:
11-
- uses: actions/checkout@v4
12-
- name: Set up Python ${{ matrix.python-version }}
13-
uses: actions/setup-python@v5
14-
with:
15-
python-version: ${{ matrix.python-version }}
16-
17-
- name: Install dependencies
18-
run: |
19-
python -m pip install --upgrade pip Cmake build
20-
pip install .[test]
21-
22-
- name: Build PyPi packages
23-
run: |
24-
python -m build
25-
26-
- name: Download images
27-
run: |
28-
mkdir test_images
29-
cd test_images
30-
curl -sLO "https://downloads.volatilityfoundation.org/volatility3/images/linux-sample-1.bin.gz"
31-
gunzip linux-sample-1.bin.gz
32-
curl -sLO "https://downloads.volatilityfoundation.org/volatility3/images/win-xp-laptop-2005-06-25.img.gz"
33-
gunzip win-xp-laptop-2005-06-25.img.gz
34-
curl -sLO "https://downloads.volatilityfoundation.org/volatility3/images/win-10_19041-2025_03.dmp.gz"
35-
gunzip win-10_19041-2025_03.dmp.gz
36-
cd -
37-
38-
- name: Download and Extract symbols
39-
run: |
40-
cd ./volatility3/symbols
41-
curl -sLO https://downloads.volatilityfoundation.org/volatility3/symbols/linux.zip
42-
curl -sLO https://downloads.volatilityfoundation.org/volatility3/symbols/symbols_win-10_19041-2025_03.zip
43-
unzip linux.zip
44-
unzip symbols_win-10_19041-2025_03.zip
45-
cd -
46-
47-
- name: Testing...
48-
run: |
49-
# VolShell
50-
pytest ./test/plugins/windows/windows.py --volatility=volshell.py --image-dir=./test_images -k test_windows_volshell -v
51-
pytest ./test/plugins/linux/linux.py --volatility=volshell.py --image-dir=./test_images -k test_linux_volshell -v
52-
53-
# Volatility
54-
pytest ./test/plugins/windows/windows.py --volatility=vol.py --image=./test_images/win-10_19041-2025_03.dmp -k "test_windows and not test_windows_volshell" -v --durations=0
55-
pytest ./test/plugins/linux/linux.py --volatility=vol.py --image-dir=./test_images -k "test_linux and not test_linux_volshell" -v --durations=0
56-
57-
- name: Clean up post-test
58-
run: |
59-
rm -rf test_images
60-
cd volatility3/symbols
61-
rm -rf linux
62-
rm -rf linux.zip
63-
cd -
10+
- uses: actions/checkout@v4
11+
- name: Set up Python ${{ matrix.python-version }}
12+
uses: actions/setup-python@v5
13+
with:
14+
python-version: ${{ matrix.python-version }}
15+
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip Cmake build
19+
pip install .[test]
20+
21+
- name: Build PyPi packages
22+
run: |
23+
python -m build
24+
25+
- name: Download images
26+
run: |
27+
mkdir test_images
28+
cd test_images
29+
curl -sLO "https://downloads.volatilityfoundation.org/volatility3/images/linux-sample-1.bin.gz"
30+
gunzip linux-sample-1.bin.gz
31+
curl -sLO "https://downloads.volatilityfoundation.org/volatility3/images/win-xp-laptop-2005-06-25.img.gz"
32+
gunzip win-xp-laptop-2005-06-25.img.gz
33+
curl -sLO "https://downloads.volatilityfoundation.org/volatility3/images/win-10_19041-2025_03.dmp.gz"
34+
gunzip win-10_19041-2025_03.dmp.gz
35+
cd -
36+
37+
- name: Download and Extract symbols
38+
run: |
39+
cd ./volatility3/symbols
40+
curl -sLO https://downloads.volatilityfoundation.org/volatility3/symbols/linux.zip
41+
curl -sLO https://downloads.volatilityfoundation.org/volatility3/symbols/symbols_win-10_19041-2025_03.zip
42+
unzip linux.zip
43+
unzip symbols_win-10_19041-2025_03.zip
44+
cd -
45+
46+
- name: Testing...
47+
run: |
48+
# VolShell
49+
pytest --cov-append --cov-report=html --cov= ./test/plugins/windows/windows.py --volatility=volshell.py --image-dir=./test_images -k test_windows_volshell -v
50+
pytest --cov-append --cov-report=html --cov= ./test/plugins/linux/linux.py --volatility=volshell.py --image-dir=./test_images -k test_linux_volshell -v
51+
52+
# Volatility
53+
pytest --cov-append --cov-report=html --cov= ./test/plugins/windows/windows.py --volatility=vol.py --image=./test_images/win-10_19041-2025_03.dmp -k "test_windows and not test_windows_volshell" -v --durations=0
54+
pytest --cov-append --cov-report=html --cov= ./test/plugins/linux/linux.py --volatility=vol.py --image-dir=./test_images -k "test_linux and not test_linux_volshell" -v --durations=0
55+
56+
- name: Create coverage artifacts
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: code-coverage-report
60+
path: htmlcov
61+
overwrite: true
62+
retention-days: 7
63+
64+
- name: Clean up post-test
65+
run: |
66+
rm -rf test_images
67+
cd volatility3/symbols
68+
rm -rf linux
69+
rm -rf linux.zip
70+
cd -

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ ENV/
4343

4444
# PyTest cache files
4545
.pytest_cache/
46+
47+
# Coverage cache
48+
.coverage

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ dev = [
4545
test = [
4646
"volatility3[dev]",
4747
"pytest>=8.3.3,<9",
48+
"pytest-cov>=5,<7",
4849
"yara-x>=0.10.0,<1",
4950
]
5051

0 commit comments

Comments
 (0)