Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Artifacts for samples that crash #447

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/extended-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,13 @@ jobs:
run: |
docker build -t dewolf .
- name: Run Tests
id: run_tests
run: |
docker run dewolf make extendedtests
docker run -v "$(pwd)"/artifacts:/opt/dewolf/crash_reports dewolf make extendedtests
- name: Upload Crash Reports
if: ${{ failure() && steps.run_tests.conclusion == 'failure' }} # Only run if previous steps fail
uses: actions/upload-artifact@v4
with:
name: crash-reports
path: artifacts/*
retention-days: 7 # Adjust retention as needed
9 changes: 8 additions & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@ jobs:
docker run dewolf make check-format
- name: Run Tests
run: |
docker run dewolf make
docker run -v "$(pwd)"/artifacts:/opt/dewolf/crash_reports dewolf make
- name: Upload Crash Reports
if: ${{ failure() && steps.run_tests.conclusion == 'failure' }} # Only run if previous steps fail
uses: actions/upload-artifact@v4
with:
name: crash-reports
path: artifacts/*
retention-days: 7 # Adjust retention as needed
21 changes: 19 additions & 2 deletions tests/test_sample_binaries.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import re
import shutil
import subprocess
from pathlib import Path

import pytest
from decompiler.backend.codegenerator import FAIL_MESSAGE
Expand All @@ -8,8 +10,23 @@
def test_sample(test_cases):
"""Test the decompiler with the given test case."""
sample, function_name = test_cases
output = subprocess.run(("python", "decompile.py", sample, function_name), check=True, capture_output=True).stdout.decode("utf-8")
assert FAIL_MESSAGE not in output
try:
output = subprocess.run(("python", "decompile.py", sample, function_name), check=True, capture_output=True).stdout.decode("utf-8")
failed = FAIL_MESSAGE in output
except subprocess.CalledProcessError as e:
failed = True
if failed:
__add_sample_to_crashed_sample_folder(sample, function_name)
assert not failed


def __add_sample_to_crashed_sample_folder(sample, function_name):
"""Copy the sample to the crashed sample folder."""
crash_dir = Path("crash_reports")
crash_dir.mkdir(exist_ok=True)
# Copy the binary to the crash directory
output_file = crash_dir / ("_".join(sample.parts[3:]) + "_" + function_name)
shutil.copy(sample, output_file)


def test_globals():
Expand Down
Loading