From: Fam Zheng <famz@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org, Roman Pen <roman.penyaev@profitbricks.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/3] test-coroutine: test qemu_coroutine_entered()
Date: Wed, 28 Sep 2016 10:38:24 +0800 [thread overview]
Message-ID: <20160928023824.GF1284@lemon> (raw)
In-Reply-To: <1474989516-18255-3-git-send-email-stefanha@redhat.com>
On Tue, 09/27 16:18, Stefan Hajnoczi wrote:
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> tests/test-coroutine.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 42 insertions(+)
>
> diff --git a/tests/test-coroutine.c b/tests/test-coroutine.c
> index 6431dd6..abd97c2 100644
> --- a/tests/test-coroutine.c
> +++ b/tests/test-coroutine.c
> @@ -53,6 +53,47 @@ static void test_self(void)
> }
>
> /*
> + * Check that qemu_coroutine_entered() works
> + */
Not related to this patch:
It's a bit weird that in this file function header comments are followed by a
blank line, and in one case it even looks like as odd as this:
static void test_order(void)
{
int i;
const struct coroutine_position expected_pos[] = {
{1, 1,}, {2, 1}, {1, 2}, {2, 2}, {1, 3}
};
do_order_test();
g_assert_cmpint(record_pos, ==, 5);
for (i = 0; i < record_pos; i++) {
g_assert_cmpint(records[i].func , ==, expected_pos[i].func );
g_assert_cmpint(records[i].state, ==, expected_pos[i].state);
}
}
/*
* Lifecycle benchmark
*/
static void coroutine_fn empty_coroutine(void *opaque)
{
/* Do nothing */
}
> +
> +static void coroutine_fn verify_entered_step_2(void *opaque)
> +{
> + Coroutine *caller = (Coroutine *)opaque;
> +
> + g_assert(qemu_coroutine_entered(caller));
> + g_assert(qemu_coroutine_entered(qemu_coroutine_self()));
> + qemu_coroutine_yield();
> +
> + /* Once more to check it still works after yielding */
> + g_assert(qemu_coroutine_entered(caller));
> + g_assert(qemu_coroutine_entered(qemu_coroutine_self()));
> + qemu_coroutine_yield();
> +}
> +
> +static void coroutine_fn verify_entered_step_1(void *opaque)
> +{
> + Coroutine *self = qemu_coroutine_self();
> + Coroutine *coroutine;
> +
> + g_assert(qemu_coroutine_entered(self));
> +
> + coroutine = qemu_coroutine_create(verify_entered_step_2, self);
> + g_assert(!qemu_coroutine_entered(coroutine));
> + qemu_coroutine_enter(coroutine);
> + g_assert(!qemu_coroutine_entered(coroutine));
> + qemu_coroutine_enter(coroutine);
> +}
> +
> +static void test_entered(void)
> +{
> + Coroutine *coroutine;
> +
> + coroutine = qemu_coroutine_create(verify_entered_step_1, NULL);
> + g_assert(!qemu_coroutine_entered(coroutine));
> + qemu_coroutine_enter(coroutine);
> +}
> +
> +/*
> * Check that coroutines may nest multiple levels
> */
>
> @@ -389,6 +430,7 @@ int main(int argc, char **argv)
> g_test_add_func("/basic/yield", test_yield);
> g_test_add_func("/basic/nesting", test_nesting);
> g_test_add_func("/basic/self", test_self);
> + g_test_add_func("/basic/entered", test_entered);
> g_test_add_func("/basic/in_coroutine", test_in_coroutine);
> g_test_add_func("/basic/order", test_order);
> if (g_test_perf()) {
> --
> 2.7.4
>
Reviewed-by: Fam Zheng <famz@redhat.com>
next prev parent reply other threads:[~2016-09-28 2:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-27 15:18 [Qemu-devel] [PATCH v2 0/3] linux-aio: fix "Co-routine re-entered recursively" error Stefan Hajnoczi
2016-09-27 15:18 ` [Qemu-devel] [PATCH v2 1/3] coroutine: add qemu_coroutine_entered() function Stefan Hajnoczi
2016-09-28 2:19 ` Fam Zheng
2016-09-27 15:18 ` [Qemu-devel] [PATCH v2 2/3] test-coroutine: test qemu_coroutine_entered() Stefan Hajnoczi
2016-09-28 2:38 ` Fam Zheng [this message]
2016-09-27 15:18 ` [Qemu-devel] [PATCH v2 3/3] linux-aio: fix re-entrant completion processing Stefan Hajnoczi
2016-09-28 2:40 ` Fam Zheng
2016-09-28 16:12 ` [Qemu-devel] [Qemu-block] [PATCH v2 0/3] linux-aio: fix "Co-routine re-entered recursively" error Stefan Hajnoczi
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=20160928023824.GF1284@lemon \
--to=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=roman.penyaev@profitbricks.com \
--cc=stefanha@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;
as well as URLs for NNTP newsgroup(s).