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

ci(linux): collect core dumps #195

Merged
merged 1 commit into from
Sep 6, 2023
Merged
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
11 changes: 6 additions & 5 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ jobs:
python3.{5..11} \
python3.10-full python3.10-dev
python3.10 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r test/requirements.txt
- name: Compile Austin
run: |
autoreconf --install
Expand All @@ -168,14 +173,10 @@ jobs:
- name: Run tests
run: |
echo "core.%p" | sudo tee /proc/sys/kernel/core_pattern
ulimit -c unlimited
python3.10 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r test/requirements.txt
.venv/bin/pytest --pastebin=failed -sr fE -n auto || true
sudo -E env PATH="$PATH" .venv/bin/pytest --pastebin=failed -sr fE -n auto || true
deactivate
- name: Generate Cobertura report
run: gcovr --xml ./cobertura.xml -r src/
Expand Down
44 changes: 34 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ jobs:
sudo apt-get update
sudo apt-get -y install \
valgrind \
gdb \
systemd-coredump
gdb

- name: Install Python
uses: actions/setup-python@v4
Expand All @@ -114,37 +113,61 @@ jobs:
source .venv/bin/activate
pip install --upgrade pip
pip install -r test/requirements.txt

- name: Set core dump file pattern
run: |
echo "core.%p" | sudo tee /proc/sys/kernel/core_pattern

ulimit -c unlimited
python3.10 -c "import ctypes;ctypes.string_at(0)" || true
ls core.*
rm core.*

- name: Run unit tests
run: .venv/bin/pytest -sv test/cunit
run: |
ulimit -c unlimited
.venv/bin/pytest -sv test/cunit

- name: Run functional Austin tests (with sudo)
run: sudo -E env PATH="$PATH" .venv/bin/pytest --pastebin=failed -svr a test/functional -n auto -k "not austinp"
run: |
ulimit -c unlimited
sudo -E env PATH="$PATH" .venv/bin/pytest --pastebin=failed -svr a test/functional -n auto -k "not austinp"
if: always()

- name: Run functional Austin tests (without sudo)
run: .venv/bin/pytest --pastebin=failed -svr a test/functional -n auto -k "not austinp"
run: |
ulimit -c unlimited
.venv/bin/pytest --pastebin=failed -svr a test/functional -n auto -k "not austinp"
if: always()

- name: Run functional austinp tests (with sudo)
run: sudo -E env PATH="$PATH" .venv/bin/pytest --pastebin=failed -svr a test/functional -n auto -k "austinp"
run: |
ulimit -c unlimited
sudo -E env PATH="$PATH" .venv/bin/pytest --pastebin=failed -svr a test/functional -n auto -k "austinp"
if: always()

- name: Run functional austinp tests (without sudo)
run: .venv/bin/pytest --pastebin=failed -svr a test/functional -n auto -k "austinp"
run: |
ulimit -c unlimited
.venv/bin/pytest --pastebin=failed -svr a test/functional -n auto -k "austinp"
if: always()

- name: Run integrity tests (with sudo)
run: sudo -E env PATH="$PATH" .venv/bin/pytest --pastebin=failed -svr a test/integrity
run: |
ulimit -c unlimited
sudo -E env PATH="$PATH" .venv/bin/pytest --pastebin=failed -svr a test/integrity
if: always()

- name: Run integrity tests (without sudo)
run: .venv/bin/pytest --pastebin=failed -svr a test/integrity
run: |
ulimit -c unlimited
.venv/bin/pytest --pastebin=failed -svr a test/integrity
if: always()

- name: Run support tests
run: .venv/bin/pytest -sv test/support
run: |
ulimit -c unlimited
.venv/bin/pytest -sv test/support
if: always()

wheels-linux:
Expand Down Expand Up @@ -484,6 +507,7 @@ jobs:
- name: Run data validation
run: |
ulimit -c unlimited
echo "core.%p" | sudo tee /proc/sys/kernel/core_pattern

source .venv/bin/activate
python scripts/validation.py --ignore-errors
Expand Down
6 changes: 4 additions & 2 deletions test/cunit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import typing as t
from pathlib import Path
from subprocess import PIPE
from subprocess import run
from test.cunit import SRC
from test.utils import bt
from test.utils import run
from types import FunctionType

import pytest
Expand Down Expand Up @@ -55,7 +55,9 @@ def _(*_, **__):

if result.returncode == -11:
binary_name = Path(module).stem.replace("test_", "")
raise SegmentationFault(bt((SRC / binary_name).with_suffix(".so")))
raise SegmentationFault(
bt((SRC / binary_name).with_suffix(".so"), result.pid)
)

raise CUnitTestFailure(
f"\n{result.stdout.decode()}\n"
Expand Down
12 changes: 7 additions & 5 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ def apport_unpack(report: Path, target_dir: Path):
).decode()


def bt(binary: Path) -> str:
if Path("core").is_file():
return gdb(["bt full", "q"], str(binary), "core")
def bt(binary: Path, pid: int) -> str:
core_file = f"core.{pid}"
if Path(core_file).is_file():
return gdb(["bt full", "q"], str(binary), core_file)

# On Ubuntu, apport puts crashes in /var/crash
crash_dir = Path("/var/crash")
Expand Down Expand Up @@ -155,7 +156,8 @@ def collect_logs(variant: str, pid: int) -> List[str]:
EXEEXT = ".exe" if platform.system() == "Windows" else ""


# Taken from the subprocess module
# Taken from the subprocess module. We make our own version that can also
# propagate the PID.
def run(
*popenargs, input=None, capture_output=False, timeout=None, check=False, **kwargs
):
Expand Down Expand Up @@ -248,7 +250,7 @@ def __call__(
raise

if result.returncode in (-11, 139): # SIGSEGV
print(bt(self.path))
print(bt(self.path, result.pid))

if mojo and not ({"-o", "-w", "--output", "--where"} & set(args)):
# We produce MOJO binary data only if we are not writing to file
Expand Down
Loading