From: "Darrick J. Wong" <djwong@kernel.org>
To: Zorro Lang <zlang@redhat.com>
Cc: fstests@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/2] check: collect core dumps from systemd-coredump
Date: Tue, 12 Aug 2025 11:14:50 -0700 [thread overview]
Message-ID: <20250812181450.GA7952@frogsfrogsfrogs> (raw)
In-Reply-To: <20250802134700.khtlw7thzqyclfnt@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com>
On Sat, Aug 02, 2025 at 09:47:00PM +0800, Zorro Lang wrote:
> On Tue, Jul 29, 2025 at 01:11:06PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > On modern RHEL (>=8) and Debian KDE systems, systemd-coredump can be
> > installed to capture core dumps from crashed programs. If this is the
> > case, we would like to capture core dumps from programs that crash
> > during the test. Set up an (admittedly overwrought) pipeline to extract
> > dumps created during the test and then capture them the same way that we
> > pick up "core" and "core.$pid" files.
> >
> > Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
> > ---
> > check | 2 ++
> > common/rc | 44 ++++++++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 46 insertions(+)
> >
> >
> > diff --git a/check b/check
> > index ce7eacb7c45d9e..77581e438c46b9 100755
> > --- a/check
> > +++ b/check
> > @@ -924,6 +924,7 @@ function run_section()
> > $1 == "'$seqnum'" {lasttime=" " $2 "s ... "; exit} \
> > END {printf "%s", lasttime}' "$check.time"
> > rm -f core $seqres.notrun
> > + _start_coredumpctl_collection
> >
> > start=`_wallclock`
> > $timestamp && _timestamp
> > @@ -957,6 +958,7 @@ function run_section()
> > # just "core". Use globbing to find the most common patterns,
> > # assuming there are no other coredump capture packages set up.
> > local cores=0
> > + _finish_coredumpctl_collection
> > for i in core core.*; do
> > test -f "$i" || continue
> > if ((cores++ == 0)); then
> > diff --git a/common/rc b/common/rc
> > index 04b721b7318a7e..e4c4d05387f44e 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -5034,6 +5034,50 @@ _check_kmemleak()
> > fi
> > }
> >
> > +# Current timestamp, in a format that systemd likes
> > +_systemd_now() {
> > + timedatectl show --property=TimeUSec --value
> > +}
> > +
> > +# Do what we need to do to capture core dumps from coredumpctl
> > +_start_coredumpctl_collection() {
> > + command -v coredumpctl &>/dev/null || return
> > + command -v timedatectl &>/dev/null || return
> > + command -v jq &>/dev/null || return
> > +
> > + sysctl kernel.core_pattern | grep -q systemd-coredump || return
>
> # rpm -qf `which coredumpctl`
> systemd-udev-252-53.el9.x86_64
> # rpm -qf `which timedatectl`
> systemd-252-53.el9.x86_64
> # rpm -qf `which jq`
> jq-1.6-17.el9.x86_64
> # rpm -qf /usr/lib/systemd/systemd-coredump
> systemd-udev-252-53.el9.x86_64
>
> So we have 3 optional running dependences, how about metion that in README?
Done.
--D
> Thanks,
> Zorro
>
> > + COREDUMPCTL_START_TIMESTAMP="$(_systemd_now)"
> > +}
> > +
> > +# Capture core dumps from coredumpctl.
> > +#
> > +# coredumpctl list only supports json output as a machine-readable format. The
> > +# human-readable format intermingles spaces from the timestamp with actual
> > +# column separators, so we cannot parse that sanely. The json output is an
> > +# array of:
> > +# {
> > +# "time" : 1749744847150926,
> > +# "pid" : 2297,
> > +# "uid" : 0,
> > +# "gid" : 0,
> > +# "sig" : 6,
> > +# "corefile" : "present",
> > +# "exe" : "/run/fstests/e2fsprogs/fuse2fs",
> > +# "size" : 47245
> > +# },
> > +# So we use jq to filter out lost corefiles, then print the pid and exe
> > +# separated by a pipe and hope that nobody ever puts a pipe in an executable
> > +# name.
> > +_finish_coredumpctl_collection() {
> > + test -n "$COREDUMPCTL_START_TIMESTAMP" || return
> > +
> > + coredumpctl list --since="$COREDUMPCTL_START_TIMESTAMP" --json=short 2>/dev/null | \
> > + jq --raw-output 'map(select(.corefile == "present")) | map("\(.pid)|\(.exe)") | .[]' | while IFS='|' read pid exe; do
> > + test -e "core.$pid" || coredumpctl dump --output="core.$pid" "$pid" "$exe" &>> $seqres.full
> > + done
> > + unset COREDUMPCTL_START_TIMESTAMP
> > +}
> > +
> > # don't check dmesg log after test
> > _disable_dmesg_check()
> > {
> >
>
>
next prev parent reply other threads:[~2025-08-12 18:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 20:08 [PATCHSET 3/3] fstests: integrate with coredump capturing Darrick J. Wong
2025-07-29 20:10 ` [PATCH 1/2] fsstress: don't abort when stat(".") returns EIO Darrick J. Wong
2025-07-30 14:23 ` Christoph Hellwig
2025-07-30 14:55 ` Darrick J. Wong
2025-07-29 20:11 ` [PATCH 2/2] check: collect core dumps from systemd-coredump Darrick J. Wong
2025-08-02 13:47 ` Zorro Lang
2025-08-12 18:14 ` Darrick J. Wong [this message]
2025-08-13 15:18 ` [PATCH v2 " Darrick J. Wong
-- strict thread matches above, loose matches on Subject: below --
2025-10-21 18:39 [PATCHSET 2/2] fstests: integrate with coredump capturing Darrick J. Wong
2025-10-21 18:42 ` [PATCH 2/2] check: collect core dumps from systemd-coredump Darrick J. Wong
2025-10-22 4:24 ` Christoph Hellwig
2025-10-22 4:28 ` Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250812181450.GA7952@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=zlang@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox