From: Eric Blake <eblake@redhat.com>
To: Cleber Rosa <crosa@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 05/10] qemu-iotests: define functions used in _cleanup() before its use
Date: Fri, 1 Dec 2017 15:03:02 -0600 [thread overview]
Message-ID: <94cfacec-b804-f9de-e769-243ff4a206e7@redhat.com> (raw)
In-Reply-To: <20171116173810.16457-6-crosa@redhat.com>
On 11/16/2017 11:38 AM, Cleber Rosa wrote:
> The functions used in _cleanup() come from common.rc, which currently
> gets sourced after _cleanup() is defined and registered as a signal
> handler. When _cleanup() is executed, it has no valid references to
> those functions, as BASH won't resolve the reference at that time.
>
Rather, there is a (small) window of time where if the test gets killed
after the trap handler is registered but before the function definition
is sourced, then the trap handler will fail to execute correctly
(although if you kill the process that early, there was probably nothing
that the handler would have cleaned up, so you are just littering extra
messages to stderr).
Bash does NOT require a function to exist before a trap handler
references it - only that the function exists at the time the trap
handler body is invoked later.
> +++ b/tests/qemu-iotests/001
> @@ -27,15 +27,15 @@ echo "QA output created by $seq"
> here=`pwd`
> status=1 # failure is the default!
>
> +# get standard environment, filters and checks
> +. ./common.rc
> +
> _cleanup()
> {
> _cleanup_test_img
> }
> trap "_cleanup; exit \$status" 0 1 2 3 15
>
> -# get standard environment, filters and checks
> -. ./common.rc
> -
At any rate, I do think it reads better in this order, and consistency
is nice.
With an improved commit message,
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2017-12-01 21:03 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-16 17:38 [Qemu-devel] [PATCH 00/10] I/O tests cleanups Cleber Rosa
2017-11-16 17:38 ` [Qemu-devel] [PATCH 01/10] qemu-iotests: make execution of tests agnostic to test type Cleber Rosa
2017-11-17 7:25 ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2017-11-17 13:15 ` Cleber Rosa
2017-12-01 20:16 ` Max Reitz
2017-11-16 17:38 ` [Qemu-devel] [PATCH 02/10] qemu-iotests: fix filename containing checks Cleber Rosa
2017-12-01 20:17 ` Max Reitz
2017-11-16 17:38 ` [Qemu-devel] [PATCH 03/10] qemu-iotests: be strict with expected output Cleber Rosa
2017-12-01 20:25 ` Max Reitz
2017-11-16 17:38 ` [Qemu-devel] [PATCH 04/10] qemu-iotests: include (source) filters from common.rc Cleber Rosa
2017-12-01 20:28 ` Max Reitz
2017-11-16 17:38 ` [Qemu-devel] [PATCH 05/10] qemu-iotests: define functions used in _cleanup() before its use Cleber Rosa
2017-12-01 20:43 ` Max Reitz
2017-12-01 21:03 ` Eric Blake [this message]
2017-11-16 17:38 ` [Qemu-devel] [PATCH 06/10] qemu-iotests: turn owner variable into a comment Cleber Rosa
2017-11-17 7:19 ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2017-11-17 13:18 ` Cleber Rosa
2017-11-17 17:59 ` Eric Blake
2017-11-16 17:38 ` [Qemu-devel] [PATCH 07/10] qemu-iotests: remove the concept of $seq.full (and boiler plate code) Cleber Rosa
2017-12-01 20:52 ` Max Reitz
2017-11-16 17:38 ` [Qemu-devel] [PATCH 08/10] qemu-iotests: clean up double comment characters Cleber Rosa
2017-12-01 20:53 ` Max Reitz
2017-11-16 17:38 ` [Qemu-devel] [PATCH 09/10] qemu-iotests: remove unused "here" variable Cleber Rosa
2017-11-17 18:03 ` Eric Blake
2017-12-01 20:55 ` Max Reitz
2017-11-16 17:38 ` [Qemu-devel] [PATCH 10/10] qemu-iotests: add section on how to write a new I/O test Cleber Rosa
2017-12-01 21:12 ` Max Reitz
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=94cfacec-b804-f9de-e769-243ff4a206e7@redhat.com \
--to=eblake@redhat.com \
--cc=crosa@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).