public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: guaneryu@gmail.com
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org
Subject: Re: [PATCH 8/9] check: run tests in a systemd scope for mandatory test cleanup
Date: Mon, 2 Nov 2020 13:37:56 -0800	[thread overview]
Message-ID: <20201102213756.GA7118@magnolia> (raw)
In-Reply-To: <160382534122.1202316.7161591166906029132.stgit@magnolia>

On Tue, Oct 27, 2020 at 12:02:21PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> If systemd is available, run each test in its own temporary systemd
> scope.  This enables the test harness to forcibly clean up all of the
> test's child processes (if it does not do so itself) so that we can move
> into the post-test unmount and check cleanly.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  check |   21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/check b/check
> index 5072dd82..47c72fa2 100755
> --- a/check
> +++ b/check
> @@ -521,6 +521,11 @@ _expunge_test()
>  	return 0
>  }
>  
> +# Can we run systemd scopes?
> +HAVE_SYSTEMD_SCOPES=
> +systemd-run --quiet --unit "fstests-check" --scope bash -c "exit 77" &> /dev/null
> +test $? -eq 77 && HAVE_SYSTEMD_SCOPES=yes
> +
>  # Make the check script unattractive to the OOM killer...
>  OOM_SCORE_ADJ="/proc/self/oom_score_adj"
>  test -w ${OOM_SCORE_ADJ} && echo -1000 > ${OOM_SCORE_ADJ}
> @@ -528,8 +533,22 @@ test -w ${OOM_SCORE_ADJ} && echo -1000 > ${OOM_SCORE_ADJ}
>  # ...and make the tests themselves somewhat more attractive to it, so that if
>  # the system runs out of memory it'll be the test that gets killed and not the
>  # test framework.
> +#
> +# If systemd is available, run the entire test script in a scope so that we can
> +# kill all subprocesses of the test if it fails to clean up after itself.  This
> +# is essential for ensuring that the post-test unmount succeeds.
>  _run_seq() {
> -	bash -c "test -w ${OOM_SCORE_ADJ} && echo 250 > ${OOM_SCORE_ADJ}; exec ./$seq"
> +	local cmd=(bash -c "test -w ${OOM_SCORE_ADJ} && echo 250 > ${OOM_SCORE_ADJ}; exec ./$seq")
> +
> +	if [ -n "${HAVE_SYSTEMD_SCOPES}" ]; then
> +		local unit="$(systemd-escape "fs$seq").scope"
> +		systemd-run --quiet --unit "${unit}" --scope "${cmd[@]}"

/me discovers that systemd preserves failed transient scopes (where
"failed" means the processes get killed, not that they return nonzero),
so this patch has to reset-failed the scope in case the user calls
fstests before rebooting.

Hence, self NAK.

--D

> +		res=$?
> +		systemctl stop "${unit}" &> /dev/null
> +		return "${res}"
> +	else
> +		"${cmd[@]}"
> +	fi
>  }
>  
>  _detect_kmemleak
> 

  parent reply	other threads:[~2020-11-02 21:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 19:01 [PATCH 0/9] xfstests: random fixes Darrick J. Wong
2020-10-27 19:01 ` [PATCH 1/9] common: extract rt extent size for _get_file_block_size Darrick J. Wong
2020-10-28  7:41   ` Christoph Hellwig
2020-10-28 22:24     ` Darrick J. Wong
2020-10-27 19:01 ` [PATCH 2/9] xfs/520: disable external devices Darrick J. Wong
2020-10-28  7:41   ` Christoph Hellwig
2020-10-27 19:01 ` [PATCH 3/9] xfs/341: fix test when rextsize > 1 Darrick J. Wong
2020-10-28  7:41   ` Christoph Hellwig
2020-10-27 19:01 ` [PATCH 4/9] various: replace _get_block_size with _get_file_block_size when needed Darrick J. Wong
2020-10-28  7:42   ` Christoph Hellwig
2020-10-27 19:02 ` [PATCH 5/9] xfs/327: fix inode reflink flag checking Darrick J. Wong
2020-10-28  7:42   ` Christoph Hellwig
2020-10-27 19:02 ` [PATCH 6/9] xfs/27[26]: force realtime on or off as needed Darrick J. Wong
2020-10-28  7:43   ` Christoph Hellwig
2020-10-27 19:02 ` [PATCH 7/9] xfs/030: hide the btree levels check errors Darrick J. Wong
2020-10-28  7:43   ` Christoph Hellwig
2020-10-27 19:02 ` [PATCH 8/9] check: run tests in a systemd scope for mandatory test cleanup Darrick J. Wong
2020-10-28  7:44   ` Christoph Hellwig
2020-10-28 16:58     ` Darrick J. Wong
2020-10-29  1:04     ` Darrick J. Wong
2020-11-02 21:37   ` Darrick J. Wong [this message]
2020-10-27 19:02 ` [PATCH 9/9] common/populate: make sure _scratch_xfs_populate puts its files on the data device Darrick J. Wong
2020-10-28  7:44   ` Christoph Hellwig
2020-10-28 16:27     ` Darrick J. Wong
2020-11-08 10:05 ` [PATCH 0/9] xfstests: random fixes Eryu Guan
2020-11-08 17:23   ` 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=20201102213756.GA7118@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=linux-xfs@vger.kernel.org \
    /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