From patchwork Fri Oct 14 18:20:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13007261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6028EC433FE for ; Fri, 14 Oct 2022 18:20:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230008AbiJNSUZ (ORCPT ); Fri, 14 Oct 2022 14:20:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229818AbiJNSUY (ORCPT ); Fri, 14 Oct 2022 14:20:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 280EC32D91; Fri, 14 Oct 2022 11:20:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C233F61BD5; Fri, 14 Oct 2022 18:20:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 229CEC433B5; Fri, 14 Oct 2022 18:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665771621; bh=7CUd+8iHQxma0frVDstHzhcs63DWTzPkijl4B9vgrnU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eEDZ+WYUEoMKto9LLJNdgXZtZ9TR8V6rTmfJevJWLNvVOKddfP5wPzzg5KhcK6iM/ KRj2smaq2CxJkfovhPOI/FvkvG0Nycfe+WQUJ7K4T3CbKTC/x5oqqWgdfcaaFqj6Mg DRQiUn2C8ONvXqEChe7zkri7dlpEr58jsWLf1Qnwue3PRutiYWsy+C0OH0UOEyNO6D vCe1PeVnjeuiFoo1aGKMpOL9z4Im9OIfF/D7p2A4rAO6v9HDaZk4QROYBEa9g5XzCx pJO5BKAS5cU+mb1+IUgAcNWYktsJXlCSMKYYZyduqc9kHMKT8TboUh+NVnuaHdiHKU 2VsCOmX+DkoMQ== Date: Fri, 14 Oct 2022 11:20:20 -0700 From: "Darrick J. Wong" To: guaneryu@gmail.com, zlang@redhat.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Subject: [PATCH v2.2 1/2] check: detect and preserve all coredumps made by a test Message-ID: References: <166553910766.422356.8069826206437666467.stgit@magnolia> <166553911331.422356.4424521847397525024.stgit@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <166553911331.422356.4424521847397525024.stgit@magnolia> Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Darrick J. Wong If someone sets kernel.core_uses_pid (or kernel.core_pattern), any coredumps generated by fstests might have names that are longer than just "core". Since the pid isn't all that useful by itself, let's record the coredumps by hash when we save them, so that we don't waste space storing identical crash dumps. Signed-off-by: Darrick J. Wong Reviewed-by: Zorro Lang --- v2.1: use REPORT_DIR per maintainer suggestion v2.2: use seqres, not REPORT_DIR, since REPORT_DIR doesnt work --- check | 26 ++++++++++++++++++++++---- common/rc | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/check b/check index 3b7bb84ca2..9bebd2a1b9 100755 --- a/check +++ b/check @@ -923,11 +923,19 @@ function run_section() sts=$? fi - if [ -f core ]; then - _dump_err_cont "[dumped core]" - mv core $RESULT_BASE/$seqnum.core + # If someone sets kernel.core_pattern or kernel.core_uses_pid, + # coredumps generated by fstests might have a longer name than + # just "core". Use globbing to find the most common patterns, + # assuming there are no other coredump capture packages set up. + local cores=0 + for i in core core.*; do + test -f "$i" || continue + if ((cores++ == 0)); then + _dump_err_cont "[dumped core]" + fi + (_adjust_oom_score 250; _save_coredump "$i") tc_status="fail" - fi + done if [ -f $seqres.notrun ]; then $timestamp && _timestamp @@ -960,6 +968,16 @@ function run_section() # of the check script itself. (_adjust_oom_score 250; _check_filesystems) || tc_status="fail" _check_dmesg || tc_status="fail" + + # Save any coredumps from the post-test fs checks + for i in core core.*; do + test -f "$i" || continue + if ((cores++ == 0)); then + _dump_err_cont "[dumped core]" + fi + (_adjust_oom_score 250; _save_coredump "$i") + tc_status="fail" + done fi # Reload the module after each test to check for leaks or diff --git a/common/rc b/common/rc index d877ac77a0..1a0f167f84 100644 --- a/common/rc +++ b/common/rc @@ -4949,6 +4949,28 @@ _create_file_sized() return $ret } +# Save an arbitrary coredump to the report directory. +_save_coredump() +{ + local path="$1" + + if [ -z "$seqres" ]; then + echo "$path: seqres is not defined; ignoring coredump!" + return 1 + fi + + local core_hash="$(_md5_checksum "$path")" + local out_file="${seqres}.core.${core_hash}" + + if [ -s "$out_file" ]; then + rm -f "$path" + return + fi + rm -f "$out_file" + + mv "$path" "$out_file" +} + init_rc ################################################################################