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

tests/core-dump: check that core dumps can be generated on UC #13284

Merged
merged 1 commit into from
Oct 16, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/core/core-dump/core-dump-snap/bin/crash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash -e

ulimit -c unlimited
while true
do sleep 100
done
8 changes: 8 additions & 0 deletions tests/core/core-dump/core-dump-snap/meta/snap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: core-dump-snap
base: ##BASE##
type: app
version: 1.0
apps:
crash-svc:
command: bin/crash.sh
daemon: simple
27 changes: 27 additions & 0 deletions tests/core/core-dump/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
summary: Make sure we can generate core dumps on UC

execute: |
# To get VERSION_ID defined
. /etc/os-release
if [ "$VERSION_ID" = 16 ]; then
sed -i '/base: ##BASE##/d' core-dump-snap/meta/snap.yaml
else
BASE=core"$VERSION_ID"
sed -i "s/##BASE##/$BASE/" core-dump-snap/meta/snap.yaml
fi

# Install snap with a service that simply waits
DUMP_SNAP_FILE=core-dump-snap.snap
snap pack core-dump-snap --filename="$DUMP_SNAP_FILE"
snap install --dangerous "$DUMP_SNAP_FILE"

# Allow suid programs like snap-confine to produce a core dump
echo 1 > /proc/sys/fs/suid_dumpable
# Make sure that dumps are produced in a place writable from snap context
echo "/tmp/core.%p" > /proc/sys/kernel/core_pattern

CRASH_PID=$(retry --wait 1 -n 5 pgrep crash.sh)
kill -ABRT "$CRASH_PID"

# A core dump file should be generated in little time
retry --wait 1 -n 5 sh -c "stat /tmp/snap-private-tmp/snap.core-dump-snap/tmp/core.$CRASH_PID"